DEV Community

Cover image for RASA - REST API
Petr Janik
Petr Janik

Posted on

RASA - REST API

So far, we have been interacting with the chatbot in the terminal.

In this chapter, we will look at how we can send messages to the chatbot via REST API.

Add the following to the credentials.yml. If you created your project using rasa init, it should be already there and you don't need to do anything.

rest:
  # you don't need to provide anything here - this channel doesn't
  # require any credentials
Enter fullscreen mode Exit fullscreen mode

To send a request, I will use Postman's desktop app. You can now run Postman also in the browser without installing the app. Or you can use https://hoppscotch.io/. You can of course use terminal interface like curl as well.

Let's start the server by running rasa run.
The server is now running on http://localhost:5005/.

Server is running

Now, send a POST request to http://localhost:5005/webhooks/rest/webhook in the following format:

{
  "sender": "test_user",
  "message": "Hi there!",
}
Enter fullscreen mode Exit fullscreen mode

The response will be a JSON body of chatbot responses, for example:

[
    {
        "recipient_id": "test_user",
        "text": "Hey! How are you?"
    }
]
Enter fullscreen mode Exit fullscreen mode

Here's how it looks in Postman:

You can learn more about Rasa's REST API in the documentation.

In the next chapter, we will look at Rasa X, a tool for Conversation-Driven Development.

Repository for this tutorial:

You can checkout the state of the repository at the end of this tutorial by running:

git clone --branch 07-rest-api git@github.com:petr7555/rasa-dev-tutorial.git
Enter fullscreen mode Exit fullscreen mode

Oldest comments (3)

Collapse
 
otmarjr profile image
otmarjr

Hello Petr!

Very good and clear explanations. I'm new to Rasa, but so far, your tutorials seem to be better than the official docs!

I'm sttruggling to find directions on how to set up a Google Hangouts chatbot powered by Rasa, specially because Rasa Docs give no direction on how to reach Rasa server from Hangouts API's side. Do you have any plans on creating such tutorial or give me some directions?

Collapse
 
petr7555 profile image
Petr Janik • Edited

Hi!

I am so glad you find my articles helphful.
I will create an article for Google Hangouts integration shortly.
I will let you know once it is finished.

Collapse
 
petr7555 profile image
Petr Janik • Edited

Hi @otmarjr ,

I would like to let you know that I have written an article about Rasa integration with Google Hangouts.