我正在尝试打开一个松弛模式。 以下是我的JSON。将字段放在附件下时,不会传递该值。我在该字段旁边遇到错误。我做错什么了吗?当我将其放入输入类型块中时,同样的事情也起作用。以下是我使用Slack Block Kit Builder构建的JSON代码。我还添加了action_id
{
"type": "modal",
"title": {
"type": "plain_text",
"text": "My App",
"emoji": true
},
"submit": {
"type": "plain_text",
"text": "Submit",
"emoji": true
},
"close": {
"type": "plain_text",
"text": "Cancel",
"emoji": true
},
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "To"
},
"accessory": {
"type": "static_select",
"action_id": "to_time",
"placeholder": {
"type": "plain_text",
"text": "Select an item",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "8 AM",
"emoji": true
},
"value": "8"
},
{
"text": {
"type": "plain_text",
"text": "9 AM",
"emoji": true
},
"value": "9"
},
{
"text": {
"type": "plain_text",
"text": "10 AM",
"emoji": true
},
"value": "10"
},
{
"text": {
"type": "plain_text",
"text": "11 AM",
"emoji": true
},
"value": "11"
},
{
"text": {
"type": "plain_text",
"text": "12 PM",
"emoji": true
},
"value": "12"
},
{
"text": {
"type": "plain_text",
"text": "1 PM",
"emoji": true
},
"value": "1"
},
{
"text": {
"type": "plain_text",
"text": "2 PM",
"emoji": true
},
"value": "2"
},
{
"text": {
"type": "plain_text",
"text": "3 PM",
"emoji": true
},
"value": "3"
},
{
"text": {
"type": "plain_text",
"text": "4 PM",
"emoji": true
},
"value": "4"
},
{
"text": {
"type": "plain_text",
"text": "5 PM",
"emoji": true
},
"value": "5"
}
]
}
}
]
}
未传递值
答案 0 :(得分:1)
您需要使用views.open
而不是dialog.open
。由于您正在模态中使用块元素,因此建议使用view.open
,希望对您有用。
看起来像您的Webhook URL有问题,您可以再检查一次吗?我尝试过使用您的JSON,它的工作就像一个魅力!
代码:
const data = {
token: authToken,
trigger_id: trigger_id,
view: {
// Json goes here
}
};
const headers = {
Authorization: `Bearer ${authToken}`
}
const response = await axios.post(`${apiUrl}/views.open`, data, { headers });
console.log(response.data);
return response;
对话框:
成功响应: