-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: add Telegram webhook notification support #9825
Conversation
👷 Deploy request for prefect-docs-preview pending review.Visit the deploys page to approve it
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for contributing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! The implementation looks solid! Most of my comments involve making the generated form for this block more intuitive for users. Let me know if you have any questions!
chat_id: str = Field( | ||
description=( | ||
"Identify the users you want your bot to deliver your notifications to. You" | ||
" must specify at least 1 chat_id. If you do not specify a chat_id, the" | ||
" notification script will attempt to detect the bot owner's (you) chat_id" | ||
" and use that." | ||
), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the Apprise docs, this looks like it should be a list of strings. Adding a couple of other fields will also make the generated field easier to understand.
chat_id: str = Field( | |
description=( | |
"Identify the users you want your bot to deliver your notifications to. You" | |
" must specify at least 1 chat_id. If you do not specify a chat_id, the" | |
" notification script will attempt to detect the bot owner's (you) chat_id" | |
" and use that." | |
), | |
) | |
chat_ids: Optional[List[str]] = Field( | |
default=None, | |
title="Chat IDs", | |
description=( | |
"The chat IDs of the users you want to deliver your notifications to. " | |
"If no IDs are provided, the block will attempt to detect the bot " | |
"owner's chat_id and use that." | |
), | |
example=["1622956968"], | |
) |
preview: Optional[Literal["yes", "no"]] = Field( | ||
default=None, | ||
description=( | ||
"A yes/no flag allowing you to display webpage previews of your post. By" | ||
" default this is set to no." | ||
), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preview: Optional[Literal["yes", "no"]] = Field( | |
default=None, | |
description=( | |
"A yes/no flag allowing you to display webpage previews of your post. By" | |
" default this is set to no." | |
), | |
) | |
preview: bool = Field( | |
default=False, | |
description=( | |
"Whether to display webpage previews of your post." | |
), | |
) |
silent: Optional[Literal["yes", "no"]] = Field( | ||
default=None, | ||
description=( | ||
"A yes/no flag allowing you to send the notification in a silent fashion." | ||
" By default this is set to no." | ||
), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bool
typed field will render nicely in the UI.
silent: Optional[Literal["yes", "no"]] = Field( | |
default=None, | |
description=( | |
"A yes/no flag allowing you to send the notification in a silent fashion." | |
" By default this is set to no." | |
), | |
) | |
silent: bool = Field( | |
default=False, | |
description=( | |
"Whether to send the notification silently." | |
), | |
) |
), | ||
) | ||
|
||
topic_id: Optional[SecretStr] = Field( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a sensitive value? It doesn't seem like this needs to be a SecretStr
and instead could be a str
.
include_image: bool = Field( | ||
default=False, | ||
description=( | ||
"You can optionally append the argument of ?image=Yes to the end of your" | ||
" URL to have a Telegram message generated before the actual notice which" | ||
" uploads the image associated with it. Due to the services limitations," | ||
" Telegram doesn't allow you to post an image inline with a text message." | ||
" But you can send a message that just contains an image. If this flag is" | ||
" set to true, apprise will send an image notification followed by the" | ||
" notice itself. Since receiving 2 messages for every 1 notice could be" | ||
" annoying to some, this has been made an option that defaults to being" | ||
" disabled." | ||
), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose we leave this field off for now since Prefect doesn't currently handle images in notifications.
NotifyTelegram( | ||
bot_token=self.bot_token.get_secret_value(), | ||
targets=self.chat_id, | ||
include_image=self.include_image, | ||
silent=self.silent, | ||
preview=self.preview, | ||
topic=self.topic_id, | ||
detect_owner=self.detect_owner, | ||
).url() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to include the format
kwarg as well to allow different formatting styles.
Co-authored-by: Alexander Streed <desertaxle@users.noreply.github.com>
This pull request is stale because it has been open 60 days with no activity. To keep this pull request open remove stale label or comment. |
This pull request was closed because it has been stale for 14 days with no activity. If this pull request is important or you have more to add feel free to re-open it. |
@mujahidfa @desertaxle Is there any update on this? Expected anytime soon? |
Ah that's a shame |
UP! |
Oh, come on guys! This PR wasn't merged only because of descriptions? |
UP!!! I'd like to understand why this feature hasn't been merged yet? |
Adds a TelegramWebhook notification block using the AbstractAppriseNotificationBlock.
Closes #9408.
Example
Result:
Checklist
<link to issue>
"fix
,feature
,enhancement
,docs
.