You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Teams中发送带查询参数的活动提要通知?

解决Teams活动提要通知传递查询参数的问题

直接在entityUrl的value后附加查询参数的方式不可行,因为Graph API处理entityUrl类型的topic时,只会解析URL对应的实体信息,不会保留额外的查询参数。以下是两种可行的实现方式:

方式一:通过templateParameters传递自定义参数

把需要的参数添加到templateParameters数组中,应用可以从通知的payload里读取这些参数。修改后的请求体如下:

POST https://graph.microsoft.com/v1.0/users/{user id}/teamwork/sendActivityNotification
Content-Type: application/json
{
    "topic": {
        "source": "entityUrl",
        "value": "https://graph.microsoft.com/v1.0/users/{user id}/teamwork/installedApps/{installation id}"
    },
    "activityType": "taskCreated",
    "previewText": {
        "content": "New Task Created"
    },
    "templateParameters": [
        {
            "name": "taskId",
            "value": "Task 12322"
        },
        {
            "name": "hoge",
            "value": "123"
        }
    ]
}

在TeamsFx SDK的通知处理逻辑中,你可以通过上下文对象获取templateParameters里的参数,比如在Bot的消息处理函数中,从turnContext.Activity.Value.TemplateParameters(根据使用的SDK语言调整)中提取hoge的值。

方式二:用deeplink传递跳转参数

如果需要用户点击通知后跳转到带参数的应用页面,可以在请求中添加deeplink字段,把带查询参数的页面链接放在这里:

POST https://graph.microsoft.com/v1.0/users/{user id}/teamwork/sendActivityNotification
Content-Type: application/json
{
    "topic": {
        "source": "entityUrl",
        "value": "https://graph.microsoft.com/v1.0/users/{user id}/teamwork/installedApps/{installation id}"
    },
    "activityType": "taskCreated",
    "previewText": {
        "content": "New Task Created"
    },
    "templateParameters": [
        {
            "name": "taskId",
            "value": "Task 12322"
        }
    ],
    "deeplink": "https://your-app-domain.com/target-page?hoge=123"
}

用户点击通知时会直接跳转到这个带参数的链接,应用可以通过页面的查询参数获取hoge=123。

内容的提问来源于stack exchange,提问作者Nakayama Naoto

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 07:35:25