airy icon indicating copy to clipboard operation
airy copied to clipboard

Rasa Connector

Open M-Shorouk opened this issue 2 years ago • 11 comments

[In progress]

M-Shorouk avatar Jul 08 '22 08:07 M-Shorouk

(Draft Ticket)

Is your feature request related to a problem? Please describe.

As an Airy user, I want to be able to connect a Rasa chatbot to the running Airy instance.

Describe the solution you'd like

Drawing from the dialougeflow connector built in the Airy Cloud repo by @juan-sebastian, the Rasa connector will be built similarly.

Broadly there are five steps in the process of handling a single message:

  1. Ingest a message from a Kafka stream
  2. Enrich the message (i.e with language detection/sentiment/context)
  3. Send the message with context to Rasa (via Webhook? Using the custom connector built by @chrismatix here https://github.com/airyhq/rasa-x-demo/blob/main/channels/airy.py using the template here https://rasa.com/docs/rasa/connectors/custom-connectors/
  4. Get the response and confidence levels from the Rasa server
  5. Either respond to the user or suggest (based on confidence levels)
  6. Write back the outcome to the Kafka stream

Additional context

  • General (future) questions to consider:
    • What is the desired behavior if both Dialogueflow & Rasa?

armanjindal avatar Jul 27 '22 08:07 armanjindal

As an Airy user, I want to be able to connect a Rasa chatbot to the running Airy instance.

@M-Shorouk could you provide clarification as to what the goal of the airy user would be?

chrismatix avatar Jul 27 '22 08:07 chrismatix

@chrismatix Airy user's goal is to

  1. Install the component
  2. Configure connector
  3. Rasa connector is connected to Airy.
  4. Ability to update the internal variables, if exist. example: in dialogflow > confidence level

M-Shorouk avatar Jul 27 '22 08:07 M-Shorouk

@M-Shorouk thank you, but I meant more in regards to what the user's goal of installing the Rasa connector is: I.e. what is the Rasa connector supposed to do?

The draft by @armanjindal implies that the connector should either reply using the bot's response or suggest a reply. Is that what is asked?

chrismatix avatar Jul 27 '22 12:07 chrismatix

What i am aware of is that Rasa and Dialogflow have the same purpose; ingesting messages from streams and enriching those messages by providing reply within the confidence level or reply suggestion.

For Rasa, am also aware that the connector work on 1 page at a time; 1 facebook page, but Dialogflow works with many channels..... Right?

Your question is about what the the user goal from setting such connectors (What Rasa connector supposed to do?):

  1. Ingest messages from streams to these connectors.
  2. Configure the confidence level and reply suggestion level.
  3. View these suggestion replies on Inbox as well as the automatic reply within the confidence level.

@steffh do you wanna add something?

M-Shorouk avatar Jul 27 '22 13:07 M-Shorouk

Updated scoping based on research and discussion above.

The Alpha version of the Rasa Connector will:

  1. Forward all messages received by Airy to Rasa (regardless of confidence).

These messages will be sent to Rasa over the REST API channel where Airy is treated as a custom front-end.

Since the commutation back to Airy is longer via the Airy API (as the connector gets responses directly from the Rasa REST API), the connector does not require the custom Airy channel connector.

  1. Processed the Rasa response to a stream-supported format.
  2. Write the stream-supported format back to the Kafka stream.

Installation Process/Docs Outline:

  • Rasa: In the credentials.yaml add "rest: " on a new line to open the webhook to access the REST API. Restart your Rasa server with the command:

rasa run --enable-api --cors="*"

  • Airy:
    From the control center UI, add your webhook: http://<host>:<port>/webhooks/rest/webhook

If you are in a production environment, it is highly recommended you secure the API with token-based authentication.

This information will be written into the rasa-connector-configmap.

Tests for alpha connectors:

  • [x] API calls work when secured with the token.
  • [x] Multimedia support:
    • [x] Text
    • [x] Images
    • [ ] Audio
    • [ ] Buttons
  • [ ] Supports Custom Action server functions as expected.
  • [ ] Supports channel specific response variations

Areas of Discussion:

  • It is unspecified if the REST API will support External Events. As in the rocket chat version, to support this, they used Callbacks and provide two modes to install their connector (one with REST the other with Callbacks). I will investigate this after a working alpha.

Beta version of the Rasa connector:

  • Build a suggestion functionality.
  • Build a human-handoff
  • Enrich message function
  • Create a message "enrichment" function (i.e sentiment/language).

This will require more configuration on the Rasa side and integration with their existing functionality to support Fallback and Human Handoff. Also, a discussion on how the tracker store/state is maintained in the Rasa trackers when human intervention occurs. (i.e, should we write human intervention to Rasa tracker, or will the source of truth be Airy Kafka stream?).


(Future) RasaX Connector: This makes sense to be paid in the cloud to reflect Rasa's decision to no longer support the community edition. It will only make sense to build once the product deems it a priority and the suggestion/human-handoff is already built.

(Future) Rasa connector ideas:

  • UI for slots & forms (loading from database / other connectors + allowing operators to edit slots/data).
  • Enriching Rasa models (making them context-aware) with Kafka stream data.

armanjindal avatar Aug 01 '22 21:08 armanjindal

@armanjindal thank you for the detailed breakdown. This looks like a sensible implementation, just one question: According to @M-Shorouk users will want to use this like dialogflow, however the REST API that you linked only returns a single response as if it were a "normal" chatbot.

Perhaps it's more reasonable then that the Rasa connector relays messages from the rasa bot back to the sender rather than (like dialogflow) suggest replies. What do you two think?

chrismatix avatar Aug 02 '22 11:08 chrismatix

@chrismatix i would also agree with @armanjindal on Alpha version of Rasa connector for now. Hence its open-source, we can postpone building more features as suggested in the Beta version.

@steffh what do you think?

M-Shorouk avatar Aug 02 '22 13:08 M-Shorouk

Another question @armanjindal

Write the stream-supported format back to the Kafka stream.

Do we want the rasa agent to be able to actually reply to a conversation or will we only store the intended reply as metadata? I guess if it's the later then that detail is still tbd.

chrismatix avatar Aug 02 '22 14:08 chrismatix

Perhaps it's more reasonable then that the Rasa connector relays messages from the rasa bot back to the sender rather than (like dialogflow) suggest replies. What do you two think?

@chrismatix - Yes, I think we can reply directly to the user in the alpha.

Regarding suggestions, the endpoint for custom UI is the RASA API /models/parse. This returns the top three intents, for which we can generate potential responses using /model/predict endpoint.

Regarding where the data will be stored, I plan to look at the Airy Suggest Replies API and try to implement that directly in the connector.

armanjindal avatar Aug 02 '22 14:08 armanjindal

Final scope based on further research and discussion.

The Rasa Connector will:

  1. Forward all messages (from contacts) received by Airy to Rasa (regardless of confidence) via the Rasa REST API
  2. Processed the Rasa response to a stream-supported format.
  3. Write the stream-supported format back to the Kafka stream.

Installation Process/Docs Outline:

  • Rasa: In the credentials.yaml add "rest: " on a new line to open the webhook to access the REST API. Restart your Rasa server with the command:

rasa run --enable-api --cors="*"

  • Airy:
    From the control center UI, add your webhook: http://<host>:<port>/webhooks/rest/webhook

Authentication is not required for the REST endpoint

The webhook URL will be written into the rasa-connector-configmap from the control center UI.


The next feature for the Rasa Connector will be to support a Human Handoff handoff feature. This will be developed only once this connector is finished.

armanjindal avatar Aug 10 '22 12:08 armanjindal