Initial Approach:
When we started looking for options, we could initially figure out that this information is stored in the Dataverse table called Conversation Transcripts. Each interaction is created as a record and the entire conversation is stored in a field called Content field. The idea is to use Power Automate in the Escalate Topic to retrieve this record from the Conversation Transcripts table using the Conversation ID and post the chat conversation in the Teams Channel, in case of an escalation.
Figure 1: Dataverse Tables accessible after navigating to Power Apps or Power Automate
Figure 2: Conversation Transcript (Stores Chat Conversations) Table in the Dataverse
Figure 3: Content field that stores the chat conversation
Figure 4: Raw data in the Content Field. Additional formatting to be done to extract the required information.
Inferences based on the initial approach:
- Significant delay in the record creation after the conversation ended. Record is not created for close to 30 mins.
- Use of Premium Connector for Dataverse in Power Automate to query the Conversation Transcripts Table adds additional cost.
The above points made us look for an alternative approach. We looked at Global Variables and we could successfully append the data to the global variable using Power Fx Formulas.
Our Approach:
The approach was based on Global Variables creation and appending the same across all the topics.
Below are high level steps as part of this approach.
- Adding/Declaring Global Variable in Conversation Start Topic.
- Appending the Global Variable with both the question and the user response in all the topics.
- Use Global Variable within the Escalation Topic and trigger a PowerAutomate within the topic by passing this variable for the chat conversation to be posted to Teams Channel.
Benefits from this approach
- Chat Conversation is available immediately in the Teams Channel in case of escalation.
- Don’t need any premium connectors to access the Dataverse Conversation Transcripts Table.
Customizing Existing Inbuilt Topics
- Conversation Start Topic:
This topic is triggered at the start of the conversation. Declared global variables in this Topic as below.
- BotName: Stores the name of the Chatbot.
- UserName: Stores the display name of the user interacting with the Chatbot.
- Mainvar: Stores details of the chat history.
- BreakLine: Used for new line in the PVA and Teams Chat (Post in Teams Channel).
Figure 5: Global Variables declared in Conversation Start Topic
- Fallback Topic:
This topic is triggered when the Chatbot cannot match the user's question or message to a trigger phrase. It will prompt the user with the message:
I'm sorry, I'm not sure how to help with that. Can you try rephrasing?
If the user's question remains unanswered, it hits the Escalate Topic, where the user receives a customized the message:
I'm sorry, I couldn't help you with your query. However, I've forwarded your query to the IT Service Team. They will get in touch with you shortly.
Figure 6: Appending data to Global Variable.
- Escalation Topic:
This topic is triggered when the bot is not able to answer the user query.
Figure 7: Input variables to Power Automate are passed here so the chat conversation is posted in Teams Channel
Figure 8: Power Automate to post the chat history to Teams Channel and to create a log in sharepoint list
Log entire chat history in sample topic:
- Create a topic IT Help desk.
- Set the global variable value at every node as below.
Figure 9: Sample Topic depicting the Global Variable Append operation.
Figure 10: Appending Name Question and User Response to Global Variable
Figure 11: Appending Age Question and User Response to Global Variable
Figure 12: Appending DOB Question and User Response to Global Variable
Figure 13: Sample Output of Chat Conversation posted to Teams Channel using PowerAutomate
Note:
- Global Variables used in the approach mentioned above has an overhead of updating the same in the new topics that will be created and if any updates are made to existing topics. This approach worked for us since the client requested us to capture only the last user query to which the bot couldn’t respond.
- The above approaches work only with Copilot Studio for Web and not in Copilot Studio for Teams.
Figure 14: Copilot Studio for Teams based Bot Actions
Copilot Studio for Teams has few limitations.
- It doesn't support the declaration of global variables.
- Data is not available for query within the Dataverse Conversation Transcripts table.