Creating an Android Studio application with Rasa

Hi guys. I am trying to make an android which connects to my Rasa bot. I have tried reading the documentation of the REST inputs. Does anyone have an ideas or sample projects that I see to understand how to work on this?

Your help will be appreciated.

At the end of the day, Rasa (and RasaX) is a server-side application, meaning any client front-ends should be sending messages to a specific endpoint and processing their returned messages to display to the user.

If you’re just starting out, your messages should be a JSON POST request to a server running RASA at the following URL:

<your host url here>/webhooks/rest/webhook
(If you run rasa run, your host URL will be displayed in the console.)

With the body being\

{
      "sender" : <some string here>,
      "message" : <your input string here>
}

Hi @zaidalvi In local host as mentioned the endpoint is http://localhost:/webhooks/rest/webhook

But things change a lot when you deploy on GCP, Before you use it you have to get an bearer access token by following method:

Your endpoint is :
 http://<your_ip>/api/auth

with Json Body as POST request: 

{
	"username": "your usename, usually its me",
	"password": "your password"
}

It will return something like this:

{
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1c2VybmFtZSI6Im1lIiwiZXhwIjoxNTg2MTE1MDMxLCJ1c2VyIjp7InVzZXJuYW1lIjoibWUiLCJyb2xlcyI6WyJhZG1pbiJdLCJkYXRhIjpudWxsLCJhcGlfdG9rZW4iOiI2MjkzYWU5MDcxMmIyYjEwNzJjNTBmNmFkNTE2YjJlMmUzNTc1ZjE4In0sInNjb3BlcyI6WyJhY3R
---really long access token
pb25QcmVkaWN0aW9uOmNyZWF0ZSIsImFjdGlvblByZWRpY3Rpb246Z2V0IiwiYWN0aW9uczpjcmVhdGUiLCJhY3Rpb25zOmRlbGV0ZSIsImFjdGlvbnM6Z2V0IiwiYWN0aW9uczp1cGRhdGUiLCJhbGxFd
9tWCLbQtPGe8jDfxExLwLdcxvkF7s5DQail8gtt_60mLPAlNRKbWeR3zpJ8RFf_KOAqxXDcg9rrZO-g_hXRng1ePOFOyrOFlQLMp0IN4YwRgHhdbqIlypdw"
}

authentication curl request will be like this:

curl --location --request POST 'http://your_ip/api/auth' \
--header 'Content-Type: application/json' \
--data-raw '{
	"username": "your username",
	"password": "your password"
}'

Now use this bearer token as authentication to chat endpoint:

The endpoints to chat is

http://<your_ip>/api/chat

with body in Json as POST request:

{
      "message" : <your input string here>
}

with bearer token.

Your curl request will be like this:

curl --location --request POST 'http://your ip/api/chat' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1c2VybmFtZSI6Im1lIiwiZXhwIjoxNTg2MTE1MDMxLCJ1c2VyIjp7InVzZXJuYW1lIjoibWUiLCJyb2xlcyI6WyJhZG1pbiJdLCJkYXRhIjpudWxsLCJhcGlfdG9rZW4iOiI2MjkzYWU5MDcxMmIyYjEwNzJjNTBmNmFkNTE2YjJlMmUzNTc1ZjE4In0sInNjb3BlcyI6WyJhY3R
---really long access token
pb25QcmVkaWN0aW9uOmNyZWF0ZSIsImFjdGlvblByZWRpY3Rpb246Z2V0IiwiYWN0aW9uczpjcmVhdGUiLCJhY3Rpb25zOmRlbGV0ZSIsImFjdGlvbnM6Z2V0IiwiYWN0aW9uczp1cGRhdGUiLCJhbGxFd
9tWCLbQtPGe8jDfxExLwLdcxvkF7s5DQail8gtt_60mLPAlNRKbWeR3zpJ8RFf_KOAqxXDcg9rrZO-g_hXRng1ePOFOyrOFlQLMp0IN4YwRgHhdbqIlypdw' \
--header 'Content-Type: application/json' \
--data-raw '{
	"message": "hi"
}'

Refer to this for more documentation HTTP API.

1 Like

Hi there, I tried to pull up an easy way for this and created a tutorial for the same I hope this helps every Android and rasa developer “Rasa Chatbot + Android Covid app Tutorial: Part 1” by Dishant gandhi https://link.medium.com/7jH3pLzbvab I hope you all like it!

1 Like