How to let bot start the conversation

Hi all,

Using the latest rasa version, i would like to know if there ara some ways to let the bot start the conversation.

Can we start with an utterance instead of action_listen?

Thanks

1 Like

Hi @Asmacats, You can use the below api to trigger an event when ever user opens the chat window

http://localhost:5005/conversations/{conversation_id}/execute

Rasa Documentation

Note that you will require conversation_id

@JiteshGaikwad Thanks for your response. But i dont understand how to use it? in which file i have to put it? and how to get automatically the conversation id.

hi @Asmacats, In my case what I had done was:

  • I had written a custom action that will send the greeting message
  • then I had configured the event i.e whenever the user will open the chatbot widget(webpage), I am sending an event to the bot that will trigger the custom actions and it will greet the user

attaching the sample code for your references:

actions.py file image

make sure you return the action with UserUtteranceReverted()event, so that it won’t affect the conversation flow

script.js file(this is the custom webpage widget build using jquery)

here If you see while calling the REST api, I am passing the user_id as the conversation_id

output:

image

Hope this helps you :wink:

2 Likes

@JiteshGaikwad thanks for your reponses. are you used this solution in case of channel connexion??

@Asmacats, I have used this in the . Rasa’s rest channel

1 Like

I have used this but conversation/tracker store in mongodb as a same conversation_id. so, when I open new conversation tab but all conversation is append on same conversation_id. So, how can we store diffrent conversation with diffrent conversation_id?

I try it, but the response data is null, what happens? thanks

Hi @JiteshGaikwad, thanks for sharing this info. However, i ran into some issue whereby i couldn’t make the action_greet_user to initiate upon starting the conversation UI. How can i debug this and see where i made a mistake ? There is no error on the browser console, and i have added action_greet_user as a custom action inside actions.py .

hey @Wy0024, can you show me the logs of the Rasa Core server.

Hi @JiteshGaikwad, i took a slight detour and dive into another webchat integration and the bot conversation initiation went well.

Anyways, back to this, attaching my screenshot as below and do let me know if you notice any problem. It seems like there is some work to be done on the events perhaps? FYI, i am following the tutorial from one of your HR bot repo here

Thanks!

Sorry @JiteshGaikwad for the false alert, i just went thru the scripts and notice there are some functions in the js file that has been commented out. After following the instructions, the UI is now able to initiate the starting message. All is good for now. For those out there looking for a solution for this, do take a look into this repo here.

Thanks in advance!

1 Like

hey @Wy0024, that’s fine, I am glad that it worked for you well :slight_smile:

Hi @JiteshGaikwad, i have another question, is there a way we can have like a “preview” mode from a dynamically changing url image link? Feel free to redirect me to any relevant post, as i am coming up short in finding any reference on this.

Much Appreciated.

I didn’t understand what “preview” mode you are talking about, can you please explain me detail? :sweat_smile:

Sure, sorry about the lack of background for this. I have an idea of trying to create a bot response that crawls information from a news api and reply with:

  • An image (this is a url in the api)
  • A title (this is a string)
  • A reference link (this is a url)

And i m looking for a way to let the image url to display as an image on the UI, instead of a clickable link (this is what i get in Rasa X). Any ideas i can achieve this ?

which chatbot UI are you using?

For now, i have both webchat and this custom . At the same time, i have Rasa X ui as well for my interactive training.

Hello jitesh i’m following your code technique but one thing i didn’t understand that your script.js file concept about where in which folder i have to create this file in my rasa chatbot project.

Hey there, for me, i downloaded the repo into my local machine and just hit the index.html file. But before that, i ran both the action server and the model on my IDE. The script.js is not in my chatbot project directory.

Hope this helps !