How to do conversation with rasa bot using api

I am confused with all the rest API’s provided by Rasa.

I have trained my model successfully.

Now i want to do the conversation using .net code.

/conversations/<conversation_id>/messages

i am able to post payload to above Rest API but not getting bot output in response.

How do i keep getting responses of my input from API like it works with rasa shell?

To talk to the bot via REST use POST on

<base_url>/webhooks/rest/webhook

The body is a json containing sender and message

{"sender": <sender_id>, "message": <message>}

You can choose any string as the sender id.

I second that this is not well documented.

3 Likes

Hi @aniket, welcome to the community.

You can use rest channel to get response from the bot.

Also I have designed the chatbot widget for the same, it’s in jQuery but you can relate it:

Hope it helps :slight_smile:

Thanks.Its working fine

@JiteshGaikwad i am using GitHub - JiteshGaikwad/Chatbot-Widget: ChatBot widget easy to connect to RASA bot through REST channel for ui of my rasa chat bot i have used the following code in my connect.py from rasa_core.channels import SocketIOInput

from rasa_core.agent import Agent

from rasa_core.interpreter import RegexInterpreter

from rasa_core.interpreter import RasaNLUInterpreter

from rasa_core.utils import EndpointConfig

from rasa_core.policies import KerasPolicy, MemoizationPolicy

load your trained agent

interpreter = RasaNLUInterpreter(‘rasa/models/nlu/profiler/nlu’)

agent = Agent.load(‘rasa/models/dialogue’,

interpreter=interpreter, 

action_endpoint=EndpointConfig('http://localhost:5055/webhook')

#for action endpoint

)

input_channel = SocketIOInput(

# event name for messages sent from the user

user_message_evt="user_uttered",

# event name for messages sent from the bot

bot_message_evt="bot_uttered",

# socket.io namespace to use for the messages

namespace=None

)

set serve_forever=True if you want to keep the server running

s = agent.handle_channels([input_channel], 5500, serve_forever=True) and i have use this in my credentials.yml rest:

socketio:

user_message_evt: user_uttered

bot_message_evt: bot_uttered

session_persistence: true

rasa:

url: http://localhost:5055/webhook

do i have to add something more in my code like in rasa code to send data or it is sufficient.

thank you.

hey @vjaiswal693, first thing first the widget which I have designed is based on rest not socket.io you don’t need to use socket.io for that, it’s pretty simple just follow the below steps and you will get it up & running:

  • In your credentials.yml , just add the below lines:
rest:
  # you don't need to provide anything here - this channel doesn't
  # require any credentials
  • start you rasa server using the below command:
rasa run -m models --enable-api --cors "*" --debug

and that’s it you can test you bot by running the index.html file in your browser

let me know if this helps you. :slight_smile:

Reference: https://rasa.com/docs/rasa/user-guide/connectors/your-own-website/#restinput

Thank you for helping me. @JiteshGaikwad is there any widget in which i can use socket.io.if yes kindly brief about the steps how to connect it. if i use this GitHub - JiteshGaikwad/Rasa_CustomUI-v_2.0: Custom UI for Rasa thank you

Hi @vjaiswal693 you can use Rasa Webchat since it uses Socket.IO

https://github.com/botfront/rasa-webchat.git

@JiteshGaikwad thank you for the help.

Hi @JiteshGaikwad, using you solution together with the rasa x is causing malfunction in the events.db and rasa x is stopping from store the conversations

Hi @JiteshGaikwad

I changed the endpoint to inject intent in to the conversation and now the rasa x is not having problems any more using your solution.

thanks!

Hello, I have deployed the rasa x in AWS server following this tutorial. Now, I am trying to connect to the rasa x using the Chatbot Widget but, it’s throwing an error

. After surfing the web, I found this issue which was similar to mine. I tried it but, It’s also throwing the same error. It’s working fine Rasa Webchat UI. I don’t know where the error lies. Any help would be appreciated @JiteshGaikwad @Saul.

Thanks

I still don’t know solution for this issue but, It got fixed after updating the rasa x version

Thanks

Jitesh, your Widget is awesome, however I am having issues when deploying:

index.html is served by IIS on port 8080 rasa server is running on port 5005 rasa actions is running on port 5050

when I start the conversation I get blocked by CORS, because of the different ports: Front-End and Rasa backends.

hi @JiteshGaikwad after i run the command and i open the widget ,when i type any message into the chatbot it says i am facing some issues please try again later, is there anything i am doing wrong?, thanks in advance

same here

Hey! I’m facing the same problem, have you found a solution?

Hey! I’m facing the same problem, have you found a solution?