Performs a Slack API request and returns the result. Args: text: The text message (even when having blocks, setting this as well is recommended as it works as fallback) attachments: A collection of attachments blocks: A collection of Block
(
self,
*,
text: Optional[str] = None,
attachments: Optional[Sequence[Union[Dict[str, Any], Attachment]]] = None,
blocks: Optional[Sequence[Union[Dict[str, Any], Block]]] = None,
response_type: Optional[str] = None,
replace_original: Optional[bool] = None,
delete_original: Optional[bool] = None,
unfurl_links: Optional[bool] = None,
unfurl_media: Optional[bool] = None,
metadata: Optional[Dict[str, Any]] = None,
headers: Optional[Dict[str, str]] = None,
)
| 76 | self.proxy = env_variable |
| 77 | |
| 78 | def send( |
| 79 | self, |
| 80 | *, |
| 81 | text: Optional[str] = None, |
| 82 | attachments: Optional[Sequence[Union[Dict[str, Any], Attachment]]] = None, |
| 83 | blocks: Optional[Sequence[Union[Dict[str, Any], Block]]] = None, |
| 84 | response_type: Optional[str] = None, |
| 85 | replace_original: Optional[bool] = None, |
| 86 | delete_original: Optional[bool] = None, |
| 87 | unfurl_links: Optional[bool] = None, |
| 88 | unfurl_media: Optional[bool] = None, |
| 89 | metadata: Optional[Dict[str, Any]] = None, |
| 90 | headers: Optional[Dict[str, str]] = None, |
| 91 | ) -> WebhookResponse: |
| 92 | """Performs a Slack API request and returns the result. |
| 93 | |
| 94 | Args: |
| 95 | text: The text message |
| 96 | (even when having blocks, setting this as well is recommended as it works as fallback) |
| 97 | attachments: A collection of attachments |
| 98 | blocks: A collection of Block Kit UI components |
| 99 | response_type: The type of message (either 'in_channel' or 'ephemeral') |
| 100 | replace_original: True if you use this option for response_url requests |
| 101 | delete_original: True if you use this option for response_url requests |
| 102 | unfurl_links: Option to indicate whether text url should unfurl |
| 103 | unfurl_media: Option to indicate whether media url should unfurl |
| 104 | metadata: Metadata attached to the message |
| 105 | headers: Request headers to append only for this request |
| 106 | |
| 107 | Returns: |
| 108 | Webhook response |
| 109 | """ |
| 110 | return self.send_dict( |
| 111 | # It's fine to have None value elements here |
| 112 | # because _build_body() filters them out when constructing the actual body data |
| 113 | body={ |
| 114 | "text": text, |
| 115 | "attachments": attachments, |
| 116 | "blocks": blocks, |
| 117 | "response_type": response_type, |
| 118 | "replace_original": replace_original, |
| 119 | "delete_original": delete_original, |
| 120 | "unfurl_links": unfurl_links, |
| 121 | "unfurl_media": unfurl_media, |
| 122 | "metadata": metadata, |
| 123 | }, |
| 124 | headers=headers, |
| 125 | ) |
| 126 | |
| 127 | def send_dict(self, body: Dict[str, Any], headers: Optional[Dict[str, str]] = None) -> WebhookResponse: |
| 128 | """Performs a Slack API request and returns the result. |