SOLFIND
Web Lens
Portal home

Listening & responding to shortcuts | Slack Developer Docs

https://docs.slack.dev/tools/bolt-python/concepts/shortcuts/ • 67 KB fetched
Open original page


Listening & responding to shortcuts | Slack Developer Docs python Skip to main content Guides Reference Samples Tools Changelog Dev Program MANAGE APPS * Overview * Community-developed tools * Slack MCP and Skills Plugin * Sandboxes * Deno Slack SDK * Java libraries * JavaScript libraries * Python libraries * Bolt for Python * Creating an app * AI & Agents * Slack API calls * Events * App UI & Interactivity * Acknowledging requests * Listening & responding to shortcuts * Listening & responding to commands * Listening & responding to actions * Opening modals * Updating & pushing views * Listening to views * Listening & responding to select menu options * Publishing views to App Home * Custom Steps * App Configuration * Middleware & Context * Lazy listeners (FaaS) * Adaptors * Authorization & Security * Experiments * Legacy * Tutorials * Reference * 日本語 (日本) * Python Slack SDK * Slack CLI * Slack GitHub Action * * Python libraries * Bolt for Python * App UI & Interactivity * Listening & responding to shortcuts Copy as markdown On this page Listening & responding to shortcuts The shortcut() method supports both global shortcuts and message shortcuts . Shortcuts are invokable entry points to apps. Global shortcuts are available from within search and text composer area in Slack. Message shortcuts are available in the context menus of messages. Your app can use the shortcut() method to listen to incoming shortcut requests. The method requires a callback_id parameter of type str or re.Pattern . Shortcuts must be acknowledged with ack() to inform Slack that your app has received the request. Shortcuts include a trigger_id which an app can use to open a modal that confirms the action the user is taking. When setting up shortcuts within your app configuration, as with other URLs, you'll append /slack/events to your request URL. ⚠️ Note that global shortcuts do not include a channel ID. If your app needs access to a channel ID, you may use a conversations_select element within a modal. Message shortcuts do include a channel ID. Refer to the module document to learn the available listener arguments. # The open_modal shortcut listens to a shortcut with the callback_id "open_modal" @app . shortcut ( "open_modal" ) def open_modal ( ack , shortcut , client ) : # Acknowledge the shortcut request ack ( ) # Call the views_open method using the built-in WebClient client . views_open ( trigger_id = shortcut [ "trigger_id" ] , # A simple view payload for a modal view = { "type" : "modal" , "title" : { "type" : "plain_text" , "text" : "My App" } , "close" : { "type" : "plain_text" , "text" : "Close" } , "blocks" : [ { "type" : "section" , "text" : { "type" : "mrkdwn" , "text" : "About the simplest modal you could conceive of :smile:\n\nMaybe </block-kit/#making-things-interactive|*make the modal interactive*> or </surfaces/modals|*learn more advanced modal use cases*>." } } , { "type" : "context" , "elements" : [ { "type" : "mrkdwn" , "text" : "Psssst this modal was designed using <https://api.slack.com/tools/block-kit-builder|*Block Kit Builder*>" } ] } ] } ) Listening to shortcuts using a constraint object ​ You can use a constraints object to listen to callback_id s, and type s. Constraints in the object can be of type str or re.Pattern . # Your listener will only be called when the callback_id matches 'open_modal' AND the type matches 'message_action' @app . shortcut ( { "callback_id" : "open_modal" , "type" : "message_action" } ) def open_modal ( ack , shortcut , client ) : # Acknowledge the shortcut request ack ( ) # Call the views_open method using one of the built-in WebClients client . views_open ( trigger_id = shortcut [ "trigger_id" ] , view = { "type" : "modal" , "title" : { "type" : "plain_text" , "text" : "My App" } , "close" : { "type" : "plain_text" , "text" : "Close" } , "blocks" : [ { "type" : "section" , "text" : { "type" : "mrkdwn" , "text" : "About the simplest modal you could conceive of :smile:\n\nMaybe </block-kit/#making-things-interactive|*make the modal interactive*> or </surfaces/modals|*learn more advanced modal use cases*>." } } , { "type" : "context" , "elements" : [ { "type" : "mrkdwn" , "text" : "Psssst this modal was designed using <https://api.slack.com/tools/block-kit-builder|*Block Kit Builder*>" } ] } ] } ) Previous Acknowledging requests Next Listening & responding to commands Copy as markdown * Listening to shortcuts using a constraint object . * Tools * Slack CLI * Bolt frameworks * Slack SDKs * Block Kit Builder * Developer program * Code samples & tutorials * LLM? Read llms.txt * All tools Learn * Learning paths * Workshops * Slack certifications * Trailhead * Resource library * All learning resources Community * Slack community * Slack events Resources * Docs * Blog * Slack marketplace * Developer newsletter Manage Apps * Your apps * Status * Privacy * Terms * Cookie Preferences * Support * Changelog * Your Privacy Choices © 2026 Slack Technologies, LLC, a Salesforce company. All rights reserved. Various trademarks held by their respective owners. * * *

Links found on this page

  1. Skip to main content [direct]
  2. Guides [direct]
  3. Reference [direct]
  4. Samples [direct]
  5. Tools [direct]
  6. Changelog [direct]
  7. Dev Program [direct]
  8. MANAGE APPS [direct]
  9. Overview [direct]
  10. Community-developed tools [direct]
  11. Slack MCP and Skills Plugin [direct]
  12. Sandboxes [direct]
  13. Deno Slack SDK [direct]
  14. Java libraries [direct]
  15. JavaScript libraries [direct]
  16. Python libraries [direct]
  17. Creating an app [direct]
  18. AI & Agents [direct]
  19. Slack API calls [direct]
  20. Events [direct]
  21. App UI & Interactivity [direct]
  22. Listening & responding to shortcuts [direct]
  23. Listening & responding to commands [direct]
  24. Listening & responding to actions [direct]
  25. Opening modals [direct]
  26. Updating & pushing views [direct]
  27. Listening to views [direct]
  28. Listening & responding to select menu options [direct]
  29. Publishing views to App Home [direct]
  30. Custom Steps [direct]
  31. App Configuration [direct]
  32. Middleware & Context [direct]
  33. Lazy listeners (FaaS) [direct]
  34. Adaptors [direct]
  35. Authorization & Security [direct]
  36. Experiments [direct]
  37. Legacy [direct]
  38. Tutorials [direct]
  39. Reference [direct]
  40. 日本語 (日本) [direct]
  41. Python Slack SDK [direct]
  42. Slack CLI [direct]
  43. Slack GitHub Action [direct]
  44. global shortcuts [direct]
  45. conversations_select [direct]
  46. the module document [direct]
  47. Block Kit Builder [direct]
  48. Code samples & tutorials [direct]
  49. LLM? Read llms.txt [direct]
  50. Learning paths [direct]
  51. Workshops [direct]
  52. Slack certifications [direct]
  53. Trailhead [direct]
  54. Resource library [direct]
  55. All learning resources [direct]
  56. Slack community [direct]
  57. Slack events [direct]
  58. Blog [direct]
  59. Slack marketplace [direct]
  60. Developer newsletter [direct]
  61. Status [direct]
  62. Privacy [direct]
  63. Terms [direct]
  64. Support [direct]
  65. Your Privacy Choices [direct]