AIAgent
Hand the call to one of your Sautikit AI agents.
Hand the call to one of your Sautikit AI agents.
aiAgent hands the call to one of your Sautikit AI agents. It must be the last action in the list; say and play may come before it.
An AI agent costs KES 4.00 a minute on top of the call rate, metered per second.
| Parameter | Type | Required | Description |
|---|---|---|---|
agentId | string | Yes | The agent's id (a UUID). Agents are addressed by id, not by name. |
revision | integer | No | A published revision to run. 0 or omitted runs the agent's current one. |
variables | object | No | Named values given to the agent for this call, such as the caller's name. Keys and values are strings. |
handover | object | No | Where the caller goes when the agent hands the call back. Set exactly one of its three fields. See below. Without it the number's own handover setting applies, and if there is none the call ends. |
onUnavailable | string | No | What happens when the agent cannot take the call, for example when it has no published revision or no AI seat is free: hangup (default), voicemail, forward or callback. |
voicemail | object | No | The voicemail to use when onUnavailable is voicemail. See below. |
forward | object | No | Where to send the call when onUnavailable is forward. See below. |
handover takes:
| Field | Type | Description |
|---|---|---|
callbackUrl | string | Sautikit POSTs to this URL and runs the voice actions it returns. |
forward | object | Ring other people. |
voicemail | object | Take a message. |
forward takes:
| Field | Type | Description |
|---|---|---|
destinations | array of strings | Phone numbers in E.164 form, client:<username> identities, or 4-digit extensions. |
sequential | boolean | true rings the destinations one at a time instead of together. |
firstAnswerWins | boolean | true stops ringing the others once one answers. |
ringTimeout | integer | Seconds to ring each attempt. 0 or omitted uses the default. |
callerId | string | The number shown to the destination. |
voicemail | object | Take a message if nobody answers. |
voicemail takes:
| Field | Type | Description |
|---|---|---|
greetingText | string | Spoken before the tone. |
greetingPlayUrl | string | A recording hosted on Sautikit, played instead of greetingText. |
greetingVoice | string | Voice for greetingText: man or woman. |
maxLength | integer | Longest message, in seconds. 0 or omitted uses the default. |
beep | boolean | Play a tone before recording starts. |
import { sauti } from "@sautikit/node";
res.json(sauti.voiceResponse([
sauti.say("Connecting you to our assistant."),
sauti.aiAgent("3f1b8c22-6a4e-4f1a-9c77-5b2e0d9a4411", {
handover: {
forward: {
destinations: ["+254720000000"],
voicemail: { greetingText: "Sorry we missed you. Leave a message after the tone." },
},
},
}),
]));{
"actions": [
{
"say": {
"text": "Connecting you to our assistant."
}
},
{
"aiAgent": {
"agentId": "3f1b8c22-6a4e-4f1a-9c77-5b2e0d9a4411",
"handover": {
"forward": {
"destinations": [
"+254720000000"
],
"voicemail": {
"greetingText": "Sorry we missed you. Leave a message after the tone."
}
}
}
}
}
]
}Route inbound calls to an AI agent covers the setup.