I been trying to set up MS Bot within an app. So far, I did following.
set a REST endpoint for Bot, that connector listens to it.
app.post("/botapi/messages", connector);
get APP_ID and APP_PASSWORD, emulator successfully connected to with following,
http://localhost:4000/botapi/messages APP_ID APP_PASSWORD
this is successful, bot replied as expected.
Tried to talk to the Bot using Direct Line API. Successfully started conversations. One of the response is as follows.
{ "conversationId": "3JYZyAn5VYB3HNcO3tcgtn", token: .... ..... }
I used "node-fetch" packages to issue POST request, as the documentations said.
However, I cannot send an activity using Direct Line API, received
internal server error 500
The documentation said the POST request should be like this below.
POST
https://directline.botframework.com/v3/directline/conversations
Authorization: Bearer my_secret
This worked perfectly for starting conversations but not for sending activities.
The activity I sent is:
{
"type": "message",
"from": {
"id": "user1"
},
"text": "hello Bot, say something"
}
I don't think "id" is something important, so that is what I posted to
https://directline.botframework.com/v3/directline/conversations/{conversationId}/activities
I used the conversationId received from starting a conversation. I googled around, but find no answer to my problem. Besides, I have few questions, maybe their answers would help me.
Q1: The url "https://directline.botframework.com/v3/directline/" is the same for everybody using Direct Line API? When I replace it with the endpoint of the bot, "http://localhost:3000/botapi/messages/conversations", I even cannot start conversations, nothing works.
Q2: How does the Direct Line API work? I issue POST with my secret to the API, then how the API finds my bot? How the Bot and API communicate? am I missing something here?
Q3: When I issue POST to send an activity, I followed the documentation. In the Authorization, I tried both my secret and the token I got from starting conversation, both did not work. I believe both should work. am I wrong?
Q4: Do I need to do something with Bot Connector Service? I read the article, but I don't know what it is for. am I wrong?
So, what I am missing here? How can I send activities?
Note: My bot is not deployed to azuri or aws, it is on my Mac only. But, I got APP_ID, APP_PASSWORD and SECRET for DirectLine as documents explained.