2

I am working with slack_bolt and trying to make different responses according to static_select in block element. How to print the value from selected_option?

the block is like this

        {
            "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"
                    }, ....

In this case, how can I print the value("value-0") I selected after I select one option?

What variables do I need to use? with blow function

@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"***)
Solsupungi
  • 29
  • 2

1 Answers1

2

You need to add 'block_id' & 'action_id' in your static select block.
And then you can access it as:
state.values['block_id']['action_id'].value

You can use Block Kit Builder to test it real time.
Check the Action Preview tab to see the response payload. Block Kit Builder

Suyash Gaur
  • 2,481
  • 2
  • 9
  • 22
  • 1
    but when I use the value you mentioned, I couldn't get result I expect. Therefore, I use "body['state']['values']['actionblock789']['select_action']['selected_option']['value']" The keys I have got from your comment is how to use Action preview and adding block_id' & 'action_id Thank you. – Solsupungi Jul 30 '21 at 02:58