Connectivity between Flutter and Rasa using Rest API

I want to know how to Implement connectivity between Flutter and RASA using Rest API Json query

1 Like

hi @Dilshan !

What you probably want is one of the rest channels

2 Likes

Like @amn41 said you probably want to use the REST API function of the Rasa server. I supposed you could utilize the socketio function, but I think using REST from Flutter would be easier to setup.

Basically your app would send the user’s input to that rest endpoint and wait for the rasa sever to respond. you would need to parse the json response and pull the response text and display it in your app.

If you want to see how some of that parsing is done, there’s a really good Web chat ui I’ve played around with and uses HTML / CSS / jQuery. You may not be a fan of jQuery, but it is pretty easy to see how to deal with different response formats from straight text, to panels of data.

It is pretty much plug-n-play locally so you spin up your rasa server and action server (and anything else you need like Duckling, etc) open index.html in a browser and you’re good to go.

That repo is here:

1 Like

please show a connectivity example between flutter and rasa

hey @Meet, you can call the Rasa’s REST api within flutter and render the response accordingly.

You can use REST channel for interacting with the bot from flutter

I am attaching the sample code for calling REST api in flutter.

Future<http.Response> getBotResponse(String senderId, String message) {
  return http.post(
    'http://your-bot-ip:5005/webhooks/rest/webhook',
    headers: <String, String>{
      'Content-Type': 'application/json; charset=UTF-8',
    },
    body: jsonEncode(<String, String>{
      'sender': senderId,
      'message': message
    }),
  );
}

You can can get the complete example of the calling POST HTTP request in flutter here.

Thanks, Jitesh

2 Likes