我正在尝试向我创建并发布到 azure 服务的机器人发送消息,以便该机器人可以开始向其某些用户发送消息。
我尝试首先在 Postman 上发出请求,然后我可以为该交互构建一个控制器。
我正在执行以下请求:
POST https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
Body:
grant_type:client_credentials
client_id: my_ms_app_id
client_secret: my_ms_app_secret
scope: https://api.botframework.com/.default
从这里我得到了承载授权的响应:
{
"token_type": "Bearer",
"expires_in": 3599,
"ext_expires_in": 0,
"access_token": "eyJ0eXA..."
}
然后我继续执行以下请求:
POST https://skype.botframework.com/v3/conversations
Content-Type: application/json
Authorization: Bearer eyJ0eXAi....
{
"bot": {
"id": "i don't have this id so i pass some string",
"name": "connector controller"
},
"isGroup": false,
"members": [
{
"id": "28:...", //ID of the bot I want to send the message to
"name": "Sp Bot"//Name of the bot I want to talk to
},
{
"id": "i don't have this id so i pass some string",
"name": "connector controller"
}
],
"topicName": "News Alert"
}
作为回应,我得到了与“id”匹配的对话id:“我没有这个id,所以我传递了一些字符串”:
{
"id": "我没有这个 ID,所以我传递了一些字符串"
}
然后我继续执行以下 POST 请求:
POST. https://skype.botframework.com/v3/conversations/i don't have this id so i pass some string/activities
Authorization: Bearer eyJ0...
Content-Type:application/json
我得到以下回复:
400 Bad Request
{
"error": {
"code": "ServiceError",
"message": "The conversationId 29... and bot .... doesn't match a known conversation"
}
}
看起来问题出现在第二个和第三个 post 方法之间。看起来像https://skype.botframework.com/v3/conversations https://skype.botframework.com/v3/conversations不会与具有我输入的 ID 的机器人生成对话。
因此,当我对机器人进行最后一次调用时:https://skype.botframework.com/v3/conversations/.../activities https://skype.botframework.com/v3/conversations/.../activities我总是收到 serviceError 消息。