slack.actions - Actions

class slack.actions.Action(raw_action: MutableMapping[KT, VT], verification_token: Optional[str] = None, team_id: Optional[str] = None)[source]

MutableMapping representing a response to an interactive message, a dialog submission or a message action.

Parameters:
  • raw_action – Decoded body of the HTTP request
  • verification_token – Slack verification token used to verify the request came from slack
  • team_id – Verify the event is for the correct team
Raises:

slack.exceptions.FailedVerification – when verification_token or team_id does not match the incoming event’s

class slack.actions.Router[source]

When creating a slack applications you can only set one action url. This provide a routing mechanism for the incoming actions, based on their callback_id and the action name, to one or more handlers.

dispatch(action: slack.actions.Action) → Any[source]

Yields handlers matching the incoming slack.actions.Action callback_id or action_id.

Parameters:actionslack.actions.Action
Yields:handler
register(callback_id: str, handler: Any, name: str = '*') → None[source]

Register a new handler for a specific slack.actions.Action callback_id. Optional routing based on the action name too.

The name argument is useful for actions of type interactive_message to provide a different handler for each individual action.

Parameters:
  • callback_id – Callback_id the handler is interested in
  • handler – Callback
  • name – Name of the action (optional).
register_block_action(block_id: str, handler: Any, action_id: str = '*') → None[source]

Register a new handler for a block-based slack.actions.Action. Internally uses the base register method for actual registration.

Optionally provides routing based on a specific action_id if present.

Parameters:
  • block_id – The action block_id the handler is interested in
  • handler – Callback
  • action_id – specific action_id for the action (optional)
register_dialog_submission(callback_id: str, handler: Any)[source]

Registers a new handler for a dialog_submission slack.actions.Action.

Internally calls the base register method for actual registration.

Parameters:
  • callback_id – Callback_id the handler is interested in
  • handler – Callback
register_interactive_message(callback_id: str, handler: Any, name: str = '*') → None[source]

Register a new handler for a specific slack.actions.Action callback_id. Optional routing based on the action name too.

The name argument is useful for actions of type interactive_message to provide a different handler for each individual action.

Internally calls the base register method for actual registration.

Parameters:
  • callback_id – Callback_id the handler is interested in
  • handler – Callback
  • name – Name of the action (optional).
exception slack.actions.UnknownActionType(action: slack.actions.Action)[source]

Raised for incoming action with unknown type

action

The incoming action