What is a Letterflow?
A Letterflow connects steps you want Hato API to run together. For example, you can send a request, check its response, and send an email when it needs your attention.
Build a Letterflow
On the Dashboard, choose Create Flow. Enter a Letterflow Name and choose a Coordinator, the region that runs the flow and evaluates Value and Condition steps.
Click or tap a component in the palette to add it. Select it to edit its properties. Give each step after Start a unique Step ID, such as fetch_item, so later steps can refer to its result.
Drag from a step’s bottom connection point to the next step’s top connection point. On a touchscreen, tap the bottom point first, then the top point. Drag a component to move it or drag empty space to pan.
Letter component
The Letter component is the core of Hato API because it sends the API request.
A Letter sends a request or transfers a file. Later steps can use its response status, headers, or body.
- Delivery Policy and Execution Region
- Choose the policy for timeouts, retries, and size limits, and the region that sends this request. On Tinkerer, use the Coordinator region for every
Letter. The builder shows your separate limit for these components. - Target Protocol and Target URL
- Choose HTTP or HTTPS for an API, or an available file-transfer protocol for a file. Enter the full URL for the endpoint or file.
- HTTP Method and Headers
- Choose the action your API expects, such as GET to read or POST to submit data. Add headers as fields or plain text. Headers expression accepts a Headers value or a JSON object. Headers you enter on this request override matching names from the expression.
- Request Body Type and Content-Length
- For a request that sends data, enter text such as JSON, upload a binary file, or add text and files as multipart fields. Auto-include Content-Length sets the length from the body size unless you supply your own header.
- Authentication and file transfers
- Use Directory basic authentication when a saved credential is needed. For FTP, FTPS, or SFTP, choose Download or Upload and the authentication your server requires. SFTP also requires the server’s SHA256 fingerprint. You can use a Directory private key, upload your own key with its passphrase if needed, or generate one.
- Follow redirects and Use flow session
- For HTTP, enable Follow redirects and set the maximum if the service redirects requests. Each followed redirect that reaches a server counts toward usage. Enable Use flow session on the HTTP steps that should share login cookies during this run.
Flow session example
- Enable Use flow session on the first
Letter, sign_in. It signs in to the shop service and saves the login cookie. - Leave Use flow session off on the second
Letter, check_status. It calls a public status endpoint without sending or changing the saved login cookie. - Enable Use flow session again on the third
Letter, fetch_orders. It can use the cookie from sign_in to fetch orders from the same shop service.
Value component
Use a Value to prepare a result for later steps, such as a number read from a response or a message built from several values.
- Input and Output type
- Enter the value or expression in Input. Choose Text for a message, JSON or XML for structured data, or HTTP headers for a reusable set of headers. Input is limited to 64 KiB, and text output to 1 MiB.
- Document template
- For JSON or XML, turn on Document template to insert variables when the flow runs. In JSON, leave a numeric expression outside quotes to keep it a number.
- Test, Run, and Output
- Enter a trial expression in Test, click Run beside it, and read the result in Output. Testing does not change Input or save the result. Tests can use earlier
ValueandConditionsteps. LiveLetterandEmailresults are available in a flow run.
Condition component
A Condition picks the next path based on a check, such as whether remaining stock is below a threshold.
- Condition Statement
- Enter a comparison without double braces. It must return true or false and fit within 64 KiB. A false result is a normal outcome. An evaluation error stops the run.
- True and False outputs
- The True output is on the left. The False output is on the right. Connect each to the step you want on that path. If the chosen output has no connection, the run ends there.
Email component
An Email sends a notification when a run reaches that step. It is available on paid plans. Check Usage for your sending allowance.
- To and Reply-To
- Enter one recipient and, optionally, one address for replies. Hato supplies the sender. You can use variables in both fields.
- Subject, Format, and Body
- Write the subject and message, using variables if needed. Choose Plain text or HTML. After inserting variables, the subject is limited to 255 bytes, the body to 64 KiB, and the full message to 256 KiB. Attachments and CC/BCC are unavailable.
- On error
- Choose Stop to end the run after a send failure or Continue to follow the next connection.
Variables in Letterflows
Use the Step ID to refer to a result. A step must run earlier on the path your flow takes. Use prev.output when you want the result of the step immediately before this one.
Use the Expression builder
Open Expression builder above the canvas. Choose a source variable and, if you need a field inside it, enter a path such as .customer.name. Use [0] for the first item in a list.
Add a function if you want to change the value. The builder lists the available functions. Copy the generated expression and paste it into the field you want to fill.
Common examples
Read a field from the JSON response of a Letter with the Step ID lookup.
{{ (lookup.body | to_json).email }}
Insert a name into the subject of an Email or a text Value. Add upper after a pipe to display the name in uppercase.
Order for {{ order.customer | upper }}
A Condition takes a check directly. Leave out the double braces when entering the comparison.
order.total >= 40
Validation
Click Validate before saving. Every edit clears the previous validation, so click Validate again after each change. Select a warning to find the field to fix. After the check finishes, choose Save Letterflow. Fix any remaining warnings before you run the flow.
Run the saved flow from the Dashboard. Open the Letterbox to see which steps ran and what they returned.
Letterbox guide →Example of a stock refill alert
A shopkeeper wants an email when fewer than 10 desk lamps are in stock. To try this example, use your own inventory API and a paid plan that supports the Email component.
Fetch the item. Connect Start to a Letter with Step ID fetch_item. Send a GET request to your inventory API, for example https://inventory.example/items/desk-lamp. A response might look like this.
{"sku":"desk-lamp","remaining_stock":4}
Extract the stock count. Connect a Value with Step ID stock. Choose JSON for Output type and turn on Document template. Enter the expression below in Input so the result stays a number.
{{ (fetch_item.body | to_json).remaining_stock }}
Check the threshold. Connect a Condition with Step ID needs_refill. Enter the check below in Condition Statement.
stock < 10
Email the shopkeeper. Connect the left True output to an Email with Step ID alert_shopkeeper. Enter the shopkeeper’s address in To, set the Subject to Desk lamp stock is low, and choose Plain text for Format. Use the message below as the Body. Leave the right False output unconnected.
Only {{ stock }} desk lamps remain. Please refill the stock.
Validate, save, and run the flow. In the Letterbox, a count of 4 follows the left True path and sends the email. A count of 10 or more follows the right False path and ends without an email.