Skip to content

operator

hook

__all__ = ['SlackHook'] module-attribute

SlackHook

Bases: BaseHook

Hook for interacting with Slack API.

__init__() -> None

Initializes the SlackHook.

get_headers() -> Dict[str, str]

Gets the headers for the Slack API requests.

Returns:

Type Description
Dict[str, str]

Dict[str, str]: The headers including the authorization token.

react(channel: str, reaction: str, ts: str) -> Dict[str, Any]

Adds a reaction to a Slack message.

Parameters:

Name Type Description Default
channel str

The channel of the message.

required
reaction str

The reaction to add.

required
ts str

The timestamp of the message.

required

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: The response from the Slack API.

send(channel: Optional[str] = None, message: Optional[str] = None, blocks: Optional[List[Dict[str, Any]]] = None, thread_ts: Optional[str] = None, reply_broadcast: bool = False, attachments: Optional[List[Dict[str, Any]]] = None, response_url: Optional[str] = None, response_type: Optional[str] = None, replace_original: Optional[bool] = None) -> Dict[str, Any]

Sends a message to a Slack channel or a response URL.

Parameters:

Name Type Description Default
channel Optional[str]

The channel to send the message to.

None
message Optional[str]

The message text.

None
blocks Optional[List[Dict[str, Any]]]

The message blocks.

None
thread_ts Optional[str]

The timestamp of the thread to reply to.

None
reply_broadcast bool

Whether to broadcast the reply to the channel.

False
attachments Optional[List[Dict[str, Any]]]

The message attachments.

None
response_url Optional[str]

The response URL to send the message to.

None
response_type Optional[str]

The response type.

None
replace_original Optional[bool]

Whether to replace the original message.

None

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: The response from the Slack API.

set_token(token: str) -> None

Sets the authorization token for the Slack API.

Parameters:

Name Type Description Default
token str

The authorization token.

required