Programmatic client side scenario invocation
In some cases you would like to invoke the scenario before the end user provides any input. For example, you want to show a welcome message in the chat with helpful options as soon the user opens the chat application.
You can invoke a scenario by adding some client side code to the chat application. The JavaScript code sends an event that invokes a custom scenario you have defined for your Healthcare Bot Instance.
The healthcare agent service Container Sample contains a sample code for invoking a scenario in the Webchat channel.
To implement this behavior, uncomment the following code from the function initBotConversation()
in the /public/index.js
file:
triggeredScenario: {
trigger: "{scenario_id}",
args: {
myVar1: "{custom_arg_1}",
myVar2: "{custom_arg_2}"
}
}
Replace {scenario_id} with the scenario ID of the scenario you would like to invoke.
You can also pass different values through the "args" object. Values passed in the "args" object are accessible in the healthcare agent service scenario editor by using the scenario.scenarioArgs variable.