Finding an agent
The bot calls search with the person’s question. The call returns up to three agents, and two values that say what to do with them.
{ "success": true,
"searchResults": [ { "agentName": "hr_policy", "agentTitle": "HR policy" } ],
"searchBehavior": "executeTopMatch",
"followupBehavior": "executePrevious" }What to do with the results
searchBehavior applies to a new question. followupBehavior applies to a question asked inside a conversation that already exists. Both come from the account’s search settings.
| Value | What the bot does |
|---|---|
executeTopMatch | Run the first result. |
executeOnlyMatch | Run the result when there is exactly one. Otherwise show the list. |
showResults | Show the list and let the person choose. |
executePreviousonly in followupBehavior | Keep using the agent already in the conversation. |
Both values are guidance, not a rule the bot must follow. They carry the account’s preference, and a bot may take its own line. A bot that always runs the top match, for example, feels more like a conversation and less like a search page. The cost is that the person is never offered a choice when the match is uncertain. Either suits, as long as the bot stays consistent.
Letting the person choose
When the behaviour says to show the results, show them as buttons: one button per agent, labelled with the agent title. Search returns at most three, so the buttons fit in a single row.
Four things make a picker work properly.
- Carry the question, not only the choice. Running an agent needs the question, and a click only says which agent. It works well to put a short identifier in the button and keep the question in your own store. A chat application limits how much a button can carry, and a question can be longer than that.
- Replace the message once somebody has chosen. Otherwise the buttons stay live, and a second click starts a second conversation on the same question. Showing which agent was chosen reads better.
- Accept the click only from the person who asked. In a channel anybody can click. A click from somebody else would run that question under their account and put it in their history.
- Let the behaviour decide whether to show a picker at all. A rule of your own is likely to surprise people who also use the GUI.
When nothing matches
An empty result means no agent covers that question, and it helps to tell the person so. There is no directory of agents for end users, and none is needed: people ask, and the answer tells them whether an agent exists. See How matching behaves.
Short questions
A question must be at least eight characters. A shorter one is best treated as a greeting, rather than shown as an error.

