Add replace_original/delete_original to WebhookClient (async/sync)
See original GitHub issueAdd functionality to allow updating a message when using the WebhookClient by passing replace_original=true
to the API.
Requirements
Currently it is only possible to send a new message using the WebhookClient. The Slack API offers the option to include a boolean replace_original
flag that will then update the original message instead of posting a new message. It would be great if we could add a similar WebClient.chat_update
method to the WebhookClient. Some PoC code of what this could look like:
def chat_update(
self,
*,
text: Optional[str] = None,
attachments: Optional[List[Union[Dict[str, any], Attachment]]] = None,
blocks: Optional[List[Union[Dict[str, any], Block]]] = None,
headers: Optional[Dict[str, str]] = None,
) -> WebhookResponse:
"""Performs a Slack API request and returns the result.
:param text: the text message (even when having blocks, setting this as well is recommended as it works as fallback)
:param attachments: a collection of attachments
:param blocks: a collection of Block Kit UI components
:param headers: request headers to append only for this request
:return: API response
"""
return self.send_dict(
body={
"text": text,
"attachments": attachments,
"blocks": blocks,
"replace_original": True,
},
headers=headers,
)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Webhook Client — Python Slack SDK
To use Incoming Webhooks, just calling WebhookClient(url)#send(payload) method works for you. The call posts a message in a channel associated with the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
+1 for adding this functionality, it would be really useful!
Makes sense. I guess the WebhookClient will only ever be dealing with a single message so treating it as different sounds good. Honestly just adding the
replace_original
flag will clean things up for me so appreciate you taking this on!