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.
@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.
@nik202 Yup, Let’s see what Chris will reply, after that we will go ahead.
@Smit deal
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:
-
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 thegreet
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?”. -
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:
- Chatbot Widget by Jitesh Gaikwad (web)
- WebApp by me (web)
- Webchat by Botfront (web)
- Chatroom by ScalableMinds (web)
- Rasa Android by Dishant Ghandi (mobile)
- MobApp by me (mobile)
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);
}
Thank you so much @ChrisRahme. We tried your Solution 1 and it’s working perfectly .
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.
@Smit I told you, but you did a cheating you suppose to use Rasa-X and you used alternative instead, which I also proposed. But, I am happy that you solved your issue . If you got any GUI issue do let me know or to Chris.
@nik202 Oops, sorry I broke the deal ,
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
Are these widgets still working with Rasa 3.x?
@lucas144 you can try botfront
Okay @nik202. I will check it out. I tried with " * Chatbot Widget by Jitesh Gaikwad (web)" but it was not working anymore with Rasa 3.1
@lucas144 sure give it a try, it always works for me with 2.x and 3.x in past, but there can be some sanic version issue, that you can easily find on the forum.
Sounds good @nik202. Thanks!
@lucas144 no worries.