I created the following BLOCK but cannot figure out how to use it within a /Command. It shows fine when used within the ack({...}) but does nothing when I use say({...}). The only other way is the client.dialog with type: modal but that is not what I want.
I simple need to know how to respond using my JSON block kit code. Any help is appreciated.
{
"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"
}
}
]
}
]
}
EDIT could this work?
client.chat_postMessage(
channel=event['channel'],
blocks=[
{...})
EDIT
@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=[
{ ... }])