Skip to main content
APIs involved: Configuration API, Agent Chat API, Webhooks Bots in Text are dedicated agent identities that operate entirely via the Agent Chat API Web — not RTM, which is for human agents. A bot gets its own token and responds to chats through webhooks rather than by staying connected. This guide builds a triage bot: it greets every new customer, attempts to match their question against a set of known answers, and transfers to a human if it can’t help.

Prerequisites

  • An agent access token with scope bots--all:rw and webhooks--all:rw. Create one in Text under Settings → API access → Personal access tokens.
  • A server with a publicly reachable HTTPS endpoint to receive webhooks.
  • The group ID of the queue the bot will serve, and the group ID of the human agent queue to hand off to. Find these in Text under Settings → Chat routing → Groups.

Step 1: Create the bot and get its token

Call create-bot with an agent access token. Assign the bot to the group it should serve.
Now get the bot’s own access token. All Agent Chat API calls the bot makes must use this token, not your agent token.
Store this access_token — your bot uses it for every subsequent call.

Step 2: Register webhooks

Register two webhooks using the bot’s token (not your agent token). This scopes them to the bot’s activity. incoming_chat — fires when a customer starts a new chat in the bot’s group:
incoming_event — fires when the customer sends a message:
Both webhooks deliver to the same URL. Your handler branches on action to tell them apart.

Step 3: Handle incoming chats and messages

When incoming_chat fires, the payload includes the full chat object with the chat_id you need for all subsequent calls:
When incoming_event fires for a customer message:
Sending a message uses send-event with the bot token:
Transferring to a human uses transfer-chat. The full message history is preserved — the agent sees everything the bot exchanged:

Step 4: Put it together

Here is a complete webhook handler for the triage pattern — greet, attempt to match, transfer if needed:

Going further

AI responses: replace matchAnswer with a call to a language model to handle a much wider range of questions before falling back to a human. Collecting structured info: before transferring, have the bot ask for an order number or account email, then use update-chat-properties to store the values on the chat object. The agent who picks up the conversation sees them immediately in the customer details panel. Typing indicators: call send-typing-indicator before sending a message to make the bot feel more natural.