Users can communicate to RapidPro chatbots in IoGT v2. If you are a content creator on an IoGT site, the technical setup on the IoGT server should have been done, and you can set up a chatbot channel. For completeness, the technical setup is outlined at the bottom, but it should not concern content creators.
- Find the Authorization Header Value for the chatbot on your site by navigating in the Admin Panel to Chatbot > Chatbot Channels. It will be displayed at the top.
- Log in to your workspace on your RapidPro Server. Click Settings > Add Channel
- Select "External Api"
- Fill in the following form fields
- URN Type: External identifier
- Address: Enter a name identifying your RapidPro server, e.g. my_rapidpro_server
- Method: HTTP POST
- Encoding: Default Encoding (TODO: Confirm this)
- Content type: JSON - application/json
- Max length:
6400
(on older RapidPro installations the upper allowed limit might be only640
). Note: Messages longer than this size will be split up into multiple parts, and on the IoGT side we have to stitch them back together, which can cause spaces between words to be lost. Thus, the larger this value, the better, so we can avoid messages getting split as much as possible. - Authorization Header Value: Enter the Authorization Header Value from the IoGT Admin Panel > Chatbot > Chatbot Channels mentioned earlier. (Make sure to include the word
Basic
that is displayed, not only the code.) - Send URL: This should be
https://[URL of the IoGT site]/messaging/api/rapidpro-webhook/
where[URL of the IoGT site]
is the URL of your IoGT site, e.g.rw.goodinternet.org
. - Request Body:
{"id":{{id}}, "text":{{text}}, "to":{{to}}, "to_no_plus":{{to_no_plus}}, "from":{{from}}, "from_no_plus":{{from_no_plus}}, "channel":{{channel}}, "quick_replies":{{quick_replies}}}
(TODO: Check whether we can omit theto_no_plus
andfrom_no_plus
) - MT Response check:
ok
- Click Submit
- You will land on a page External API Configuration
- Copy the Received URL that is displayed on the page. This URL should look roughly like this:
https://[your RapidPro server]/c/ex/some-uuid-here-7afd839d7123-a95d/receive
- Go back to the IoGT Admin Panel > Chatbot > Chatbot. Create a new channel.
- DISPLAY NAME: This is the name that users will see when interacting with the bot.
- REQUEST URL: Enter the Received URL from step 7 here
As part of an article's content, you can now add a Chatbut button. It has the following form fields:
- Subject: The title identifiying the conversation with the chatbot in the user's inbox.
- Button text: The text to be displayed on the button
- Trigger string: The initial message that will be sent to the chatbot, starting the conversation
- Channel: Select the channel that you just created.
Upon clicking the button, the user will be directed to a conversation view with the chatbot.
The inbox view can be accessed via the URL https://[URL of the IoGT site]/messaging/inbox/
. To allow users to resume conversations later, you can e.g. create a flat menu entry (Admin Panel > Settings > Flat Menus) linking to this inbox view, or to an article explaining about the chatbot that also has a link to the inbox.
In order to communicate with the IoGT website, RapidPro needs an IoGT user account as which it can authenticate. This user needs to be set up on the IoGT side. Once that is done, you can set up a channel on your RapidPro server, and add this channel to the IoGT site so you can start communicating with it.
- Run the command
python manage.py sync_rapidpro_bot_user
in django container (to go inside django container runmake ssh
) - Optional: Run the command
python manage.py get_rapidpro_authentication_header_value
in django container to get the Authorization Header Value for RapidPro server. (This value should also be displayed in the admin panel.)