How to do conversation with rasa bot using api - Rasa Open Source - Rasa Community Forum

👋 Introducing the Rasa Playground

How to do conversation with rasa bot using api

You have selected 0 posts.

9.4k views 9 links 10 users

post by aniket on Jan 3, 2020

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?

post by IgNoRaNt23 on Jan 3, 2020

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.

post by JiteshGaikwad on Jan 3, 2020

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

post by vjaiswal693 on Jan 27, 2020

@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)

also 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

post by JiteshGaikwad on Jan 27, 2020

hey @vjaiswal693, 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:

rest:
  # you don't need to provide anything here - this channel doesn't
  # require any credentials
rasa run -m models --enable-api --cors "*" --debug

post by Saul on Mar 19, 2020

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

post by n-k-chilagani on May 5, 2020

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.

post by n-k-chilagani on May 14, 2020

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

post by iveen on Sep 16, 2020

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.

post by vikkooo013 on Oct 13, 2020

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

post by sid321axn on Aug 19, 2021

same here

post by Mery404 on Mar 26, 2022

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

post by Mery404 on Mar 26, 2022

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