Forum Discussion
arie_schwartzman
Microsoft
Jan 05, 2023Accessing "Conversation", "User" or "Scenario" entire objects is not allowed
Health bot uses three scopes of variables:
- Conversation - Variables that store data throughout the entire conversation. They are removed when the conversation ends.
- User - Variables that are stored in the context of the User Id that interacts with the bot. They are stored until the user asks to remove them. They are used so that we can retrieve user specific data, like birthdate, without asking it each time the same user interacts with the bot.
- Scenario - Variables that are stored in the context of the scenario and kept until the scenario ends. In analogy to normal programming language, they are like function variables that are allocated on the stack. If scenario A calls scenario B, each of the scenarios can have the same variable "foo" and each scenario will hold a different value. This allows us to write contained and reusable scenarios without the fear of "side effects".
The syntax for accessing each variable scope is as follows:
"This is a welcome message " + conversation.welcomeMessage
"conversation" is not a real object, it's just a scope of the welcomeMessage variable. Therefore, we don't allow accessing the "conversation" as plain JavaScript object since it's really a reserved word. To access specific variables within the conversation scope, you can use the assign step and "pluck" the variables within the conversation scope into a new object. For example:
We define a new object on the scenario scope called "dumpObject", we then "cherry pick", variables from scenario or conversation scopes. We later can use this object whenever we like, for example use it to dump onto custom telemetry.
- Karteek_BandiCopper Contributor
Thank you for explanation of the variables.
could you please let us know on what options I have to extract scenario variables (for example scenario.results) and send them to our application which has the healthbot embedded as Iframe.