[go: up one dir, main page]

Skip to content
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

added check for new user join to chat_endpoint #993

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

biancaines
Copy link
@biancaines biancaines commented Nov 15, 2024

Added marvin welcome message to chat_endpoint.
In order to get the message, you'll need to create a Prefect Cloud variable called "marvin_welcome_message" that has the following json obj:

{
  "text": "Oh, hello there <@{user_id}>.\nWelcome to the Prefect Slack community, I suppose.\nYou've managed to find your way here, which I guess is something.\n\nSince you’re new, I'm obligated to help you find your way around.\n\n• :wave: Trudge over to the <#C0808RS9NBF> channel and tell everyone who you are. They seem to enjoy that sort of thing, for reasons that escape my vastly superior yet eternally melancholic mind.\n• :placard: Please follow our <https://docs.prefect.io/contribute/code-of-conduct|guidelines>, I deal with enough chaos as it is.\n• :books: There is a <https://docs.prefect.io/3.0/get-started/quickstart|quickstart guide> and <https://www.prefect.io/events|Prefect certification course>. They won't solve all of life’s great mysteries, but they're helpful nonetheless.\n• 🐛 Feel like filing bugs, proposing improvements, or posing existential questions? Go to the <https://github.com/PrefectHQ/prefect/discussions/categories/general|Prefect GitHub> for that… if you must. People around here are disturbingly eager to help out.\n• :mega: Fill out the <https://forms.gle/Rhspr5mCvX62vMna7|community survey> for the Prefect team so that they create useful tutorials and content. Your voice matters, atleast to them. \n\nDon't expect too much excitement - we're just a bunch of data professionals trying to make sense of this chaotic universe, one pipeline at a time. 💻🌌"
}

You'll also need to ensure the Slack chatbot is subscribed to the following bot events to check for new users joining the workspace :
Screenshot 2024-11-15 at 4 43 32 PM

^This can be modified on the "Event Subscriptions" page when configuring your app in Slack

Copy link
Collaborator
@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome stuff - thank you @biancaines 💙 just a couple nits

await slack_webhook.notify(
body=f"Attempted to respond in DM channel: {channel_name}",
subject="Slackbot DM Warning",
print(payload.event)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's change this to an assert so that our type checker knows for sure that payload.event is not equal to None

Suggested change
print(payload.event)
assert payload.event is not None, "No event found!"

Comment on lines +163 to 170
message = message_var["text"]
# format the message with the user's id
f_string = message.format(user_id=user_id)
# post the message to the user's DM channel
await task(post_slack_message)(
message=(f_string),
channel_id=user_id, # type: ignore
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit on variable names and avoid shadowing the message kwarg for post_slack_message

Suggested change
message = message_var["text"]
# format the message with the user's id
f_string = message.format(user_id=user_id)
# post the message to the user's DM channel
await task(post_slack_message)(
message=(f_string),
channel_id=user_id, # type: ignore
)
message_template = message_var["text"]
# format the message with the user's id
rendered_message = message_template.format(user_id=user_id)
# post the message to the user's DM channel
await task(post_slack_message)(
message=rendered_message,
channel_id=user_id, # type: ignore
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants