我创建了以下 BLOCK,但无法弄清楚如何在 /Command 中使用它。它在 ack({...}) 中使用时显示良好,但在我使用 say({...}) 时什么也不做。唯一的另一种方法是带有 type: modal 的 client.dialog ,但这不是我想要的。
我只需要知道如何使用我的 JSON 块工具包代码进行响应。任何帮助表示赞赏。
{
"attachments": [
{
"blocks": [
{
"type": "context",
"elements": [
{
"type": "plain_text",
"text": user_id + ", this was your question",
"emoji": True
}
]
},
{
"type": "section",
"text": {
"type": "plain_text",
"text": question,
"emoji": True
}
},
{
"type": "context",
"elements": [
{
"type": "plain_text",
"text": "Here's what I found",
"emoji": True
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": answer
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "plain_text",
"text": "Info",
"emoji": True
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "*Author:* " + author
}
]
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "*Book:* " + booktitle
}
]
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "*Page:* " + str(page_num)
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": content
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Was this helpful?"
},
"accessory": {
"type": "static_select",
"placeholder": {
"type": "plain_text",
"text": "please select an answer from the drop-down",
"emoji": True
},
"options": [
{
"text": {
"type": "plain_text",
"text": "*This was spot on*",
"emoji": True
},
"value": "1"
},
{
"text": {
"type": "plain_text",
"text": "*This was somewhat helpful*",
"emoji": True
},
"value": "0"
},
{
"text": {
"type": "plain_text",
"text": "*This was not helpful*",
"emoji": True
},
"value": "-1"
}
],
"action_id": "static_select-action"
}
}
]
}
]
}
编辑这可以工作吗?
client.chat_postMessage(
channel=event['channel'],
blocks=[
{...})
编辑
@app.command("/q")
def q_command(client, event, ack, command):
ack("Gotcha! Let me take a look...")
user_id = event.get("user")
#...
client.chat_postMessage(
channel=event['channel'],
blocks=[
{ ... }])