问题描述
我正在使用 slack_bolt 并尝试根据块元素中的 static_select 做出不同的响应。如何从 selected_option 打印值?
块是这样的
{
"type": "section","text": {
"type": "mrkdwn","text": "Pick an item from the dropdown list"
},"accessory": {
"type": "static_select","placeholder": {
"type": "plain_text","text": "Select an item","emoji": True
},"options": [
{
"text": {
"type": "plain_text","text": "value-0","emoji": True
},"value": "value-0"
},....
在这种情况下,我选择一个选项后如何打印我选择的值(“value-0”)?
我需要使用哪些变量?带吹气功能
@app.message("hello")
def show_event(event,say):
say(
blocks=blocks,text="Pick a date for me to remind you"
)
@app.action("select_action")
def handle_some_action(ack,body,logger,say):
ack()
logger.info(body)
say(***"the variable to return selected value"***)
解决方法
您需要在静态选择块中添加“block_id”和“action_id”。
然后你可以访问它:
state.values['block_id']['action_id'].value
您可以使用 Block Kit Builder 进行实时测试。
检查操作预览标签以查看响应负载。