Events and webhooks
Events let bots respond to something that happened outside chat: a new lead, a GitHub push, a payment event, or an internal system update.
Message events
The most common event is on user.message. It runs when someone chats with the bot.
on user.message {
respond
}Webhook events
Use webhooks when another system should trigger the bot. Always verify signatures for production webhooks.
bot LeadRouter {
description: "Scores inbound leads from a website form"
capabilities {
ai.generate
slack.send
}
webhook newLead path "/webhooks/leads" verify signature with secret LEAD_WEBHOOK_SECRET {
score = call ai.generate with {
prompt: f"Score this lead from 1-10 and explain why: {webhook}"
}
if score contains "8" {
call slack.send with {
channel: "#sales",
message: f"High intent lead: {score}"
}
} else {
say f"Lead recorded: {score}"
}
}
}Production checklist
- Verify the webhook signature.
- Deduplicate events using memory or an external ID.
- Retry network actions with fallback notifications.
- Never trust webhook payload text without validation.