botframeworkazure-bot-servicedirect-line-botframeworkweb-chat

Send Conversation History API returning HTTP 400 BotFramework


I'm trying to sendConversation History API provided by Microsoft in BotFramework Documentation. It takes Transcript object (array of activities) as the input. But I've getting HTTP 400 Bad Request when using trying that.

I'm making a POST request on this and authenticating it using JWT Token generated by client credentials for the bot.

https://directline.botframework.com/v3/conversations/HBoZPkTiBYOAadigqEqFaJ-us/activities/history

This is the error I get.

{
    "error": {
        "code": "BadSyntax",
        "message": "Invalid or missing activities"
    }
}

This is the activity array payload that I'm using

[    
    {
        "type": "message",
        "id": "HBoZPkTiBYOAadigqEqFaJ-us|0000003",
        "timestamp": "2022-09-05T08:10:00.3574378Z",
        "localTimestamp": "2022-09-05T13:39:57.633+05:30",
        "localTimezone": "Asia/Calcutta",
        "serviceUrl": "https://directline.botframework.com/",
        "channelId": "directline",
        "from": {
            "id": "dl_uID1",
            "name": "userName"
        },
        "conversation": {
            "id": "HBoZPkTiBYOAadigqEqFaJ-us"
        },
        "recipient": {
            "id": "bot-name-dev@abcd",
            "name": "bot-name-dev"
        },
        "textFormat": "plain",
        "locale": "en-GB",
        "text": "hi",
        "channelData": {
            "clientActivityID": "1662365337633rmq6e8mbm09",
            "clientTimestamp": "2022-09-05T08:09:57.633Z"
        }
    }
]

I'm not able to figure out what's the correct format of activity object that it is expecting.


Solution

  • After connecting with Microsoft, I found this is the correct payload for this API.

    {
      "activities": [
       
           {
        "type": "message",
        "id": "whatever-conversation-id-in|0000000",
        "timestamp": "2022-11-20T20:14:26.242902Z",
        "serviceUrl": "https://directline.botframework.com/",
        "channelId": "directline",
        "from": {
            "id": "dl_test_id",
            "name": ""
        },
        "conversation": {
            "id": "whatever-conversation-id-in"
           
        },
        "recipient": {
            "id": "ABC_bot",
            "name": "ABC_bot"
        },
        "text": "Hello Bot"
    }
    ]
    }