2017-08-22 11 views
0

私は現在、Microsoft-Teamsのカスタムボットを開発中です。 Msdoc(https://msdn.microsoft.com/en-us/microsoft-teams/custombot)に記載されている手順に従いましたが、まだ管理されておらず、要求に対して適切に応答を送信していませんでした。以前jsonは、その後に送信されMicrosoft-Teamsカスタムボット:返信を送信中にエラーが発生しました

{ 
"type": "message", 
"id": "1503406241867", 
"timestamp": "2017-08-22T12:50:41.978Z", 
"localTimestamp": "2017-08-22T14:50:41.978+02:00", 
"serviceUrl": "https://smba.trafficmanager.net/emea-client-ss.msg/", 
"channelId": "msteams", 
"from": { 
    "id": "29:1nxaNQeM7AaQumVmUmPaS4K0gMHZD-FtA_gnJ9xFqZXG5nlpRnsIv-uWeAWQeuKKEQXEEXbwhK4LG1oqvqinGJg", 
    "name": "John Doe" 
}, 
"conversation": { 
    "isGroup": true, 
    "id": "19:[email protected];messageid=1503406241867", 
    "name": null 
}, 
"recipient": null, 
"textFormat": "plain", 
"attachmentLayout": null, 
"membersAdded": [], 
"membersRemoved": [], 
"topicName": null, 
"historyDisclosed": null, 
"locale": null, 
"text": "<at>AgentSmith</at> test", 
"speak": null, 
"inputHint": null, 
"summary": null, 
"suggestedActions": null, 
"attachments": [ 
    { 
     "contentType": "text/html", 
     "contentUrl": null, 
     "content": "<div><span itemscope=\"\" itemtype=\"http://schema.skype.com/Mention\" itemid=\"0\">AgentSmith</span> test</div>", 
     "name": null, 
     "thumbnailUrl": null 
    } 
], 
"entities": [ 
    { 
     "type": "clientInfo", 
     "locale": "fr-FR", 
     "country": "FR", 
     "platform": "Web" 
    } 
], 
"channelData": { 
    "teamsChannelId": "19:[email protected]", 
    "teamsTeamId": "19:[email protected]", 
    "channel": { 
     "id": "19:[email protected]" 
    }, 
    "team": { 
     "id": "19:[email protected]" 
    }, 
    "tenant": { 
     "id": "c41d586a-6ec1-4ce3-89ed-54a2f844c8e1" 
    } 
}, 
"action": null, 
"replyToId": null, 
"value": null, 
"name": null, 
"relatesTo": null, 
"code": null} 

は、これは私が@AgentSmithで、MS-チーム内のチャネル上で件のデータを送信するときに、私のウェブフックハンドラが受け取るものです(AgentSmithは私のボットの名前です)私たちのプラットフォームは、単純なテキスト応答を計算します。

https://smba.trafficmanager.net/emea-client-ss.msg/v3/conversations/19:[email protected];messageid=1503406241867/activities/1503406241867

体と

{ 
"type": "message", 
"id": "1503406241867", 
"timestamp": "2017-08-22T14:01:31.352Z", 
"localTimestamp": "2017-08-22T16:01:31.352+02:00", 
"serviceUrl": "https://smba.trafficmanager.net/emea-client-ss.msg/", 
"channelId": "msteams", 
"from": { 
    "name": "AgentSmith", 
    "id": "fake string as I don t know the id" 
}, 
"conversation": { 
    "isGroup": true, 
    "id": "19:[email protected];messageid=1503406241867", 
    "name": null 
}, 
"recipient": { 
    "id": "29:1nxaNQeM7AaQumVmUmPaS4K0gMHZD-FtA_gnJ9xFqZXG5nlpRnsIv-uWeAWQeuKKEQXEEXbwhK4LG1oqvqinGJg", 
    "name": "John Doe" 
}, 
"textFormat": "plain", 
"attachmentLayout": null, 
"membersAdded": [], 
"membersRemoved": [], 
"topicName": null, 
"historyDisclosed": null, 
"locale": null, 
"text": "Désolé, je n'ai pas compris", 
"speak": null, 
"inputHint": null, 
"summary": null, 
"suggestedActions": null, 
"attachments": [], 
"entities": [ 
    { 
     "type": "clientInfo", 
     "locale": "fr-FR", 
     "country": "FR", 
     "platform": "Web" 
    } 
], 
"channelData": { 
    "teamsChannelId": "19:[email protected]", 
    "teamsTeamId": "19:[email protected]", 
    "channel": { 
     "id": "19:[email protected]" 
    }, 
    "team": { 
     "id": "19:[email protected]" 
    }, 
    "tenant": { 
     "id": "c41d586a-6ec1-4ce3-89ed-54a2f844c8d0" 
    } 
}, 
"action": "message", 
"replyToId": "1503406241867", 
"value": null, 
"name": null, 
"relatesTo": null, 
"code": null} 

要求として失敗した計算された応答を含む:当社のプラットフォームから受信した応答が、私は次のエンドポイントにPOSTリクエストを行うと

続く:

error: 0.4.0: send message error: statusCode:403, statusCodeMessage:Forbidden, 
error: { 
    "error": { 
     "code":"ServiceError", 
     "message":"not member of thread" 
    } 
} 

助けていただければ幸いです。私が作成した返信メッセージに何が間違っているのかわかりません。

ところで、私のwebhookハンドラで受信したオブジェクトの受信者がnullであることは奇妙なことではありませんか?

答えて

0

遅くとも返信して申し訳ありません - 投稿時にこれを見ませんでした。

あなたは、あなただけのエンドポイントにHTTPポストに応答することができません(とすることはできません)https://smba.trafficmanager.net/emea-client-ss.msg/に投稿...

つまり、チームはPOSTを行い、応答にはメッセージオブジェクトが含まれています。

ここに、概念を示すnode.jsのエコーボットがあります。

const util = require('util'); 

var http = require('http'); 
var PORT = process.env.port || process.env.PORT || 8080; 

http.createServer(function(request, response) { 
    var payload = ''; 
    request.on('data', function (data) { 
     // console.log("Chunk size: %s bytes", data.length) 
     payload += data; 
    }); 

    request.on('end', function() { 
     try { 
      response.writeHead(200); 
      var receivedMsg = JSON.parse(payload); 
      var responseMsg = '{ "type": "message", "text": "You typed: ' + receivedMsg.text + '" }'; 
      response.write(responseMsg); 
      response.end(); 
     } 
     catch (err) { 
      response.writeHead(400); 
      return response.end("Error: " + err + "\n" + err.stack); 
     } 
    }); 

}).listen(PORT); 

console.log('Listening on port %s', PORT); 
関連する問題