question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Block Actions Interactions Payload Inquiry

See original GitHub issue

Hello,

I’m experimenting with the Slack Bolt Python API and its block actions interaction. In the function decorator, what is the value or string that the decorator should attempt to match?

@app.block_action("________")

Reproducible in:

The slack_bolt version

slack-bolt==1.4.4
slack-sdk==3.4.2
slackclient==2.9.3

Python runtime version

Python 3.8.5

OS info

Nah

Steps to reproduce:

Source Code

app = AsyncApp(token="...")

blocks = [
{
            "type": "actions",
            "elements": [
                {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "emoji": True,
                        "text": "Approve"
                    },
                    "style": "primary",
                    "value": "click_me_1"
                },
                {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "emoji": True,
                        "text": "Deny"
                    },
                    "style": "danger",
                    "value": "click_me_2"
                }
            ]
        }]

@app.event("app_mention")
async def app_mention(client, event, say):
    channel = event['channel']
    ts = event['ts']
    await client.chat_postMessage(
                    channel=channel,
                    thread_ts=ts,
                    blocks=blocks
                )

@app.block_action("________")                        <-- What should this decorator check for?
async def deny(ack, respond):
    await ack()
    await respond("Deny")

async def main():
    handler = AsyncSocketModeHandler(app, "...")
    await handler.start_async()

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

Expected result:

Slack Bolt API to register the listener and handle the block_action request via apt listener

Actual result:

Logs:

DEBUG:slack_bolt.AsyncApp:Checking listener: app_mention ...
DEBUG:slack_bolt.AsyncApp:Checking listener: deny ...
WARNING:slack_bolt.AsyncApp:Unhandled request ({'type': 'block_actions', ...

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

Thanks all,

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
seratchcommented, May 11, 2021

@DataGreed If you don’t set action_id for a block element, a random value would be set. We highly recommend setting your own unique value for easily handling interactivity events.

1reaction
CSP197commented, Apr 7, 2021

The docs above really helped! Please feel free to close this issue 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reference: block_actions payloads - Slack API
A block_actions payload is received when a user interacts with a Block Kit interactive component. Read our guide to handling payloads from user...
Read more >
Handling user interaction in your Slack apps
This payload is a bundle of information that explains the context of the user action, giving the app enough to construct a coherent...
Read more >
Bolt Basics | Slack SDK for Java
Interactive Components: Responds to user actions (e.g., click a button, choose an item from select menus, radio buttons, etc.) in blocks. These events...
Read more >
Messaging - Messenger Platform - Meta for Developers
Users have the option to block or mute a conversation with a business at any time. Here are examples of the user actions...
Read more >
Customizing a User Interface using Block Kit - YouTube
Connect with Salesforce Developers:Website: https://developer.salesforce.com/Facebook: https://facebook.com/salesforcedevs/Twitter: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found