Can i send a message to user using api? (Bot to say something using api)

I didn’t find anything to send a message to conversation(bot to say this message) using api.

I thought i could set a slot using conversations/{conversation_id}/tracker/events and then use /conversations/<conversation_id>/trigger_intent that would trigger custom action and utter the slot.

But this doesn’t sound good to me. Is there a better way to do this?

If you just want to talk to the bot via API, send a POST request to

http://[server url]/webhooks/rest/webhook

You can run the server on your localhost by running rasa run --cors "*", in which case replace server url above with localhost:5005.

The POST body should look like this:

	"sender": "Sender",
	"message": "Hello there."

Hi @ActuallyAcey Thanks for your response.

I already have rasa x and custom action servers running live. That way i just get bot to respond to message that i send to it. It’s same as connecting to channel.

My goal:

  1. Be able to receive all users messages to 3rd server. (Solved/Done)
  2. Be able to send message to user from 3rd server. (Open)

Currently i have action that pauses the bot(and takes the conversationID) and after that i get this users messages to 3rd server. All i need now is to be able to send message to the user/conversation “as the bot”.

That POST would add message to the tracker but i’m not sure if the sender can be bot and since it just log’s the message the bot would not actually utter the message?

1 Like

Hey were you able to find any solution to this?

Is that documented somewhere? I could not find it in the Server Endpoints (1.0.0)… I’d be thankful for a link

Hi @PhilipAllStar

If you want to connect to your Rasa chatbot via an API, then do these

  • Run rasa with the following command: rasa run --enable-api --cors "*"

  • Go to POSTMAN/ Thunderclient to check if the server is responding to the API call or not

Use the URL http://[server url]/webhooks/rest/webhook where server URL can be localhost:5005 if you are running on local

Select POST and add the following in body as JSON

	"sender": "Sender",
	"message": "Hello there."

The correct way to send a message from your bot to the user is by appending an event to your tracker using this endpoint: http://localhost:5005/conversations/{conversation_id}/tracker/events

Its essential to include these query parameters:
output_channel='telegram' (try ‘latest’ , didn’t work for me)

(api reference)

I’ve built a web-app replacing some of Rasa-X features, it has the ability to send message from bot to user. it is open source and works with Rasa 3.x: GitHub - nesterapp/rasa-admin: An open-source alternative for Rasa-X