How to assign a dynamic global variable from entities to be use in different tasks

Hello

My first dialog task has 3 entities nodes. I want to assign those values to a global variable so those values can be used in all the dialog task.

Can you share with me some examples of how to assign them with javascript and how can I call them in the other dialog tasks?

Please don’t refer me to the docs. I already read them I don’t get it how to do it.

Just, if you could be so kind. Just an example how to assign them to a global variables and how to call them in the other dialog tasks

Thanks

@daniel

This is my bot setup at a high level

Task - storeEntitiesInContext will get the entities and store them in the ‘context’ before ending the task. Read further on using the context. The below example will illustrate anyway.

Task - checkEntitiesInContext will fetch the stored values from the context for further use.
image

Details
the script node - scrStoreEntities in storeEntitiesInContext task has the below code. This again impements what is explained in Using Session and Context Variables in Tasks - Kore.ai Documentation but in a variety of ways. Note that the below example uses both - BotUserSession and UserSession. Storing in both is possible but I would request you to understand the purpose of each before you use them.

//Setting E1 in BotUserSession
context.session.BotUserSession.myEnt1 = context.entities.E1;

BotUserSession.put("MyEnt2",context.entities.E2);//another way to set a variable

//Setting in UserSession
context.session.UserSession.myEnt3 = context.entities.E3;

//reset the entities; Not mandatory
context.entities.E1 = undefined;
context.entities.E2 = undefined;
context.entities.E3 = undefined;

In another task, checkEntitiesInContext, I am fetching the values stored in a simple message node. In plain-text {{flower}} notation is used to get the value and in JS mode, direct context.session.BotUserSession.KEY or BotUserSession.get("KEY") is used. NOTE - The Key or context variable name is case-sensitive

Output:


So, to conclude, before a task ends, one can put the entities/any collected/processed information in the right context variable to use it in other tasks of the bot.

@daniel
If you are new to Kore.ai, I would also encourage you to enroll in Kore.ai training

And use the academy. https://academy.kore.ai/learningpath/course-124---context-and-session-variables
Any time, a video course is better than documentation :slight_smile:

Hello @swagata.sengupta

Thank you for your help.

This worked for our prospect customer!! However I think how you describe it is how has to be in the documentation. Sometimes the documentation is very general and assumes that the every user that read it will catch the solution and sometimes it’s not like that.

The clients that we are presenting and selling Kore in LATAM are not technical at all so we must show them that kore is easy to use and config like if you were using an iphone.

Thanks again for your help

@daniel

I will convey your feedback. However if one is building bots, as a part of onboarding we are providing self help academy as well as basic and advanced training. So far it has been adequate but I would agree that we can improve on the no code-low code aspects.

@santhosh.myadam

is this link is still woking Error page

Hello Vignesh,

Please confirm if you are facing the below error ?

Thank you,
Srujan Madderla
Kore.ai Community Team

yes, Srujan madderla