Custom API actions
Custom API actions let your AI chatbot look things up in your own systems while it chats: an order's status, a booking reference, an account balance. The agent asks the visitor for what it needs, calls your API, and shows the answer in the chat.
You need an agent, an https address on your server that answers with JSON, and an owner or admin role to set it up. You can test a call before anything goes live.
What an action is
An action is something your agent can do besides answering from what it learned. Actions (under Train) lists them all as cards: your forms, your custom API actions and Shopify. Each card has an on/off switch.
A custom API action is one request to your API. You choose the address, what the agent asks the visitor for, and which values from the answer the visitor sees. Use the Custom tab to see only your API actions.
Which plans include it
Custom API actions are included on Starter, Pro, Business, and during the free trial. Each agent can have up to 5, few enough for the agent to pick the right one.
On Free you can set one up and run a test call; to save it, upgrade in Billing.
Create an API action
- In Actions, click New action, then New API action.
- Under Basics, give it a Name and say What it returns, for example "The status and delivery date of an order".
- Under Request, choose GET or POST and paste the Address. Put each input in it by its id in braces, such as
https://api.example.com/orders/{order_id}. - Under Inputs the agent asks for, click Add input for each value, with an Id (
order_id), a Label ("Order number") and What to ask for ("From the confirmation email"). Tick Required where it is. - Add any Headers your API needs, such as an API key.
- Click Test call with sample values. Then, under Show in the chat, click Pick for me or pick the values yourself.
- Click Add action.
On GET, inputs that aren't in the address are added as query parameters; on POST they are sent as the JSON body.
Tell the agent when to use it
Write it in plain words under When should the agent use it?, for example "When the visitor asks where their order is". Leave it empty and the agent uses it whenever the visitor needs what it returns.
Under Show as, choose Card to show the picked values in a card (one item, a list or a table) while the agent sums them up, or Text to have the agent answer in words. Picking POST switches it to Text. Before a POST, the agent reads the details back and waits for the visitor's yes. With no values picked, it just confirms the request went through.
Test it in the Playground
The Test call in the editor checks your API. Nothing is saved by it, and no visitor sees it.
To see the whole conversation, click Try in Playground in the saved action and ask what a visitor would ask. The agent asks for the inputs, calls your API and shows the answer, just as it will on your site.
Turn an action off
Flip the switch on its card in Actions, or turn off Enabled in the action and click Save changes. The agent stops using it from the next message. To delete it, click Remove (the bin icon) in the action and confirm; chats where it already answered keep what they showed.
If your plan no longer includes API actions, they are paused, not deleted. Upgrade and they work again as they were.
Keep your API safe
- Your API is called from our servers, never from the visitor's browser, and only at public https addresses.
- Header values are stored encrypted and never shown again. Use a read-only key.
- Only the values you pick under Show in the chat reach the visitor and the agent. The rest of the answer stays on our servers.
- Your API must answer within 10 seconds. A 404 tells the agent nothing was found.
- Anyone can type anything into a chat, so don't return private data for a value the visitor could guess. Ask for two things that must match, like an order number and the email on the order.