Triggers
Tasks that start when new mail arrives or when another system calls them.
A task can start when something happens instead of at a time. There are two triggers: new mail, and a call to the task's address (a webhook).
When new mail arrives
Tell a bot: "When an email comes from acme.com, pull out the quote request and summarize it for me." You'll need a mailbox added under the Email app first.
- Mohzi checks the inbox every 5 minutes. The check is done by the server, not the model, so a check that finds nothing costs nothing.
- Mail already in the inbox when you set the task is ignored. Only mail that arrives afterwards counts.
- You can limit it to mail from a sender (an address, a domain or a name) and mail containing a word.
- New mail is handed to the task ten messages at a time; more than that is picked up at the next check.
- If the mailbox needs you to sign in again, checks stop until you do, and you're told after three failed checks.
When another system calls
Tell a bot: "Give me an address our ERP can call when there's a new order, and check each order against the price list." The bot replies with an address like:
https://app.mohzisi.com/api/hooks/task/k3Jq… (32-character secret)
Anything that can make an HTTP POST can call it: an ERP, a form tool, a CI pipeline, GitHub.
curl -X POST https://app.mohzisi.com/api/hooks/task/<secret> \
-H 'Content-Type: application/json' \
-d '{"order": "SO-1042", "customer": "Acme", "total": 1640}'
The body can be JSON or plain text. The task starts at once with what was sent; calls that arrive while it's running are handled next, ten at a time.
| Response | Meaning |
|---|---|
202 | Accepted. The task will run with it. |
404 | No task has this address. It may have been deleted. |
409 | The task is paused. |
413 | The body is larger than 20 KB. |
429 | More than 60 calls in the last hour, or 30 calls already waiting. |
The secret in the address is the only credential. Give it only to the system that needs it. To get a new address, delete the task and set it up again.
What a triggered task may do
Mail and webhook bodies are written by someone else, and may contain instructions meant to trick a bot. So a task started by a trigger is restricted, whatever you've allowed elsewhere:
- It can read and look things up: your mail, databases, the knowledge base, files on your computer.
- It can make Word, PDF and XMind files in Mohzi.
- It can't send messages to anyone, change data, use connected apps, browse the web, or do anything on your computer except read. It doesn't make Excel files, because a spreadsheet formula can send data out when the file is opened.
- It can't run as a long task.
- The content is marked as coming from outside, and links in it are not treated as links you gave.
If the task needs to do something it isn't allowed to, it says so in its result and you can do it from the conversation.