I am building a bot that will answer a question asked in a slack App.
I want to configure a followup question
Note: Yes and No are radio buttons
eg.
User: What is the event date?
Bot: 22nd Feb, 2023
(after the answer bot will trigger followup question with radio buttons)
Bot: Does this answer your query?
- Yes
- No
Here's my code
import asyncio
from slack_bolt.adapter.socket_mode.async_handler import AsyncSocketModeHandler
from slack_bolt.async_app import AsyncApp
from slack_sdk import WebClient
client = WebClient(token=SLACK_BOT_TOKEN)
app = AsyncApp(token=SLACK_BOT_TOKEN)
# This event will be executed when User sends the message
@app.message('')
async def in_message(say, message):
if 'event' in message['text']:
response = '22nd Feb, 2023'
block = []
await say(text=response, blocks=block)
I also tried appending the followup message in the response and update it on ACK but updating doesn't handle the formatting, it treats the message as plain text.
The following code should work:
@app.message('')
async def in_message(say, message):
if 'event' in message['text']:
response = '22nd Feb, 2023'
block = [
{
"type": "input",
"element": {
"type": "radio_buttons",
"options": [
{
"text": {
"type": "plain_text",
"text": "Yes",
"emoji": True
},
"value": "value-0"
},
{
"text": {
"type": "plain_text",
"text": "No",
"emoji": True
},
"value": "value-1"
}
],
"action_id": "radio_buttons-action"
},
"label": {
"type": "plain_text",
"text": "Does this answer your query?",
"emoji": True
}
}
]
await say(text = response)
await say(blocks = block)
else:
return