Skip to content

Automations

An app built on Sovyn can do work on its own, without anyone clicking a button: send an email when someone posts a review, or clean up old entries every Monday morning. Your AI assistant builds this from two parts:

  • A function is a small piece of server code, written by your assistant. It can read and write all data of the app.
  • A workflow says when something happens and which steps run then, one after the other.

Functions and workflows are part of the app like its data and its pages. A deploy puts them into development, a move to production takes them along.

A workflow starts in one of three ways:

  • On a new entry: someone creates an entry in a collection, for example a new review. The workflow knows that entry.
  • On a schedule: at fixed times, for example every Monday at 07:00. Times are always in UTC (no time zones); your assistant converts your local time. Two runs are at least 15 minutes apart. If the previous run of the same workflow is still going, the next one is left out.
  • On a webhook: another service such as Stripe, Mollie or GitHub reports an event to the app, for example a paid invoice, at https://<app>.sovyn.site/api/hooks/<name> (in development at <app>--dev.sovyn.site). The app checks the sender’s signature; you enter the signing key from the service’s dashboard as a secret. The sender gets no answer from the workflow. Webhooks are included in development and production.

Workflows do not start when an entry is changed or deleted yet.

A workflow has steps of four kinds:

  • Run a function: the function does the actual work. It can also decide that nothing needs to happen; then the run ends as skipped, and the steps after it do not run. A skipped run is not an error.
  • Send an email: an email to an end user of the app (see below).
  • Ask the AI: for example “Summarise this request in three sentences”. The answer is available to the steps after it. See AI.
  • Send a webhook: notify another service, for example on every new booking, signed so the receiver can check that the message comes from your app. If the receiver does not answer, Sovyn retries for up to 24 hours.

If a step fails, the run stops there.

Example: when a new review arrives, a function counts the reviews of the book, and then an email tells the person who added the book.

workflows:
on-new-review:
on: { collection: reviews, event: created }
steps:
- run: count_reviews
- email:
to: "{{steps.count_reviews.added_by}}"
subject: "New review of {{steps.count_reviews.title}}"
text: "{{record.stars}} stars. The book now has {{steps.count_reviews.reviews}} reviews."
  • An email always goes to an end user of the app, never to a free address. The recipient comes from the entry or from a function.
  • It is plain text, or plain text plus a simple HTML version. HTML is limited: no scripts, no images from other websites, no attachments.
  • In production it comes from noreply@sovyn.site with the name “<app> (sovyn.build)”, without a reply address. It can come from your own domain instead; see Custom domain. Every email counts against the monthly email quota of the plan. At the quota, the step fails and names the reason.
  • Development sends no email. The email (recipient, subject, text) only appears on the run, so you can check it without bothering anyone. Development allows at most 100 emails per day (UTC).

Your app can ask an AI model without an API key of its own: as a step in a workflow or from a function. The models come from Mistral and run in the EU.

  • Each question costs what Mistral charges for it, without markup. It is paid from the environment’s monthly AI credit: €0.50 in development, €2 in production (see Plans and usage).
  • Once the credit is used up, the question fails with the reason and the day the credit resets. There are no extra charges.
  • A workflow step may take up to 60 seconds, a function only 10. For long texts your assistant therefore uses the step.
  • Another model, for example from OpenAI, still works with a key of your own; see Outside services.

Unless told otherwise, your assistant uses mistral-small. To use another model, tell it, for example: “Use mistral-large for the summary.” It then sets the model on the step or in the function; you can choose differently for each step.

Model Good for Price per 1M tokens (in / out)
mistral-small short, simple texts: summarize, sort, reply briefly €0.10 / €0.30
mistral-medium harder tasks, longer answers €0.40 / €2.00
mistral-large the hardest tasks, more careful weighing €0.50 / €1.50

A larger model costs about four to five times as much per question and uses up the AI credit correspondingly faster. It also answers more slowly; in a function with its 10 seconds the time may then not be enough, in a step it is. Try the model in development: every answer shows what it cost.

  • A call may take at most 10 seconds and 128 MB of memory.
  • At most 4 calls of an app run at the same time.
  • A function that writes data can start further workflows. After a chain of 5, the run fails, so the app cannot loop forever.
  • Each function call counts against the monthly quota of the environment, also on a schedule. If the quota is reached, a scheduled run ends as skipped with the reason, not as failed.

A function can call services on the internet, such as Stripe, OpenAI or Resend, in development and in production. Try such calls in development with the service’s test key; production gets the live key.

  • Only web addresses (HTTP and HTTPS, ports 80 and 443). Private networks and internal addresses stay blocked.
  • There is no fixed outgoing IP address.
  • Services need an API key. You enter it as a secret; see API keys and secrets.

Your assistant can use npm packages in functions.

  • Work: packages written in pure JavaScript, and client libraries that talk to their service over the web, such as openai, @anthropic-ai/sdk, stripe, resend or @supabase/supabase-js.
  • Do not work: anything that opens its own connection, such as database and cache drivers (pg, mysql2, mongodb, redis), email over SMTP (nodemailer), and axios unless it is set up to use fetch. Also packages that start programs, read files or need native code, such as sharp or bcrypt. There is often a pure JavaScript alternative, such as bcryptjs.

Ask your assistant to look at the runs of the app. For each run it sees the workflow, the status (running, succeeded, failed or skipped), the error, the steps with their input and output, the log lines of the function and the email. It then fixes the function or the workflow and deploys again.

  • Workflows on changed or deleted entries.
  • Conditions in the workflow itself; a function decides instead.
  • Calling a function directly over a web address. A webhook only starts a workflow and gets no answer from it.
  • AI answers as a stream, and models other than mistral-small, mistral-medium and mistral-large without a key of your own.
  • Emails to free addresses, attachments or images from other websites.
  • Files in functions.