You're on the right track using a global variable to control post-call survey triggering in Omnichannel for Customer Service. However, directly setting and reading global variables from within a bot in the way you're describing isn't the standard approach. Global variables in Omnichannel are typically managed at the workstream level and are used for routing and other workstream-specific logic, not directly for bot control flow.
Here are the correct ways to achieve what you're trying to do:
1. Context Variables (Recommended):
The best way to control survey triggering based on bot interactions is to use context variables. These are variables that are specific to the conversation context and can be passed between the bot and the workstream.
- Bot Design: In your bot, before the conversation is transferred to the workstream, set a context variable (e.g.,
surveyConsent
). Set its value based on the user's interaction in the bot (e.g., if they opted in for a survey). You can use Power Automate to set this context variable or using the code in the bot itself.
- Workstream Configuration: In your workstream, in the post-conversation survey settings, you can use rules based on the context variable to determine whether to trigger the survey. You don't need to read a global variable. Instead, you'll check the value of the context variable (e.g.,
surveyConsent
)
2. Using Power Automate (Alternative):
You could use Power Automate to manage the survey triggering logic.
- Bot: Your bot can send a message or trigger a Power Automate flow when the conversation ends.
- Power Automate: The flow can then check the relevant information (e.g., user consent stored in a D365 entity or passed as a parameter) and then trigger the post-conversation survey using the Omnichannel APIs.
Why Not Global Variables Directly?
Global variables in Omnichannel are primarily used for:
- Routing: Directing conversations to the appropriate agents or queues.
- Workstream Configuration: Setting default behaviors for the workstream.
They are not designed to be dynamically set and read by bots during a conversation's flow. Context variables are the correct mechanism for this type of scenario.
How to Implement Context Variables:
The specific implementation details will depend on the bot framework you're using (e.g., Power Virtual Agents, Azure Bot Framework). Consult the documentation for your bot platform on how to set and pass context variables during a handoff to a workstream. The key is to set the context variable in the bot before the transfer and then use that context variable in your workstream's post-conversation survey configuration rules.
By using context variables or Power Automate, you'll have a much more robust and maintainable way to control your post-call surveys based on bot interactions.