Your app and Oalo, end to end
One worked example: host a server app, let it start workflows with events, and give a bot a tool that reads the signed-in user's own data.
This page walks one example through every piece: a Node shop server that tells Oalo when an order ships, a workflow that emails the customer, and a chat bot on the shop's pages that can look up the signed-in customer's own orders. Each step links to the page with the details.
You need the oalo CLI, logged in to your Base (oalo login <base> for
<base>.oalo.ai), and Developer access (or admin).
1. Host the app
From the repo's folder, with everything committed:
oalo deploy --new shop-api # a new app from this repo, its preview started
Oalo works out that it's a Node server and starts it on $PORT. See
Bring your repo if it can't tell.
2. What the app gets
Its environment already holds:
OALO_URLandOALO_SYNC_TOKEN: its own token, locked to its env (dev in the preview, prod live). It reads and writes data, sends events, calls workflows and starts chat sessions. There is no token to make.DATABASE_URL: its PostgreSQL database, if it keeps its own tables.
Keys it needs from elsewhere (a payment provider, say) go in with
oalo env set NAME --secret. See App environment.
3. Tell Oalo when something happens
When an order ships, the shop's server sends an event:
async function orderShipped(order, user) {
const res = await fetch(`${process.env.OALO_URL}/api/events/v1`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.OALO_SYNC_TOKEN}`,
"Content-Type": "application/json",
"Idempotency-Key": `shipped-${order.id}`,
},
body: JSON.stringify({
name: "app.order_shipped",
payload: { order_id: order.id, carrier: order.carrier },
contact: { external_ref: String(user.id), email: user.email, name: user.name },
}),
});
if (res.status !== 202) console.error("OALO event failed", res.status, await res.text());
}
contact says who it's about: Oalo finds that person by your own id, their
email or their phone, and adds them when they're new. In the preview, events
are dry runs: they register the name and say which workflows they would start,
and nothing runs. See App events.
If the fact is a row changing in an Oalo model, you don't need code:
oalo data events shipments created updated fires data.shipments.created
and .updated for every write.
4. A workflow reacts
Make a loop (in the dashboard, or a file pushed with oalo push) that sends the
email, with an event trigger on app.order_shipped. In a pulled loop file that
is:
"triggers": [{ "type": "event", "event": "app.order_shipped" }]
Steps read the event as {{trigger.payload.order_id}}, and the contact by id:
a send step takes to_contact_id: "{{trigger.contact_id}}" (loops have no
contact scope). Then check it, without sending anything:
oalo emit app.order_shipped --dry-run # which loops would start
oalo loops test shipped_email --sample latest # every step runs, sends simulated
oalo loops on shipped_email # when you're ready for it to run
5. A bot that knows the signed-in customer
The tool. Write the endpoint in the shop, then declare it in
.oalo/app.json and deploy:
{
"tools": [
{
"name": "order_status",
"description": "The status and delivery date of one of the signed-in customer's orders",
"method": "POST",
"path": "/oalo/tools/order-status",
"input": { "order_id": "string" },
"user": "required"
}
]
}
Oalo signs every call with the app's own OALO_SYNC_TOKEN and says whose chat
it is in X-Oalo-User (your own id for them). Check the signature and trust
that user, never the input. oalo typegen writes verifyOaloToolCall for a
TypeScript app; App tools has the exact format for any language.
import { verifyOaloToolCall } from "./oalo.generated";
app.post("/oalo/tools/order-status", express.text({ type: "*/*" }), async (req, res) => {
const call = await verifyOaloToolCall({ method: req.method, path: req.originalUrl, headers: req.headers, body: req.body }).catch(() => null);
if (!call?.user) return res.status(401).end();
const { order_id } = JSON.parse(req.body);
res.json(await orders.statusFor(call.user, order_id));
});
Give the bot the tool:
oalo bots # find the bot's public id
oalo bots tools bot_ABC --add order_status
The chat on the shop's pages. One script tag, and an endpoint on the shop that says who is signed in:
<script src="https://<base>.oalo.ai/chat-widget.js" data-bot="bot_ABC"
data-host="https://<base>.oalo.ai" data-user-url="/api/oalo-chat-session" defer></script>
app.get("/api/oalo-chat-session", async (req, res) => {
if (!req.user) return res.status(401).end(); // signed out: the chat stays anonymous
const r = await fetch(`${process.env.OALO_URL}/api/chat/v1/sessions`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.OALO_SYNC_TOKEN}`, "Content-Type": "application/json" },
body: JSON.stringify({ bot: "bot_ABC", user: { external_ref: String(req.user.id), email: req.user.email, name: req.user.name } }),
});
res.status(r.status).json(await r.json());
});
The bot must be published, and its allowed domains should list the shop's hosts. See Chat widget.
What you can test where:
oalo qa bot_ABC "where is my order 1042?"talks to the bot, but as nobody, so auser: "required"tool refuses there. That's a correct refusal.- Signed-in tools are tried from the shop's page, signed in. A published bot calls the live app's tools, even from a preview page, so try them once the tool is live (step 6), with a test customer.
6. Go live
oalo deploy --env prod # when you're ready to go live
The live app gets its own OALO_SYNC_TOKEN (prod data, real events), its
.oalo/app.json tools are published again for the live address, and the
workflow starts for real customers. If something breaks, oalo logs --env prod
first, and see Troubleshooting deploys.
Host code you already have: oalo deploy --new makes an app from a repo on your machine or at a Git URL, how Oalo tells what kind of app it is, and what to add.
Give an app its API keys and settings with oalo env, per env: what is secret, what each kind of app gets, its own token and database, and when changes apply.
Start workflows from your app: send an app.* event to POST /api/events/v1, or turn on row events so table changes fire data.<table>.created.
Make your server app's own endpoints into tools a bot or workflow can call: declare them in .oalo/app.json, deploy, and check Oalo's signature.
Put a bot on any web page with one script tag, anonymous or signed in as your app's own user through POST /api/chat/v1/sessions.
What starts a flow or a loop (events, schedules, dates, forms, API calls), what on and off mean, and how one runs another.
Sign up, install the CLI, and deploy your repo in a few minutes.