Repository: zulip/zulip

Issue:
Do not send first Zulip Updates message with onboarding messages in new organization
<!-- Issue description -->

To help users focus on the onboarding experience, we should not send the introductory "Zulip updates" message ("Welcome! To help you learn about new features and configuration options, ..." as part of onboarding in a new organization.

It probably makes the most sense to just wait until we are sending the first update, and send it right before the first update message. We should drop "Welcome!" from the start of the message.





Discussion:
Hello @zulip/server-bots, @zulip/server-onboarding members, this issue was labeled with the "area: onboarding", "area: bots" labels, so you may want to check it out!

<!-- areaLabelAddition -->

@prakhar1144 Would you be up for taking care of this one? Please flag if this is tricky; I think from a product perspective, there are other reasonable options, as long as we delay the message.
I'm not sure if there are product decisions specific to self-hosters that need to be considered here.

Resolving patch:
diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.py
--- a/zerver/lib/onboarding.py
+++ b/zerver/lib/onboarding.py
@@ -359,21 +359,6 @@ def send_initial_realm_messages(realm: Realm) -> None:
 :point_right: Click on this message to start a new message in the same conversation.
 """)
 
-    content_of_zulip_update_announcements_topic_name = (
-        _("""
-Welcome! To help you learn about new features and configuration options,
-this topic will receive messages about important changes in Zulip.
-
-You can read these update messages whenever it's convenient, or
-[mute]({mute_topic_help_url}) this topic if you are not interested.
-If your organization does not want to receive these announcements,
-they can be disabled. [Learn more]({zulip_update_announcements_help_url}).
-        """)
-    ).format(
-        zulip_update_announcements_help_url="/help/configure-automated-notices#zulip-update-announcements",
-        mute_topic_help_url="/help/mute-a-topic",
-    )
-
     welcome_messages: List[Dict[str, str]] = []
 
     # Messages added to the "welcome messages" list last will be most
@@ -383,15 +368,6 @@ def send_initial_realm_messages(realm: Realm) -> None:
     #
     # Initial messages are configured below.
 
-    # Zulip updates system advertisement.
-    welcome_messages += [
-        {
-            "channel_name": str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME),
-            "topic_name": str(Realm.ZULIP_UPDATE_ANNOUNCEMENTS_TOPIC_NAME),
-            "content": content_of_zulip_update_announcements_topic_name,
-        },
-    ]
-
     # Advertising moving messages.
     welcome_messages += [
         {
diff --git a/zerver/lib/zulip_update_announcements.py b/zerver/lib/zulip_update_announcements.py
--- a/zerver/lib/zulip_update_announcements.py
+++ b/zerver/lib/zulip_update_announcements.py
@@ -14,6 +14,7 @@
     internal_prep_stream_message,
 )
 from zerver.lib.message import SendMessageRequest, remove_single_newlines
+from zerver.lib.topic import messages_for_topic
 from zerver.models.realm_audit_logs import RealmAuditLog
 from zerver.models.realms import Realm
 from zerver.models.users import UserProfile, get_system_bot
@@ -264,11 +265,47 @@ def send_zulip_update_announcements(
             ):
                 continue
 
-            messages = internal_prep_zulip_update_announcements_stream_messages(
-                current_level=realm_zulip_update_announcements_level,
-                latest_level=latest_zulip_update_announcements_level,
-                sender=sender,
-                realm=realm,
+            # Send an introductory message just before the first update message.
+            with override_language(realm.default_language):
+                topic_name = str(realm.ZULIP_UPDATE_ANNOUNCEMENTS_TOPIC_NAME)
+
+            stream = realm.zulip_update_announcements_stream
+            assert stream.recipient_id is not None
+            topic_has_messages = messages_for_topic(
+                realm.id, stream.recipient_id, topic_name
+            ).exists()
+
+            if not topic_has_messages:
+                content_of_introductory_message = (
+                    """
+To help you learn about new features and configuration options,
+this topic will receive messages about important changes in Zulip.
+
+You can read these update messages whenever it's convenient, or
+[mute]({mute_topic_help_url}) this topic if you are not interested.
+If your organization does not want to receive these announcements,
+they can be disabled. [Learn more]({zulip_update_announcements_help_url}).
+"""
+                ).format(
+                    zulip_update_announcements_help_url="/help/configure-automated-notices#zulip-update-announcements",
+                    mute_topic_help_url="/help/mute-a-topic",
+                )
+                messages = [
+                    internal_prep_stream_message(
+                        sender,
+                        stream,
+                        topic_name,
+                        remove_single_newlines(content_of_introductory_message),
+                    )
+                ]
+
+            messages.extend(
+                internal_prep_zulip_update_announcements_stream_messages(
+                    current_level=realm_zulip_update_announcements_level,
+                    latest_level=latest_zulip_update_announcements_level,
+                    sender=sender,
+                    realm=realm,
+                )
             )
 
             new_zulip_update_announcements_level = latest_zulip_update_announcements_level


Test patch:
diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py
--- a/zerver/tests/test_signup.py
+++ b/zerver/tests/test_signup.py
@@ -1305,7 +1305,7 @@ def check_able_to_create_realm(self, email: str, password: str = "test") -> None
 
         # Check welcome messages
         for stream_name, text, message_count in [
-            (str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME), "learn about new features", 3),
+            (str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME), "a great place to say “hi”", 2),
             (str(Realm.ZULIP_SANDBOX_CHANNEL_NAME), "Use this topic to try out", 5),
         ]:
             stream = get_stream(stream_name, realm)
diff --git a/zerver/tests/test_zulip_update_announcements.py b/zerver/tests/test_zulip_update_announcements.py
--- a/zerver/tests/test_zulip_update_announcements.py
+++ b/zerver/tests/test_zulip_update_announcements.py
@@ -122,9 +122,10 @@ def test_send_zulip_update_announcements(self) -> None:
                 recipient__type_id=verona.id,
                 date_sent__gte=now + timedelta(days=10),
             ).order_by("id")
-            self.assert_length(stream_messages, 2)
-            self.assertEqual(stream_messages[0].content, "Announcement message 3.")
-            self.assertEqual(stream_messages[1].content, "Announcement message 4.")
+            self.assert_length(stream_messages, 3)
+            self.assertIn("To help you learn about new features", stream_messages[0].content)
+            self.assertEqual(stream_messages[1].content, "Announcement message 3.")
+            self.assertEqual(stream_messages[2].content, "Announcement message 4.")
             self.assertEqual(realm.zulip_update_announcements_level, 4)
 
     def test_send_zulip_update_announcements_with_stream_configured(self) -> None: