-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
settings: Add initial implementation for custom welcome bot message. #29452
base: main
Are you sure you want to change the base?
Conversation
Hello @zulip/server-bots, @zulip/server-onboarding members, this pull request was labeled with the "area: onboarding", "area: bots" labels, so you may want to check it out! |
fca5af3
to
c7d7fbb
Compare
a4ba94e
to
bbbf746
Compare
5b5992f
to
41d6424
Compare
The CI pipeline is currently failing due to an issue that I've reported in CZO (https://chat.zulip.org/#narrow/stream/9-issues). Once the PR #29474 is merged, it should resolve the CI failures. |
11f057d
to
2b825e7
Compare
3f89199
to
64ab80f
Compare
d50b513
to
b9d34b6
Compare
Thanks! As indicated in the issue, the custom message should be a separate message. |
Also, the field label doesn't match the description in the issue:
|
b9d34b6
to
bc530be
Compare
cd863c2
to
cc732b1
Compare
cc732b1
to
88bfd71
Compare
934a475
to
eb258c2
Compare
eb258c2
to
7187f41
Compare
7187f41
to
19f54ac
Compare
ff83508
to
7d34a1b
Compare
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 keeping the PR updated & sorry for the delay in reviewing 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.
Maybe, we should better name the file as welcome_bot_custom_message
and similar change at other places?
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.
Thank you for the suggestion. I will update the file name to welcome_bot_custom_message
and make similar changes in other relevant places.
zerver/lib/onboarding.py
Outdated
@@ -131,6 +134,35 @@ def send_initial_direct_message(user: UserProfile) -> None: | |||
disable_external_notifications=True, | |||
) | |||
|
|||
custom_welcome_bot_message_string = "" | |||
custom_welcome_bot_message_text = "" |
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 think, _string
and _text
suffix don't create much distinction & are confusing to understand how they differ.
welcome_bot_custom_test_message_content
(or simply welcome_bot_test_message_content
) & welcome_bot_custom_message_content
sounds better?
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'll update the variable names accordingly.
zerver/lib/onboarding.py
Outdated
user.realm.custom_welcome_bot_message_enabled | ||
and user.realm.custom_welcome_bot_message is not None | ||
): | ||
custom_welcome_bot_message_text = user.realm.custom_welcome_bot_message.strip() |
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.
The text stored in database should be stripped before saving.
zerver/lib/onboarding.py
Outdated
custom_welcome_bot_message_text = custom_welcome_bot_message.strip() | ||
elif ( | ||
user.realm.custom_welcome_bot_message_enabled | ||
and user.realm.custom_welcome_bot_message is not None |
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.
We should use assert user.realm.custom_welcome_bot_message is not None
, right ?
zerver/lib/onboarding.py
Outdated
|
||
if custom_welcome_bot_message_text: | ||
custom_welcome_bot_message_string = ( | ||
_( |
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.
This won't get translated properly as it is outside with override_language(user.default_language):
block.
Also, recently we have started using remove_single_newlines()
, we should use that here.
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.
Thank you for the suggestion. However, the quote\n{realm_custom_welcome_bot_message}\n block requires the newlines to maintain the correct formatting. Using remove_single_newlines here would disrupt the intended structure of the message.
zerver/lib/onboarding.py
Outdated
|
||
internal_send_private_message( | ||
get_system_bot(settings.WELCOME_BOT, user.realm_id), | ||
user, |
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.
We can use internal_prep_private_message()
twice, instead of using internal_send_private_message()
twice. and then use do_send_messages([default_message, custom_message])
-- This will save a lot of db queries.
zproject/urls.py
Outdated
@@ -300,6 +301,8 @@ | |||
), | |||
# realm/deactivate -> zerver.views.deactivate_realm | |||
rest_path("realm/deactivate", POST=deactivate_realm), | |||
# realm/test_custom_welcome_bot_message -> zerver.views.send_test_custom_welcome_bot_message |
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.
zerver.views.send_test_custom_welcome_bot_message
-- no such file exists
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.
My bad, I thought it was a function as the above comment has "deactivate_realm," which is not a file name but a function inside realm.py. I'll correct it. Thanks for pointing it out.
7d34a1b
to
8c4476b
Compare
8c4476b
to
847d3dc
Compare
This commit extends the functionality of the Welcome Bot to include the custom welcome message configured by administrators. It ensures that new users receive the additional custom message along with the standard welcome message upon joining the organization. Fixes: zulip#27663
847d3dc
to
93388df
Compare
@prakhar1144 I have updated the PR |
Heads up @akarsh-jain-790, we just merged some commits that conflict with the changes you made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
This commit extends the functionality of the Welcome Bot to include the custom welcome message configured by administrators. It ensures that new users receive the additional custom message along with the standard welcome message upon joining the organization.
Fixes: #27663
Screenshots and screen captures:
Screenshot with Checkbox Unchecked:
Organization settings page with the "Add a custom Welcome Bot message for new users" checkbox unchecked.
![Screenshot 2024-03-26 at 6 57 28 PM](https://private-user-images.githubusercontent.com/72064462/316882697-14b0377e-3230-4e8a-8994-3c0bbaa15106.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk1NTc4NDMsIm5iZiI6MTcxOTU1NzU0MywicGF0aCI6Ii83MjA2NDQ2Mi8zMTY4ODI2OTctMTRiMDM3N2UtMzIzMC00ZThhLTg5OTQtM2MwYmJhYTE1MTA2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI4VDA2NTIyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZiYTA2M2Q1MGVkMWMxZmRhZTE1YmVkOWU3OTA2NGI3MWEzZjIwOGY5MGM1MGMxYjE1N2Y0OGY0NDZiNWRhYzImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.In2zPe2SdWySKlk8XPW6P6sV4IaobQAb5knIU1lHCEw)
Screenshot with Checkbox Checked:
Organization settings page with the "Add a custom Welcome Bot message for new users" checkbox checked.
![Screenshot 2024-03-30 at 2 50 51 PM](https://private-user-images.githubusercontent.com/72064462/318183351-45649de9-a8a1-404c-b8c5-7c7f15f48d81.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk1NTc4NDMsIm5iZiI6MTcxOTU1NzU0MywicGF0aCI6Ii83MjA2NDQ2Mi8zMTgxODMzNTEtNDU2NDlkZTktYThhMS00MDRjLWI4YzUtN2M3ZjE1ZjQ4ZDgxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI4VDA2NTIyM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM2YTIyYWZmMjRkODU0N2FhNGViNzk3NGUxZjA2NzAyMzVhMjgwODA4MWYwOTY3NjFiOTg1ZWZlNGYyYzQ0Y2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.h2mEGMgZJjArcD5n4IT1GZcDTISoouKgv6H8dtR48kI)
Save button is disabled when textarea is empty.
When attempting to send a Test Custom Welcome Bot Message with an empty message:
When attempting to send a Test Custom Welcome Bot Message with a message:
Screenshot with Custom Welcome Bot Message Included:
Screenshot without Custom Welcome Bot Message:
Self-review checklist
(variable names, code reuse, readability, etc.).
Communicate decisions, questions, and potential concerns.
Individual commits are ready for review (see commit discipline).
Completed manual review and testing of the following: