How to use context session in Welcome Message

I want to show the First name from the Context Session in the Welcome Message while using bot. But I am not able to show it. I have used <%= context.session.UserContext.firstName %> and {{context.session.UserContext.firstName}}.

Please let me know if it is supported or not.

Hi Himanshu, using {{context.session.UserContext.firstName}} in the message prompt for welcoming user by name should work. I tested and it worked. See below for reference.
07%20PM
51%20PM

Thanks
Swathi

Thanks for your reply. Actually I want to show the user name on Welcome Message which we configured in Settings session. Like in your snapshot the name should appear after “Hi!” itself.

Hi! Swathi

Himanshu, you can customise the welcome message at Bot settings as shown below. This way, Bot welcomes or greets the user based on the name given in the session.
42%20PM

I tried the same thing in this Welcome Message, but it doesn’t get render in chat window. It display as it is like {{context.session.UserContext.firstName}} not the actual name. I think you should also not be able to see user name in welcome message. Can you check and paste the screenshot of chat window with User name?

Himanshu, when you pass user session in welcome message at bot level, user is greeted as soon as the chat starts.
28%20PM

For more info, you should read through our documentation

https://developer.kore.ai/docs/bots/bot-builder/defining-bot-tasks/using-session-and-context-variables-in-tasks/

Hi swathi, Welcome message option not appearing in my settings page. Please give me the solution.IMG-20181124-WA0010

@rajinisiva93 Welcome message is now under Extensions - Events. With new release(6.3) in place, we have made changes to our BOT kit. You can learn about our release highlights here https://developer.kore.ai/docs/bots/whats-new-in-this-release-bot-builder/

Thanks
Swathi

1 Like

Hi Swathi,

I tried this way but why its not showing the welcome message in chat box

@chenchukishore.thath Welcome event only gets triggered the first time user sends the message. The consecutive conversations wouldn’t have the event triggered to the user.

Also, if in case you requirement is to show message when user is connected, then you could use the On connect event. Else if, the requirement is to send welcome message on first message from user, welcome event can be configured.

In case, both welcome event and on connect event are configured, then for websdk as a channel, the on connect event would take precedence.

1 Like

Okay thanks I will try that as well. One more thing like is there any way we could clear the chat bot history?

@chenchukishore.thath You could configure the chat history to load or not load at webSDK channel. In the index.html file at the variable chatConfig, you should see the parameter “loadHistory”. On setting it to “false” , the chatHistory wouldn’t be loaded to the user.
image

Hey! really thanks man that "on connect " thing worked. I will check this as well.

Could you please tell me from where I will get this index.html file I’m not able to find it

@chenchukishore.thath Glad we could help you with the “onconnect” event. You couldn’t disable the chathistory when you are testing the bot on the bot builder itself. If you have configured the webSDK channel which is available at https://github.com/Koredotcom/web-kore-sdk , then you should find it inside the UI folders as shown below:
image

@Subrahmanyam Could you please tell me how can i set context Ssersession in index.html and how do get usersession from welcome event or on connect

Hi @rajinisiva93,
Both the events on connect and welcome have the options to invoke a dialog, run a script or send a message.

Data available in the session context can be utilized in all three ways. The only way you could add some data to the context from webSDK is by adding the needed information in the customData at botinfo of index.html.

The added information should be available under BotUserSession. Detailed steps on how to add the customData and where the data is accessible are mentioned at the below post.

1 Like

Hi @Subrahmanyam
How do show multiple welcome message at a time.
1.Hi
2.i am your assistant.
3.How can i help you.

i want to show separate message at same time.

@rajinisiva93 Please follow below steps to achieve this.

  1. Add a hidden dialog in your bot. Say “Welcome Event”

image
2. Add two message nodes in the dialog as shown below
image
3. Link the welcome event at the extensions of the bot to the above dialog.
image
4. Publish the bot with extensions for making the changes available to end users
5. Run the bot via webSDK as an end user.
image

Thanks @Subrahmanyam Is it possible to show those message without user intraction.