Finding an agent

The bot calls search with the person's question. The call returns up to two matching agents, best first, and the bot decides what to do with them.

The response
{ "success": true,
  "searchResults": [ { "agentName": "hr_policy", "agentTitle": "HR policy" } ] }

What to do with the results

Search returns only the matches. What the bot does with them is the bot's own search behavior, not an account setting. Choose one approach and keep to it.

ApproachWhat the bot does
Run the best matchRun the first result.
Run only a lone matchRun the result when there is exactly one. Otherwise show the list.
Show the matchesShow the list and let the person choose.
Keep the conversation's agent
for a follow-up
Keep using the agent already in the conversation.

A bot that always runs the best match feels like a conversation rather than a search page, at the cost of never offering a choice when the match is uncertain. Either works, as long as the bot is consistent.

Letting the person choose

When the bot shows the results, show them as buttons: one button per agent, labeled with the agent title. Search returns at most two, so the buttons fit in a single row.

Letting the person choose works only when the bot does three things.

  • Carry the question, not only the choice. Running an agent needs the question, and a click only says which agent. 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 is also clearer.
  • 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.

When nothing matches

An empty result means no agent covers that question. Tell the person so. No directory of agents 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. Treat a shorter one as a greeting rather than showing an error.