Hey @nik202
I’ve fixed it.
Steps Done:
1> Created a custom actions.py with action_hello_world programm. class ActionHelloWorld(Action):
def name(self):
return "action_hello_world"
def run(self, dispatcher, tracker, domain):
dispatcher.utter_message("Hello world !") # send the message back to the user
return []
2> Created a script.js with below…
customActionTrigger();
3> Created a constant.js file with below lables and values.
const action_name = "action_hello_world";
const rasa_server_url = "http://localhost:5005/webhooks/rest/webhook";
const sender_id = uuidv4();
4> Created a chat.js file with the below function.
function customActionTrigger() {
$.ajax({
url: "http://localhost:5055/webhook/",
type: "POST",
contentType: "application/json",
data: JSON.stringify({
next_action: action_name,
tracker: {
sender_id,
},
}),
success(botResponse, status) {
console.log("Response from Rasa: ", botResponse, "\nStatus: ", status);
if (Object.hasOwnProperty.call(botResponse, "responses")) {
setBotResponse(botResponse.responses);
}
$("#userInput").prop("disabled", false);
},
error(xhr, textStatus) {
// if there is no response from rasa server
setBotResponse("");
console.log("Error from bot end: ", textStatus);
$("#userInput").prop("disabled", false);
},
});
}
5> register the action in domain.yml file actions:
- action_hello_world
6> created a story in stories.yml file. stories:
-
story: hello world
steps:
- intent: hello world
- action: action_hello_world
With all the above changes, now i can see the bot responds with it’s initPayload. Hence it is possible to write our custom initPayload capability with out any further destructions. That’s the capability of RASA.
Note : This method will only work in Rasa 2.x
Solved screen shot ![]()
Thanks,
Best Regards, Ravi
