Actions

Let your bots call your own APIs during a conversation. For example, to search your content, look up an order or make a booking.

An action is one of your own HTTP APIs that a bot can use as a tool. You describe the API once, then link it to any of your bots.

Here is what happens in a conversation. The agent reads the name and description of each action. When a question needs an action, the agent fills in its inputs. Heyllo calls your API, and the agent answers using the response.

Your content stays in your system and nothing is copied into Heyllo. You can use an API you already have. It does not need a special endpoint or response format.

Actions are private to your organisation. Only your partner portal and organisation-wide keys with the actions:manage scope can see, test or link them. You might give your own customers keys bound to a workspace or a bot. Those keys get a 403 key_bound error. Their responses and webhook events also leave out a bot's actions field.

Create an action

Create an action with POST /v1/actions. This example turns a story search API into an action that bots can use.

Your story search, as an action
curl https://api.heyllo.co/v1/actions \
  -H "Authorization: Bearer $HEYLLO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "search_stories",
    "description": "Search the stories published on Example. Use it for any question about trips, places or authors.",
    "method": "GET",
    "url": "https://api.example.com/stories?q={{query}}&author={{params.author_id}}&limit=8",
    "inputs": [{ "name": "query", "type": "string", "required": true, "description": "Keywords to search for" }],
    "headers": { "Authorization": "Bearer sk_live_..." },
    "fields": ["results.title", "results.url", "results.summary"],
    "citations": { "items": "results", "title": "title", "url": "url" }
  }'
# -> { "id": "act_...", "object": "action", "headers": { "Authorization": "********" }, "secret": "whsec_...", ... }
FieldDescription
nameThe tool name the agent sees. Use up to 48 letters, digits, _ and -. It must be unique in your organisation.
descriptionWhen to use the action and what it returns, in up to 1,000 characters. The agent decides when to call the action from this text alone, so be specific.
method, urlThe HTTP method: GET, POST, PUT, PATCH or DELETE. The default is GET, or POST if you send a body. The URL must use https. You can put placeholders in the path and query, but not in the host.
inputsUp to 20 values the agent fills in. Each one has a name, a type (string, number, integer or boolean), a description, required and an optional enum. If a required input is missing, the agent asks the visitor for it.
headersHeaders sent with every call, usually your credentials. Values are encrypted and never returned. Responses show ******** instead.
bodyThe JSON body for POST, PUT and PATCH, up to 16 KB.
fieldsThe response fields the agent may read, written as dot paths. Paths also reach into lists. Leave it out to let the agent read the whole response. Use it to keep internal data away from the agent. See Choose what the agent reads.
citationsUse this when the response contains a list of items to cite. items is the path to the list, or "" if the response is the list itself. title and url are paths inside each item. The items appear as sources under the answer. See Show sources under the answer.
timeout_msHow long to wait for your API, from 500 to 30,000 milliseconds. The default is 10,000.
confirmUse it for actions that change something, such as a booking or a cancellation. The agent first tells the visitor what it will do. It calls the action only after the visitor agrees.

The response includes a secret. Heyllo signs every call to your API with it. See What your API receives.

Placeholders

Placeholders put values into your request when Heyllo calls your API. You can use them in the URL, in header values and in the body. Write them in double curly braces.

PlaceholderValueSet by
{{query}}The value of an input, by its name.The agent
{{params.author_id}}A value from the params you set when you link the action to a bot. Nested paths work.You, when linking the bot
{{workspace.external_id}}The external_id you gave the bot's workspace.Heyllo
{{workspace.id}}, {{bot.id}}The IDs of the bot's workspace and of the bot.Heyllo
{{conversation.id}}Heyllo's internal ID for the conversation, so you can tie related calls together.Heyllo
{{conversation.public_id}}The conversation's conv_... ID, as the API returns it.Heyllo
{{end_user.external_id}}The external_id of the conversation's end user: who is asking.You, when creating the conversation
{{end_user.verified}}true when the conversation has an end user you identified.Heyllo
{{context.subject_user_id}}A value from the conversation's `context`, by key.You, when creating the conversation

Only inputs come from the agent. So use params, {{workspace.external_id}}, {{end_user.external_id}} or {{context.*}} to limit what each call can reach. Then a visitor cannot talk the agent into showing another user's data.

If an action uses {{end_user.external_id}}, {{conversation.public_id}} or a {{context.*}} key that the conversation does not have, Heyllo does not call your API. The agent is told the action failed. Your API never gets a request with its scope missing.

How values are filled in:

  • In the URL, every value is percent-encoded.
  • If an optional input is left out and it is the whole value of a query parameter, that parameter is dropped.
  • In the body, a string that is exactly one placeholder becomes a value of the right type. For example, "{{limit}}" becomes 8.
  • A placeholder inside a longer string is inserted as text.

Conversation context

Some actions depend on what a conversation is about, not just on the bot. For example, a conversation opened from a member's profile should only answer about that member. Set context when you create the conversation. Your actions read it, and the agent sees it.

Shell
curl https://api.heyllo.co/v1/conversations \
  -H "Authorization: Bearer $HEYLLO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "bot": "bot_k3x9q2m7v1p8z4w6t5r0y2",
        "end_user": { "external_id": "u_102", "name": "Bola" },
        "context": { "subject_user_id": "u_381", "subject_display_name": "Amina" } }'
# -> { "id": "conv_...", "object": "conversation", "context": { "subject_user_id": "u_381", ... }, ... }
  • Up to 10 keys. Keys are 1 to 40 lowercase letters, digits and _. Values are strings of up to 256 characters.
  • The context cannot be changed after the conversation is created. Start a new conversation for a different subject.
  • Heyllo signs it with the rest of the turn, so neither the visitor nor the agent can change it.
  • Use it in actions as {{context.<key>}}, and in a bot's persona the same way.

With https://api.example.com/members/{{context.subject_user_id}}/posts?viewer={{end_user.external_id}}&q={{query}}, the call above becomes .../members/u_381/posts?viewer=u_102&q=.... Your API can then check that u_102 may see u_381's posts.

Inputs or params?

Both put values into your request. The difference is who gives the value, and when.

Input, such as `{{query}}`Param, such as `{{params.author_id}}`
Who sets itThe agent, during the conversationYou, when you link the action to a bot
WhenFresh on every callOnce. The bot then uses the same value on every call.
Where you define itIn the action's inputsIn the bot's params for this action
Can a visitor change it?Yes. The agent works it out from what the visitor says.No. Neither the visitor nor the agent can change it.
Typical useWhat the visitor is asking forWho or what the bot is limited to

For example, a visitor on Amina's bot asks about Lamu. The agent sets the query input to Lamu. The author_id param is already u_381, because you linked Amina's bot that way. Heyllo then calls https://api.example.com/stories?q=Lamu&author=u_381&limit=8.

To choose between them:

  • If the value depends on what the visitor asks, make it an input. For example, a search term, an order number or a date.
  • If the value depends on which bot is answering, make it a param. For example, the user, shop or region the bot belongs to.
  • If the value is the same for every bot, write it straight into the URL, like limit=8.
Anything that limits whose data a bot can reach must be a param, never an input. A visitor could talk the agent into changing an input. They can never change a param.

What your API receives

This is the request your API receives for the example above.

HTTP
GET /stories?q=trips%20to%20Lamu&author=u_381&limit=8 HTTP/1.1
Host: api.example.com
Authorization: Bearer sk_live_...
Accept: application/json
User-Agent: Heyllo-Actions/1.0
webhook-id: req_3f9c...
webhook-timestamp: 1798000000
webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4=

Your own headers are usually enough to check that a call comes from Heyllo. Each call is also signed with the action's secret, in the same way as a webhook. So you can verify it with the same code you use for webhooks. For GET and DELETE, the signed body is empty.

To get a new secret, call POST /actions/{id}/rotate. The previous secret also signs calls for 24 hours, so you have time to switch. See Secret rotation.

Reply with JSON within timeout_ms. Plain text also works. The agent reads up to 12,000 characters of your response, after your fields filter has been applied.

Heyllo does not follow redirects. It only calls public addresses.

If your API fails, the conversation carries on. This covers an error status, a timeout and an API that cannot be reached. The agent is told that the action failed, with the status and the start of your error body. It then tells the visitor it cannot do that right now.

The agent may show the visitor anything it reads, including your error messages. Limit fields to what visitors may see. Keep secrets out of your error messages.

Choose what the agent reads

fields lists the parts of your response the agent may read. Heyllo removes everything else before the agent sees it. Use it to keep private or internal data away from the agent.

Say your story search answers like this:

Your API's response
{
  "results": [
    {
      "title": "Three days in Lamu",
      "url": "https://example.com/s/lamu",
      "summary": "Dhow trips, old town walks and where to eat.",
      "author_email": "[email protected]",
      "internal_score": 0.92
    },
    {
      "title": "Diani on a budget",
      "url": "https://example.com/s/diani",
      "summary": "Cheap stays and the best beach days.",
      "author_email": "[email protected]",
      "internal_score": 0.87
    }
  ],
  "debug": { "query_ms": 41 }
}

With "fields": ["results.title", "results.url", "results.summary"], the agent only gets this:

What the agent reads
{
  "results": [
    { "title": "Three days in Lamu", "url": "https://example.com/s/lamu", "summary": "Dhow trips, old town walks and where to eat." },
    { "title": "Diani on a budget", "url": "https://example.com/s/diani", "summary": "Cheap stays and the best beach days." }
  ]
}
  • Each entry is a path. The dot means "inside": results.title is the title inside results.
  • results is a list, so the path applies to every item in it. The agent gets the title of each story, not only the first one.
  • The response keeps its shape. Only the parts you did not name are removed.
  • If you leave fields out, the agent reads the whole response.

In this example, the agent cannot repeat authors' emails or your ranking scores to a visitor. A shorter response also helps the agent focus.

Show sources under the answer

citations tells Heyllo where to find links in your response. They appear as sources under the agent's answer, so visitors can open what the answer is based on.

For the response above, use this:

JSON
"citations": { "items": "results", "title": "title", "url": "url" }

The answer then lists two sources: Three days in Lamu and Diani on a budget, each linking to its story.

SettingWhat it means
itemsWhere the list is. "results" means the list inside results. If your API returns the list on its own, like [ {...}, {...} ], use "".
titleWhere the link text is, inside each item. The default is title.
urlWhere the link address is, inside each item. The default is url.

title and url can be paths too. For example, "url": "links.web" reads web inside links in each item.

  • Only real links count. An item without a url that starts with http:// or https:// is skipped.
  • If an item has no title, its link address is shown as the text.
  • Each call shows at most 10 sources. Extra items are ignored.
  • Sources are read from the full response, before your fields filter trims it. So you can hide url from the agent and still show it as a source.
  • Your API must answer with JSON. Plain-text answers give no sources.

In short, fields decides what the agent reads. citations decides which links the visitor sees. If your API returns no links, leave citations out.

Test it

Test an action to see exactly what the agent would get from your API.

Shell
curl https://api.heyllo.co/v1/actions/act_.../test \
  -H "Authorization: Bearer $HEYLLO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "inputs": { "query": "Lamu" }, "bot": "bot_k3x9q2m7v1p8z4w6t5r0y2" }'
# -> { "object": "test", "ok": true, "status": 200, "duration_ms": 182,
#      "url": "https://api.example.com/stories?q=Lamu&author=u_381&limit=8",
#      "output": "{\"results\":[...]}", "citations": [...] }

The test runs the action exactly as a bot would. If you pass bot, the test uses that bot's params and workspace. You can also pass params yourself.

For actions that use the conversation's values, pass sample ones: context (as on a conversation) and end_user (external_id, optional verified, default true). {{conversation.public_id}} is conv_test in a test.

output is what the agent would read. You can run the same test from the partner portal.