question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add replace_original/delete_original to WebhookClient (async/sync)

See original GitHub issue

Add 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:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Greenwolfcommented, Jan 23, 2021

+1 for adding this functionality, it would be really useful!

1reaction
alextriacacommented, Jan 22, 2021

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found