Hi Team,
I tried retrieving below highlighted conversations using Direct Line API 3.0,
but getting an error saying that "Token not valid for this conversation"
Generated token using Mobile Channel Endpoint URL.
In the above GET call, used System.Conversation.Id value
can you please help me out with this issue?
Hi Michael,
Thank you so much for quick reply.
Is it possible handoff conversations to a Generic Engagement Hub.
Hand off chatbot conversations to any generic engagement hub - Microsoft Copilot Studio | Microsoft Learn
Below Github repo is not having complete code for this implementation, if possible, can you please provide complete code for this.
CopilotStudioSamples/ConnectToEngagementHub at master · microsoft/CopilotStudioSamples · GitHub
Is this solution works for both Teams and Web?
you can build you own user and assistant transcript and keep it in a global variable to do the same thing.
Hi Henry,
Thank you so much for providing workaround solution. Appreciated for responding to our queries quickly.
Is there any solution available for PVA bot to receive teams bot conversations like we have it for bot framework?
Messages in bot conversations - Teams | Microsoft Learn
The token gets generated when initiating the conversation from the chat client. Not during conversation runtime, as the conversation has already started.
For Teams, the only workaround I can think of is capturing all user and bot messages as part of a global variable. For users messages, you can use the "message received" trigger event. For bot messages there is no equivalent, so you'd need to append to your variable in each topic, after a bot message.
Henry
Is there any workaround or solution available for teams channel?
Can't we generate token inside copilot studio using below api endpoint?
My example works for the default canvas using the latest code provided here: https://learn.microsoft.com/en-us/microsoft-copilot-studio/customize-default-canvas?tabs=web#customize-the-default-canvas-simple, as long as you pass the token value as a context variable to your bot.
This won't work in the Teams channel, as it isn't using Direct Line but a specific channel instead.
Hi Henry,
Thank you so much quick reply. Appreciated for all help.
Provided example worked for me. But It is not taking token value from the canvas. When I am providing manually through a questions, then able to retrieve user conversations as shown below.
User will access this bot from Teams App also. There we will not be having option to trigger 'StartConversation' event like how we did it from the canvas.
do you have solution for Teams Channel?
Also, is there any way to generate token using API endpoints inside copilot studio like how we are generating token using below code?
Hi @argeraju
I actually tried something new to get the transcript, you may disregard the "Escalate" approach.
This works for conversations happening on the Direct Line channel (website, custom app, etc.)
I basically:
To pass the Direct Line token, I just add this value to the default canvas:
On the Copilot Studio side, I create a custom topic where I ask the questions to capture the input Global variable(s):
For my example, I create a Transcript topic, where I make an HTTP call to the Direct Line API to retrieve the conversation activities. I use the System.Conversation.Id and Global.DirectLineToken variables:
And then with some Power Fx formula I isolate the messages to build the transcript as a table and then display it to the user as an adaptive card.
Here's the full topic YAML:
kind: AdaptiveDialog
beginDialog:
kind: OnRecognizedIntent
id: main
intent:
triggerQueries:
- Transcript
actions:
- kind: HttpRequestAction
id: Uaai35
url: "=\"https://directline.botframework.com/v3/directline/conversations/\" & System.Conversation.Id & \"/activities\""
headers:
Authorization: "=\"Bearer \" & Global.DirectLineToken"
response: Topic.Transcript
responseSchema:
kind: Record
properties:
activities:
type:
kind: Table
properties:
attachments:
type:
kind: Table
properties:
content:
type:
kind: Record
properties:
$schema: String
body:
type:
kind: Table
properties:
text: String
type: String
wrap: Boolean
type: String
version: String
contentType: String
channelId: String
conversation:
type:
kind: Record
properties:
id: String
entities:
type:
kind: Table
from:
type:
kind: Record
properties:
id: String
name: String
role: String
id: String
inputHint: String
listenFor:
type:
kind: Table
membersAdded:
type:
kind: Table
membersRemoved:
type:
kind: Table
name: String
reactionsAdded:
type:
kind: Table
reactionsRemoved:
type:
kind: Table
replyToId: String
serviceUrl: String
speak: String
suggestedActions:
type:
kind: Record
properties:
actions:
type:
kind: Table
properties:
text: String
title: String
type: String
value: String
to:
type:
kind: Table
text: String
textFormat: String
textHighlights:
type:
kind: Table
timestamp: String
type: String
- kind: SetVariable
id: setVariable_Ej7JF3
variable: Topic.TranscriptTable
value: |-
=ForAll(
Filter(Topic.Transcript.activities, type = "message"),
{
from: If(from.role = "bot", "Bot: ", "User: "),
text: text
}
)
- kind: SendActivity
id: sendActivity_tVLuEw
activity:
attachments:
- kind: AdaptiveCardTemplate
cardContent: |-
={
type: "AdaptiveCard",
'$schema': "http://adaptivecards.io/schemas/adaptive-card.json",
version: "1.5",
body: [
{
type: "Container",
items: [
{
type: "TextBlock",
text: "Conversation ID: " & System.Conversation.Id,
wrap: true,
size: "Small",
weight: "Lighter"
},
{
type: "TextBlock",
text: "Date: " & Now(),
wrap: true,
size: "Small",
weight: "Lighter"
}
]
},
{
type: "Table",
columns: [
{
width: "1"
},
{
width: "4"
}
],
rows: ForAll(Topic.TranscriptTable,
{
type: "TableRow",
cells: [
{
type: "TableCell",
items: [
{
type: "TextBlock",
text: from,
wrap: true,
weight: "Bolder"
}
]
},
{
type: "TableCell",
items: [
{
type: "TextBlock",
text: text,
wrap: true
}
]
}
]
}
),
firstRowAsHeaders: false
}
]
}
Hi Henry,
Thank you so much for quick reply, appreciated.
I have added mentioned event in Escalate Topic. Here I don't know what value should be provided to this event.
I can able to download transcript JSON file but it is not having any values, it is just empty.
can you please provide a sample code?
Also, provide sample code or endpoint for retrieving those transcripts using Direct line API.
The Direct Line token is unique per conversation, I don't think it's available as part of the native system variable.
To retrieve the conversation transcript over the Direct Line API, Copilot Studio must escalate to a live agent (and so send a a handoff.initiate event, that will contain variable values and the full technical JSON transcript as an activity attachment).
Ekta Gupta
4
ricardodesouza
2
L-1234567-0
2