Skip to main content

Suggested replies with Rasa


This guide assumes that you completed the Rasa Chat assistant guide, which means you have:

  • a running Airy Core instance
  • a Rasa setup connected to that instance with a custom channel (see the demo repository)

How it works#

see suggested replies in the Airy inbox when receiving a contact greeting

Chatbots can serve a wide variety of use cases like answering frequently asked questions or booking flows. Customer support however often requires a human agent to serve user questions with a high degree of quality. With Airy Core you can get the best of both worlds by using NLP frameworks like Rasa to suggest a set of replies to the agent. This way agents can handle the vast majority of use cases with the click of a button (see screenshot).

Configuring Rasa#

Step 1: Add a custom response type#

The easiest way to instruct Rasa to suggest replies for a given user messages is by adding them as a custom response type. To do this we add the following block to the responses section in our domain.yaml:

- custom:
text: "Hey, what's up?"
text: "Hi, what can I help you with?"

Step 2: Update the user stories#

Now we can use this new response type in our stories.yaml to let the bot know when to suggest replies:

- story: happy path
- intent: greet
- action: utter_suggest_greet
- intent: mood_great
- action: utter_happy

Step 3: Extend the Airy connector#

Now we need to update our custom Rasa connector for Airy Core to this response type. For this we extend the send_response method in the Airy connector so that it calls the suggest replies API whenever it encounters a custom response payload:

async def send_response(self, recipient_id: Text, message: Dict[Text, Any]) -> None:
headers = {
"Authorization": self.system_token
if message.get("custom"):
body = {
"message_id": self.last_message_id,
"suggestions": message.get("custom")
}"{}/messages.suggestReplies".format(self.api_host), headers=headers, json=body)
elif message.get("text"):
body = {
"conversation_id": recipient_id,
"message": {
"text": message.get("text")
}"{}/messages.send".format(self.api_host), headers=headers, json=body)

Step 4: Retrain and restart#

Now we need to stop the server and retrain the model:

rasa train

Finally, we start the Rasa server, open the Airy Inbox at (http://airy.core for local deployments), where we should see the suggested replies whenever a contact greets us (see gif above).

Last updated on