How to Add Welcome message in RASA X?

Hello @nik202, Do you know how to add a welcome message from bot-like “Hey there, I am a bot. How Can I assist you?”

Hello,

You will need to implement that in your frontend:

You will surely have a send(message) function to send the user messages via API. On start of your application, you will just need to automatically send a hidden message or payload as if it’s from the user, which will trigger the action.

For example, if utter_greet is the answer to the intent greet, you could execute send("Hello") or send("/greet") on startup.

1 Like

@Smit Heya! Can I ask have you decided any frontend for your bot, I mean GUI or you planning that whilst using Rasa-X?

@ChrisRahme Thank you for replying. But I couldn’t understand what you are trying to say. It would be better if you can explain with example.

Hey @nik202, RIght now I am testing my bot in Rasa X UI only. And as of now, I have not decided on which platform I will deploy it.

@Smit Right, because there is no clear solution what your use case required i.e bot should greet the user with the welcome message. You can follow Chris advice or as you asked for some example, I guess he will share.

If you plan for other alternative for GUI, I would love to provide more help for your project.

1 Like

@nik202 Yup, Let’s see what Chris will reply, after that we will go ahead.

@Smit :handshake: deal

1 Like

Fontend means the interface the user will use to talk the the bot, like a web widget or a mobile application.

You can’t start with a message from the bot in Rasa X; you will have to do that in your application. There are two ways:

  1. In that application, you will have a send() function for sure, to send the user message to the Rasa server when the user clicks on the “send” button.

    You will just need to call this function on startup, which means when the user opens the webpage or the mobile application.

    Let’s say in your domain, the phrase “Hey there, I am a bot. How can I assist you?” is called utter_greet, and in the stories, it is a response to the greet intent.

    So you can send a message with the greet intent, like “Hello” on startup, as I just said, so when the bot recieves it it will reply “Hey there, I am a bot. How can I assist you?”.

  2. You will also have a display_message() function which you will use to display the message received by the bot.

    You can also call this function on startup, to display the message directly without sending anything first.

There are multiple frontends you can use:

All of them have a feature to do what mentioned above, except the Rasa Android app (I think).


A small JavaScript code example for solution 1:

$(document).ready(() => {
  send("Hello")
})

function send(message) {
  $.ajax({
    url: rasa_server_url,
    type: "POST",
    contentType: "application/json",
    data: JSON.stringify({ message, sender: sender_id }),
    success(botResponse, status) {
      setBotResponse(botResponse);
    },
    error(xhr, textStatus) {
      setBotResponse('Error');
    },
  });
}

And for solution 2:

$(document).ready(() => {
  display_message("Hey there, I am a bot. How can I assist you?")
})

function display_message(message) {
  $(`<p class="botMsg">${message}</p>`).appendTo(".chats").hide().fadeIn(500);
}
2 Likes

@ChrisRahme :star_struck::star_struck::star_struck::star_struck::star_struck::star_struck:

2 Likes

Thank you so much @ChrisRahme. We tried your Solution 1 and it’s working perfectly :star_struck:.

And Nik202 You’re are right we tried the @ChrisRahme solution, but for that, we need one basic UI so we tried * Chatbot Widget by Jitesh Gaikwad (web). Look I’ve attached a screenshot.

1 Like

@Smit I told you, but you did a cheating :stuck_out_tongue: you suppose to use Rasa-X and you used alternative instead, which I also proposed. But, I am happy that you solved your issue :clap::clap:. If you got any GUI issue do let me know :wink: or to Chris.

1 Like

@nik202 Oops, sorry I broke the deal :see_no_evil: :stuck_out_tongue:,

But we also tried in Rasa X but we can’t call and customize the inbuilt function of Rasa X such as action_restart. That’s why we did it this way.

Glad to be of help :slight_smile:

1 Like