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 Kit UI componen
(
self,
*,
text: Optional[str] = None,
attachments: Optional[List[Union[Dict[str, any], Attachment]]] = None,
blocks: Optional[List[Union[Dict[str, any], Block]]] = None,
response_type: Optional[str] = None,
headers: Optional[Dict[str, str]] = None,
)
| 37 | self.default_headers = default_headers if default_headers else {} |
| 38 | |
| 39 | async def send( |
| 40 | self, |
| 41 | *, |
| 42 | text: Optional[str] = None, |
| 43 | attachments: Optional[List[Union[Dict[str, any], Attachment]]] = None, |
| 44 | blocks: Optional[List[Union[Dict[str, any], Block]]] = None, |
| 45 | response_type: Optional[str] = None, |
| 46 | headers: Optional[Dict[str, str]] = None, |
| 47 | ) -> WebhookResponse: |
| 48 | """Performs a Slack API request and returns the result. |
| 49 | |
| 50 | Args: |
| 51 | text: The text message (even when having blocks, setting this as well is recommended as it works as fallback) |
| 52 | attachments: A collection of attachments |
| 53 | blocks: A collection of Block Kit UI components |
| 54 | response_type: The type of message (either 'in_channel' or 'ephemeral') |
| 55 | headers: Request headers to append only for this request |
| 56 | Returns: |
| 57 | Webhook response |
| 58 | """ |
| 59 | return await self.send_dict( |
| 60 | body={ |
| 61 | "text": text, |
| 62 | "attachments": attachments, |
| 63 | "blocks": blocks, |
| 64 | "response_type": response_type, |
| 65 | }, |
| 66 | headers=headers, |
| 67 | ) |
| 68 | |
| 69 | async def send_dict(self, body: Dict[str, any], headers: Optional[Dict[str, str]] = None) -> WebhookResponse: |
| 70 | return await self._perform_http_request( |