How to make use this custom action on rasa webchat interface

import requests

sender=input(“what is your name”)

bot_message=“”

while bot_message != “Bye”: message=input(“what is your message”)

print('sending message now')

r=requests.post("http://localhost:5002/webhooks/rest/webhook",json={'sender': sender, 'message':message})

print('Bot Say',end='')

for i in r.json():
    bot_message=i['text']
    print(f"{i['text']}")

Hi, To use this custom action with the Rasa Webchat interface, you can follow these steps:

Set up Rasa:

Install Rasa on your local machine or server. Create a new Rasa project or use an existing one. Train your Rasa model:

Define your NLU data in the data/nlu.md file. Define your dialogue flow in the data/stories.md file. Create a domain file domain.yml that includes your intents, actions, and templates. Train your model using the rasa train command. Create a custom action:

Create a new Python file (e.g., actions.py) in your Rasa project directory. Import the necessary libraries (requests in this case). Write your custom action logic. In this example, the logic prompts the user for their name, allows the user to enter a message until they say “Bye”, and sends the user’s message to the Rasa server using a POST request. Make sure to include the sender and message fields in the JSON payload when making the POST request. The Rasa server will respond with a JSON object containing the bot’s response, which you can extract and print. Run the Rasa server:

Start the Rasa server using the rasa run command. Integrate with Rasa Webchat:

Install the Rasa Webchat package by following the instructions in their documentation. Add the Webchat widget to your website or interface. Configure the Webchat widget to connect to your Rasa server (usually via a WebSocket URL, e.g., ws://localhost:5005/websocket). When the user interacts with the Webchat widget, it will send the user’s messages to the Rasa server and display the bot’s responses. Ensure that the Rasa server is running and accessible to the Webchat interface. You should be able to communicate with the bot through the interface, and the custom action logic you implemented will be executed when triggered. I hope this information you like it.