背景
社内のChatシステムが、ChatworkからMicrosoftTeamsに変更になる予定なので、
Webhookを使った各種ツールの移行が必要。
取り急ぎ、Webhookで何が通知されるのかを調べた。
Request.json
{
"method": "POST",
"url": "https://xxxx.azurewebsites.net/api/xxxx",
"originalUrl": "https://xxxx.azurewebsites.net/api/xxxx",
"headers": {
"accept": "application/json",
"authorization": "HMAC xxxx",
"connection": "Keep-Alive",
"content-length": "1702",
"content-type": "application/json; charset=utf-8",
"expect": "100-continue",
"host": "xxxx.azurewebsites.net",
"max-forwards": "9",
"referer": "https://teams.microsoft.com/",
"x-ms-session-id": "Legacy-Operation-Id-xxxx",
"x-ms-request-id": "xxxx",
"x-waws-unencoded-url": "/api/xxxx",
"client-ip": "10.0.32.4:52027",
"x-arr-log-id": "xxxx",
"x-site-deployment-id": "xxxx",
"was-default-hostname": "xxxx.azurewebsites.net",
"x-original-url": "/api/xxxx",
"x-forwarded-for": "xxx.xxx.xxx.xxx:6144",
"x-arr-ssl": "2048|256|C=US, O=Microsoft Corporation, CN=Microsoft RSA TLS CA 01|CN=*.azurewebsites.net",
"x-forwarded-proto": "https",
"x-appservice-proto": "https",
"x-forwarded-tlsversion": "1.2",
"disguised-host": "xxxx.azurewebsites.net"
},
"query": {
"code": "xxxx"
},
"params": {},
"body": {
"type": "message",
"id": "162390053xxxx",
"timestamp": "2021-06-17T03:28:58.2669262Z",
"localTimestamp": "2021-06-17T12:28:58.2669262+09:00",
"serviceUrl": "https://smba.trafficmanager.net/apac/",
"channelId": "msteams",
"from": {
"id": "xxxx(AzureADの送信者IDか?)",
"name": "xxxx(送信者の名前)",
"aadObjectId": "xxxx"
},
"conversation": {
"isGroup": true,
"id": "xxxx(チームのIDか?)@thread.tacv2;messageid=162390004xxxx",
"name": null,
"conversationType": "channel",
"tenantId": "xxxx"
},
"recipient": null,
"textFormat": "plain",
"attachmentLayout": null,
"membersAdded": [],
"membersRemoved": [],
"topicName": null,
"historyDisclosed": null,
"locale": "ja-JP",
"text": "<at>myFirstWebhook(Webhook名)</at> Hello, dump message.\n",
"speak": null,
"inputHint": null,
"summary": null,
"suggestedActions": null,
"attachments": [
{
"contentType": "text/html",
"contentUrl": null,
"content": "<div><div><span itemscope=\"\" itemtype=\"http://schema.skype.com/Mention\" itemid=\"0\">myFirstWebhook</span> Hello, dump message.</div>\n</div>",
"name": null,
"thumbnailUrl": null
}
],
"entities": [
{
"type": "clientInfo",
"locale": "ja-JP",
"country": "JP",
"platform": "Mac",
"timezone": "Asia/Tokyo"
}
],
"channelData": {
"teamsChannelId": "xxxx",
"teamsTeamId": "xxxx",
"channel": {
"id": "xxxx"
},
"team": {
"id": "xxxx"
},
"tenant": {
"id": "xxxx"
}
},
"action": null,
"replyToId": null,
"value": null,
"name": null,
"relatesTo": null,
"code": null,
"localTimezone": "Asia/Tokyo"
},
"rawBody": "...上と同じ..."
}
Outgoing Webhook
https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-outgoing-webhook
Incoming Webhook
https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook