Cant send message using directlineapi in bot frame

2019-08-19 05:35发布

问题:

I am using directline api for webchat.

After generating token, Along with that token in the header and activity object in the body I am requesting to this url:

https://directline.botframework.com/v3/directline/conversations/{conversationID}/activities

I am getting 404 page not found response:

Here is my Activity object:

{"type":"message","text":"Testing Directline API","conversation":{"id":"conversationId"},"recipient":{"id":"User request id"},"from":{"id":"mybot id","name":"My Bot Name "}}

My Request body:

{"type":"conversationUpdate","id":"ID","timestamp":"2017-12-23T05:03:45.5925924Z","serviceUrl":"https://directline.botframework.com/","channelId":"webchat","from":{"id":"FROMID"},"conversation":{"id":"conversationid"},"recipient":{"id":"mybotid","name":"Bot Name"},"membersAdded":[{"id":"mybotid","name":"Bot name"}]}

I don't know how to fix that.

回答1:

getting 404 page not found response

If you’d like to send an activity to the bot, the API that you are using seems ok.

POST https://directline.botframework.com/v3/directline/conversations/{conversationID}/activities

Based on my test, I suspect something wrong with {conversationID} that you provided, which causes the issue. Please try to open a new conversation and use the returned conversation id to send activity and check if it works fine.

In my test, if I provide an incorrect conversation id, I will get 404 with “Unknown conversation” error message in fiddler.