How does the Custom Connector work?

Hi, I am building my chatbot with Rasa and everything is working fine, but I have a few questions about Rasa’s channels. First of all, I have never done anything in web developing and on top of it, I am not a native speaker (Ihr könnt die Kommentare also gerne auch auf deutsch verfassen). I followed the rasa-Docs and deployed my bot on a custom channel. For the code, I used the file channel.py I found on the docs (rasa/channel.py at master · RasaHQ/rasa · GitHub , class RestInput). I know that the messages are send in JSON-Format and I also know that the http-protocol is used. Http sends data with POST or GET. Feel free to correct me If something is wrong.

  1. The channel seems to be the connection between my frontend-UI (I used Rasa Chatroom, GitHub - scalableminds/chatroom: React-based Chatroom Component for Rasa Stack) where the user types the messages and Rasa Core. How does it direct the messages?

  2. And what is a http Input channel? Is it a channel where messages are sent via http Post or Get?

  3. What purpose does the blueprint of this channel have? It seems to use Post so I assume there is some http somewhere involved?

  4. Somehow a WebHook informs the Rasa Server if messages are Incoming? Is this right? How does it do this?

  5. I also found the term REST Api many times. It seems to be some kind of interface? But what exacty does it do? Why do I need it?

Of course I read about all these components (Rest, Webhook, …) on the Internet, but I just can’t get the connection between all of these and how rasa uses them to send messages between the Chatroom UI and the Rasa Core. This is the step I don’t get.

Chatroom UI – ?? (What happens here) ?? – Rasa Core

You can alo provide links to tutorials If you know some good tutorials.

Maybe you want to take a look at the first lesson of Designing RESTful APIs | Udacity. They talk about the whats and whys of APIs. Might be good to fill in some gaps.

Whenever the user enters a message in the Chatroom UI, the webhook endpoint of the rest input channel is called (POST /webhooks/rest/webhook). The rest input channel gets the message and forwards it to Rasa Core to get it processed (it calls the method handle_message on the agent to process the message). The result is send back to the Chatroom UI as a response of the original request. The blueprint defines the API, e.g. the endpoint POST /webhooks/rest/webhook, of the rest input channel.

Hope that clarifies some of you questions. Let me know if you have more questions.

1 Like

Thank you @Tanja you did really help me.

So my first question is: Does every channel have it’s own webhook? For example if use another channel (not REST), let’s call it channel42, this channel would have it’s own webhook and the endpoint webhooks/channel42/webhook ?

And my seconde question, just to clarify, the response I get from Rasa as result is also send through this channel (like the request) ?

Question 1: Yes. You can read more about it here Custom Connectors. If you are looking for more examples, check out our built-in channels (rasa/rasa/core/channels at master · RasaHQ/rasa · GitHub).

Question 2: The response (next message of the bot) is send back as a response to the incoming request. No new request is made. Maybe take a look at https://www.codecademy.com/articles/http-requests to clarify how a http request works.

How should you configure your development project for and how do you ‘deploy’ a custom connector? For instance I installed Rasa onto a linux VM by setting up a venv environment and installing Rasa-X with the pip install rasa-x --extra-index-url https://pypi.rasa.com/simple command. I am developing a custom Mattermost connector that takes text via a REST call forwards it to the NLU and then outputs to the Mattermost conversation. I did this because Mattermost will not trigger an outgoing webhook from an incoming webhook. They’re trying to prevent loops. So I’ve created (edited the Mattermost connector code) into my custom connector called whimm. I’m using pycharm for do this. Should I create a python package with it’s own __init.py__ in a folder like so:

image

or should I just add the naked whimm.py module at the root level of my rasa init-ed folder beside the *.yml files? Also, should I add the following:

channel.whimm:
   ...

section to my credentials.yml file? Or should it just be a whimm: section?

1 Like