发送不同类型的ActivityFeed
上一篇文章講到了如何使用最新的Graph API來給一個(gè)用戶發(fā)送一個(gè)簡單的 Activity Feed。我們這篇文章來詳細(xì)講一下發(fā)送三種不同類型的消息。
發(fā)送 Chat 相關(guān)的 Activity Notification
API 為?POST https://graph.microsoft.com/beta/chats/{chat-id}/sendActivityNotification
http請求的內(nèi)容為:
{"topic": {"source": "entityUrl","value": "https://graph.microsoft.com/beta/chats/{chat-id}"},"activityType": "taskCreated","previewText": {"content": "New Task Created"},"recipient": {"@odata.type": "microsoft.graph.aadUserNotificationRecipient","userId": "569363e2-1111-2222-3333-16f245c5d66a"},"templateParameters": [{"name": "taskId","value": "Task 12322"}] }其中?activityType?和?templateParameters?我已經(jīng)在前面一篇文章中介紹過,previewText?從名字上也很容易理解,是推送的消息的文本內(nèi)容,recipient?是接受推送消息的用戶的 id 信息。
這里比較關(guān)鍵的是?topic,這個(gè)指明了這個(gè)推送的消息是針對哪個(gè)聊天 (chat) 或者哪個(gè) 聊天消息 (chatMessage) 的,如果是針對 chat 的,那么?topic?里的?value?就是?https://graph.microsoft.com/beta/chats/{chat-id}?這種格式,如果是 chatMessage,格式就是?https://graph.microsoft.com/beta/chats/{chat-id}/messages/{message-id}
大家可能會(huì)問,如何獲得這個(gè) chat id 和 message id 呢,這兩個(gè)可以在發(fā)送 message 是返回,或者也可以通過調(diào)用 graph api 來獲取。
發(fā)送 Team 相關(guān)的 Activity Notification
API 為?POST https://graph.microsoft.com/beta/teams/{teamId}/sendActivityNotification
http請求的內(nèi)容和之前的很像:
{"topic": {"source": "entityUrl","value": "https://graph.microsoft.com/beta/teams/{team-id}"},"activityType": "pendingFinanceApprovalRequests","previewText": {"content": "Internal spending team has a pending finance approval requests"},"recipient": {"@odata.type": "microsoft.graph.aadUserNotificationRecipient","userId": "569363e2-1111-2222-3333-16f245c5d66a"},"templateParameters": [{"name": "pendingRequestCount","value": "5"}] }它支持的 entity url 有好幾種:
- team,格式為?https://graph.microsoft.com/beta/teams/{team-id}
- channel,格式為?https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id}
- chatMesage,格式為?https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id}/messages/{message-id}
- teamsTab,格式為?https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id}/tabs/{tab-id}
發(fā)送 User 相關(guān)的 Activity Notification
API 為?POST https://graph.microsoft.com/beta/users/{userId}/teamwork/sendActivityNotification
http請求的內(nèi)容和之前的很像:
{"topic": {"source": "entityUrl","value": "https://graph.microsoft.com/beta/users/{user-id}/teamwork/installedApps/{installation-id}"},"activityType": "taskCreated","previewText": {"content": "New Task Created"},"templateParameters": [{"name": "taskId","value": "Task 342342"}] }它支持的 entity url 有兩種:
- teamsAppInstallation,格式為?https://graph.microsoft.com/beta/users/{user-id}/teamwork/installedApps/{installation-id}
- teamsCatalogApp,格式為?https://graph.microsoft.com/beta/appCatalogs/teamsApps/{app-id}
總結(jié)
以上是生活随笔為你收集整理的发送不同类型的ActivityFeed的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微信微信人工客服电话/微信客服怎么正确拨
- 下一篇: 发送ActivityFeed的隐藏功能