2
votes

In the test web chat in azure portal, I get the bot to speak back to me the conversation id by getting it from session.message.address.conversation.id.

I wish to then view activities for this conversation id using the method described here:

https://docs.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-direct-line-3-0-send-activity

(POST https://directline.botframework.com/v3/directline/conversations/abc123/activities )

However, I get the following error:

{
"error": {
    "code": "BadArgument",
    "message": "Unknown conversation"
    }
}

I have also tried:

POST https://webchat.botframework.com/v3/directline/conversations/9323c31ab1ba42328edc9191621f9c9c/activities

Any help on how I can use direct line to post/view activities for a webchat?

Thanks!

1

1 Answers

0
votes

Explain your issue

I cannot reproduce your issue with POST conversations. Actually, I can only reproduce your issue with following step:

generate directline token => leverage the response conversationId and token directly call Retrieve activities with HTTP GET with:

GET https://directline.botframework.com/v3/directline/conversations/abc123/activities
Authorization: Bearer token

The correct steps are: generate token => POST to Start a conversation => GET to Retrieve activities with HTTP GET.

For your requirement I don't think we can interrupt outside of the conversion, as the description of Generate a Direct Line token

To generate a Direct Line token that can be used to access a single conversation.

So the token you asked from anywhere else, cannot request the activities in webchat.

An work around

You can leverage BotFramework-WebChat to quickly build up a web site bot testing environment. And generate the token in your own server for the bot client authentication. Then you can use the generated token and conversationId for requesting all the activites between bot and this bot client web site outside of the box.