Slack Actions API 未发送整个负载
Slack Actions API not sending entire payload
我正在使用 slack Bolt API 构建一个 slack 应用程序,我想在单击主页上的按钮时从我的应用程序主页打开模式。
这是连接到按钮的动作侦听器的相关位:
app.action("follow-users-button", async ({ ack, payload, client }) => {
await ack();
console.log("app_home opening keyusermodal");
// await block_actions.unfollowKeyuser(action);
console.log("payload = " + JSON.stringify(payload));
await client.views.open({
trigger_id: payload.trigger_id,
这是我点击该按钮后在终端上看到的内容:
payload = {"action_id":"follow-users-button","block_id":"2JW","text":{"type":"plain_text","text":"Users","emoji":true},"value":"click_me_123","type":"button","action_ts":"1642280065.631917"}
[ERROR] bolt-app missing required field: trigger_id
JSON有动作payload。
但是,根据 Slack 文档,此有效负载应该大得多。这是来自 Slack 的 Block Kit Builder 的示例负载:
{
"type": "block_actions",
"user": {
"id": "U02NF0A8D9T",
"username": "person",
"name": "person",
"team_id": "T02NTJ0UDP3"
},
"api_app_id": "A02",
"token": "Shh_its_a_seekrit",
"container": {
"type": "message",
"text": "The contents of the original message where the action originated"
},
"trigger_id": "12466734323.1395872398",
"team": {
"id": "T02NTJ0UDK3",
"domain": "4most-r637660"
},
"enterprise": null,
"is_enterprise_install": false,
"state": {
"values": {}
},
"response_url": "https://www.postresponsestome.com/T123567/1509734234",
"actions": [
{
"type": "button",
"block_id": "QdL",
"action_id": "button-action",
"text": {
"type": "plain_text",
"text": "Click Me",
"emoji": true
},
"value": "click_me_123",
"action_ts": "1642279809.506518"
}
]
}
如您所见,我只在我的负载中接收到动作元素。剩下的在哪里?为什么还不过来?我需要 trigger_id 来打开一个模式(没有它会导致错误),并且获得 user_id 之类的东西对我的应用程序非常有帮助。
提前致谢!
使用 Bolt JS 框架时,解析操作负载以获取触发器 ID 的预期方式是 body.trigger_id
。
我正在使用 slack Bolt API 构建一个 slack 应用程序,我想在单击主页上的按钮时从我的应用程序主页打开模式。
这是连接到按钮的动作侦听器的相关位:
app.action("follow-users-button", async ({ ack, payload, client }) => {
await ack();
console.log("app_home opening keyusermodal");
// await block_actions.unfollowKeyuser(action);
console.log("payload = " + JSON.stringify(payload));
await client.views.open({
trigger_id: payload.trigger_id,
这是我点击该按钮后在终端上看到的内容:
payload = {"action_id":"follow-users-button","block_id":"2JW","text":{"type":"plain_text","text":"Users","emoji":true},"value":"click_me_123","type":"button","action_ts":"1642280065.631917"}
[ERROR] bolt-app missing required field: trigger_id
JSON有动作payload。
但是,根据 Slack 文档,此有效负载应该大得多。这是来自 Slack 的 Block Kit Builder 的示例负载:
{
"type": "block_actions",
"user": {
"id": "U02NF0A8D9T",
"username": "person",
"name": "person",
"team_id": "T02NTJ0UDP3"
},
"api_app_id": "A02",
"token": "Shh_its_a_seekrit",
"container": {
"type": "message",
"text": "The contents of the original message where the action originated"
},
"trigger_id": "12466734323.1395872398",
"team": {
"id": "T02NTJ0UDK3",
"domain": "4most-r637660"
},
"enterprise": null,
"is_enterprise_install": false,
"state": {
"values": {}
},
"response_url": "https://www.postresponsestome.com/T123567/1509734234",
"actions": [
{
"type": "button",
"block_id": "QdL",
"action_id": "button-action",
"text": {
"type": "plain_text",
"text": "Click Me",
"emoji": true
},
"value": "click_me_123",
"action_ts": "1642279809.506518"
}
]
}
如您所见,我只在我的负载中接收到动作元素。剩下的在哪里?为什么还不过来?我需要 trigger_id 来打开一个模式(没有它会导致错误),并且获得 user_id 之类的东西对我的应用程序非常有帮助。
提前致谢!
使用 Bolt JS 框架时,解析操作负载以获取触发器 ID 的预期方式是 body.trigger_id
。