:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(slack): add "Dive into the data" button to subscriptions (#63251)
Vasco de Krijger2c056b61dded
diff --git a/ee/tasks/subscriptions/slack_subscriptions.py b/ee/tasks/subscriptions/slack_subscriptions.pyindex a9f7fba6c4d0..b02f94d413b6 100644--- a/ee/tasks/subscriptions/slack_subscriptions.py+++ b/ee/tasks/subscriptions/slack_subscriptions.py@@ -8,6 +8,7 @@ import aiohttpimport structlogfrom slack_sdk.errors import SlackApiError+from posthog.helpers.slack_subscription_explore import build_explore_hintfrom posthog.models.integration import Integration, SlackIntegrationfrom posthog.utils import absolute_uri@@ -139,6 +140,7 @@ def _prepare_slack_message(is_new_subscription: bool = False,change_summary: str | None = None,summary_skipped_over_budget: bool = False,+ integration: Integration | None = None,) -> SlackMessageData:"""Prepare Slack message content. Pure function with no side effects."""utm_tags = f"{UTM_TAGS_BASE}&utm_medium=slack"@@ -192,26 +194,28 @@ def _prepare_slack_message(})+ action_elements: list[dict] = [+ {+ "type": "button",+ "text": {"type": "plain_text", "text": "View in PostHog"},+ "url": f"{resource_info.url}?{utm_tags}",+ },+ {+ "type": "button",+ "text": {"type": "plain_text", "text": "Manage Subscription"},+ "url": f"{subscription.url}?{utm_tags}",+ },+ ]+blocks.extend([{"type": "divider"},- {- "type": "actions",- "elements": [- {- "type": "button",- "text": {"type": "plain_text", "text": "View in PostHog"},- "url": f"{resource_info.url}?{utm_tags}",- },- {- "type": "button",- "text": {"type": "plain_text", "text": "Manage Subscription"},- "url": f"{subscription.url}?{utm_tags}",- },- ],- },+ {"type": "actions", "elements": action_elements},])+ ai_enabled = bool(integration and integration.team.organization.is_ai_data_processing_approved)+ if explore_hint := build_explore_hint(integration, utm_tags=utm_tags, ai_enabled=ai_enabled):+ blocks.append(explore_hint)# Prepare additional messages for threadthread_messages = []@@ -249,7 +253,13 @@ def send_slack_message_with_integration(is_new_subscription: bool = False,) -> None:"""Send Slack message using provided integration (sync version)."""- message_data = _prepare_slack_message(subscription, assets, total_asset_count, is_new_subscription)+ message_data = _prepare_slack_message(+ subscription,+ assets,+ total_asset_count,+ is_new_subscription,+ integration=integration,+ )slack_integration = SlackIntegration(integration)# Send main message@@ -378,5 +388,6 @@ async def send_slack_message_with_integration_async(is_new_subscription,change_summary=change_summary,summary_skipped_over_budget=summary_skipped_over_budget,+ integration=integration,)return await deliver_slack_message_data(integration, subscription, message_data)diff --git a/ee/tasks/test/subscriptions/test_slack_subscriptions.py b/ee/tasks/test/subscriptions/test_slack_subscriptions.pyindex 59ad43657e54..af18964e3a45 100644--- a/ee/tasks/test/subscriptions/test_slack_subscriptions.py+++ b/ee/tasks/test/subscriptions/test_slack_subscriptions.py@@ -9,6 +9,7 @@ from parameterized import parameterizedfrom slack_sdk.errors import SlackApiErrorfrom slack_sdk.web.async_slack_response import AsyncSlackResponse+from posthog.helpers.slack_scopes import REQUIRED_SLACK_SCOPESfrom posthog.models.integration import Integrationfrom products.dashboards.backend.models.dashboard import Dashboard@@ -106,6 +107,15 @@ class TestSlackSubscriptionsTasks(APIBaseTest):},],},+ {+ "type": "context",+ "elements": [+ {+ "type": "mrkdwn",+ "text": "💬 <https://posthog.com/docs/slack-app?utm_source=posthog&utm_campaign=subscription_report&utm_medium=slack|Set up the @PostHog bot> to ask follow-up questions about your reports here.",+ }+ ],+ },]@parameterized.expand(@@ -208,6 +218,15 @@ class TestSlackSubscriptionsTasks(APIBaseTest):},],},+ {+ "type": "context",+ "elements": [+ {+ "type": "mrkdwn",+ "text": "💬 <https://posthog.com/docs/slack-app?utm_source=posthog&utm_campaign=subscription_report&utm_medium=slack|Set up the @PostHog bot> to ask follow-up questions about your reports here.",+ }+ ],+ },]# Second call - other asset@@ -656,3 +675,57 @@ class TestSlackSummaryNotice(APIBaseTest):def test_no_notice_when_under_budget_and_no_summary(self) -> None:texts = self._block_texts(change_summary=None, summary_skipped_over_budget=False)assert all("AI summary skipped" not in text for text in texts)+++class TestSlackExploreHint(APIBaseTest):+ def setUp(self) -> None:+ self.insight = Insight.objects.create(team=self.team, short_id="123456", name="My Test subscription")+ self.asset = ExportedAsset.objects.create(+ team=self.team,+ insight_id=self.insight.id,+ export_format="image/png",+ content_location="s3://bucket/test.png",+ )+ self.subscription = create_subscription(+ team=self.team,+ insight=self.insight,+ created_by=self.user,+ target_type="slack",+ target_value="C12345|#test-channel",+ )++ def _hint_texts(self, integration: Integration | None) -> list[str]:+ message = _prepare_slack_message(+ self.subscription,+ [self.asset],+ total_asset_count=1,+ integration=integration,+ )+ return [el["text"] for block in message.blocks if block.get("type") == "context" for el in block["elements"]]++ def _make_integration(self, scopes: frozenset[str]) -> Integration:+ return Integration.objects.create(+ team=self.team,+ kind="slack",+ integration_id="T12345",+ config={"scope": ",".join(sorted(scopes))},+ sensitive_config={"access_token": "xoxb-test"},+ )++ def test_no_hint_without_integration(self) -> None:+ assert self._hint_texts(None) == []++ def test_bot_ready_hint_nudges_mention(self) -> None:+ texts = self._hint_texts(self._make_integration(REQUIRED_SLACK_SCOPES))+ assert any("@PostHog" in t and "docs/slack-app" not in t for t in texts)++ def test_bot_not_ready_hint_links_docs(self) -> None:+ texts = self._hint_texts(self._make_integration(frozenset({"chat:write"})))+ assert any("docs/slack-app" in t for t in texts)+ assert not any("Reply in this thread" in t for t in texts)++ def test_no_hint_when_ai_not_approved(self) -> None:+ org = self.team.organization+ org.is_ai_data_processing_approved = False+ org.save()+ assert self._hint_texts(self._make_integration(REQUIRED_SLACK_SCOPES)) == []diff --git a/posthog/helpers/slack_scopes.py b/posthog/helpers/slack_scopes.pynew file mode 100644index 000000000000..2745bb0d4095--- /dev/null+++ b/posthog/helpers/slack_scopes.py@@ -0,0 +1,33 @@+# In core ``posthog`` so the delivery paths (``ee/tasks``, ``products/exports``) and the+# ``products.slack_app`` handlers can share the bot's required scopes without crossing tach+# module boundaries.++import structlog++from posthog.models.integration import Integration, SlackIntegration++logger = structlog.get_logger(__name__)++# Installs connected before the full set was requested (#57177) must reconnect before mentions work.+# channels:read/groups:read (member_joined_channel onboarding) are deliberately excluded so older+# installs degrade gracefully — they skip the welcome message rather than tripping a missing-scopes warning.+REQUIRED_SLACK_SCOPES: frozenset[str] = frozenset(+ {+ "app_mentions:read",+ "users:read",+ "users:read.email",+ "chat:write",+ "channels:history",+ "groups:history",+ "reactions:write",+ }+)+++def bot_is_ready(integration: Integration) -> bool:+ """True when the install has every scope the @PostHog bot needs to answer mentions."""+ try:+ return not SlackIntegration(integration).missing_scopes(REQUIRED_SLACK_SCOPES)+ except Exception:+ logger.warning("slack_bot_scope_check_failed", integration_id=integration.id, exc_info=True)+ return Falsediff --git a/posthog/helpers/slack_subscription_explore.py b/posthog/helpers/slack_subscription_explore.pynew file mode 100644index 000000000000..3d3f848e8fc7--- /dev/null+++ b/posthog/helpers/slack_subscription_explore.py@@ -0,0 +1,24 @@+# In core ``posthog`` so the delivery paths (``ee/tasks``, ``products/exports``) can import this+# without crossing tach's ``products.slack_app`` boundary.++from typing import Any++from posthog.helpers.slack_scopes import bot_is_ready+from posthog.models.integration import Integration++BOT_SETUP_DOCS_URL = "https://posthog.com/docs/slack-app"+++def build_explore_hint(integration: Integration | None, *, utm_tags: str, ai_enabled: bool) -> dict[str, Any] | None:+ """Slack context block nudging the channel to @PostHog this report (or to set the bot up).++ Returns ``None`` when there's no Slack install or the org hasn't approved AI data processing —+ we don't nudge people toward the AI bot when their org hasn't opted into AI.+ """+ if integration is None or not ai_enabled:+ return None+ if bot_is_ready(integration):+ text = "💬 Reply in this thread and mention *@PostHog* with a question to dig into this report."+ else:+ text = f"💬 <{BOT_SETUP_DOCS_URL}?{utm_tags}|Set up the @PostHog bot> to ask follow-up questions about your reports here."+ return {"type": "context", "elements": [{"type": "mrkdwn", "text": text}]}diff --git a/products/exports/backend/temporal/subscriptions/ai_subscription/delivery.py b/products/exports/backend/temporal/subscriptions/ai_subscription/delivery.pyindex bb56bef14ac9..c641f6385cec 100644--- a/products/exports/backend/temporal/subscriptions/ai_subscription/delivery.py+++ b/products/exports/backend/temporal/subscriptions/ai_subscription/delivery.py@@ -10,6 +10,7 @@ from markdown_to_mrkdwn import SlackMarkdownConverterfrom posthog.api.utils import hostname_in_allowed_url_listfrom posthog.email import EmailMessage+from posthog.helpers.slack_subscription_explore import build_explore_hintfrom posthog.models import Team, Userfrom posthog.models.integration import Integrationfrom posthog.sync import database_sync_to_async@@ -255,7 +256,13 @@ def send_email_ai_subscription_credit_limited(message.send(send_async=False)-def _build_ai_slack_message(subscription: Subscription, markdown: str, *, delivery_id: uuid.UUID) -> SlackMessageData:+def _build_ai_slack_message(+ subscription: Subscription,+ markdown: str,+ *,+ delivery_id: uuid.UUID,+ integration: Integration | None = None,+) -> SlackMessageData:utm_tags = f"{UTM_TAGS_BASE}&utm_medium=slack"channel = subscription.target_value.split("|")[0]sections = _split_text_into_chunks(_SLACK_CONVERTER.convert(_strip_external_links_markdown(markdown)))@@ -276,19 +283,18 @@ def _build_ai_slack_message(subscription: Subscription, markdown: str, *, delive)feedback_positive_url = _build_feedback_url(subscription_url, delivery_id, "positive", "slack")feedback_negative_url = _build_feedback_url(subscription_url, delivery_id, "negative", "slack")++ action_elements: list[dict] = [+ {+ "type": "button",+ "text": {"type": "plain_text", "text": "Manage subscription"},+ "url": f"{subscription_url}?{utm_tags}",+ }+ ]blocks.extend([{"type": "divider"},- {- "type": "actions",- "elements": [- {- "type": "button",- "text": {"type": "plain_text", "text": "Manage subscription"},- "url": f"{subscription_url}?{utm_tags}",- }- ],- },+ {"type": "actions", "elements": action_elements},{"type": "context","elements": [@@ -303,6 +309,9 @@ def _build_ai_slack_message(subscription: Subscription, markdown: str, *, delive},])+ # AI consent is enforced upstream before this report is built, so the hint always shows here.+ if explore_hint := build_explore_hint(integration, utm_tags=utm_tags, ai_enabled=True):+ blocks.append(explore_hint)thread_messages = [{"blocks": [{"type": "section", "text": {"type": "mrkdwn", "text": section}}]} for section in sections[1:]@@ -318,7 +327,7 @@ async def send_slack_ai_subscription_report(integration: Integration,delivery_id: uuid.UUID,) -> SlackDeliveryResult:- message_data = _build_ai_slack_message(subscription, markdown, delivery_id=delivery_id)+ message_data = _build_ai_slack_message(subscription, markdown, delivery_id=delivery_id, integration=integration)return await deliver_slack_message_data(integration, subscription, message_data)diff --git a/products/exports/backend/temporal/subscriptions/ai_subscription/test/test_delivery.py b/products/exports/backend/temporal/subscriptions/ai_subscription/test/test_delivery.pyindex ffe40f176679..d930374b7c81 100644--- a/products/exports/backend/temporal/subscriptions/ai_subscription/test/test_delivery.py+++ b/products/exports/backend/temporal/subscriptions/ai_subscription/test/test_delivery.py@@ -3,6 +3,8 @@ import uuidimport pytestfrom unittest.mock import MagicMock, patch+from posthog.helpers.slack_scopes import REQUIRED_SLACK_SCOPES+from products.exports.backend.temporal.subscriptions.ai_subscription.delivery import (SLACK_MRKDWN_SECTION_LIMIT,_build_ai_slack_message,@@ -202,6 +204,42 @@ class TestBuildAISlackMessage:assert block["text"]["text"].strip(), "thread section text must be non-empty"+def _mock_integration(scopes: frozenset[str]) -> MagicMock:+ integration = MagicMock()+ integration.kind = "slack"+ integration.id = 7+ integration.config = {"scope": ",".join(sorted(scopes))}+ integration.sensitive_config = {"access_token": "xoxb-test"}+ return integration+++def _hint_texts(message: SlackMessageData) -> list[str]:+ return [el["text"] for block in message.blocks if block.get("type") == "context" for el in block["elements"]]+++def _ai_message(*, integration: MagicMock | None = None) -> SlackMessageData:+ return _build_ai_slack_message(+ _mock_subscription(),+ "A short report.",+ delivery_id=_DELIVERY_ID,+ integration=integration,+ )+++class TestAIExploreHint:+ def test_no_hint_without_integration(self) -> None:+ assert not any("@PostHog" in t for t in _hint_texts(_ai_message()))++ def test_bot_ready_hint_nudges_mention(self) -> None:+ message = _ai_message(integration=_mock_integration(REQUIRED_SLACK_SCOPES))+ assert any("@PostHog" in t and "docs/slack-app" not in t for t in _hint_texts(message))++ def test_bot_not_ready_hint_links_docs(self) -> None:+ texts = _hint_texts(_ai_message(integration=_mock_integration(frozenset({"chat:write"}))))+ assert any("docs/slack-app" in t for t in texts)+ assert not any("Reply in this thread" in t for t in texts)++def _feedback_url(feedback: str, source: str) -> str:return f"{_SUBSCRIPTION_URL}?feedback_delivery={_DELIVERY_ID}&feedback={feedback}&feedback_source={source}"diff --git a/products/slack_app/backend/api.py b/products/slack_app/backend/api.pyindex b13c137632ee..b848a15dc75b 100644--- a/products/slack_app/backend/api.py+++ b/products/slack_app/backend/api.py@@ -22,6 +22,7 @@ from slack_sdk.http_retry.builtin_handlers import RateLimitErrorRetryHandlerfrom temporalio.common import WorkflowIDConflictPolicy, WorkflowIDReusePolicyfrom posthog.event_usage import groups+from posthog.helpers.slack_scopes import REQUIRED_SLACK_SCOPESfrom posthog.llm.gateway_client import get_llm_clientfrom posthog.models.integration import (SLACK_INTEGRATION_KINDS,@@ -82,27 +83,6 @@ HANDLED_EVENT_TYPES = [# needs, so both surfaces share one kind.SLACK_INTEGRATION_KIND = "slack"-# Scopes the coding-agent flow exercises end-to-end. Slack stores the granted scope set-# per install, so tenants who connected the Slack integration before the full scope set-# was requested in prod (2026-05-04, #57177) must reconnect before mentions can work.-#-# ``member_joined_channel`` (used by the channel-onboarding flow) additionally requires-# ``channels:read`` and ``groups:read``. Those are in the Slack app manifest but **not**-# in the required set on purpose: workspaces that connected before the scopes were added-# keep working — they just don't deliver the join event, so they silently skip the-# welcome message instead of seeing a "missing scopes" warning.-POSTHOG_CODE_REQUIRED_SLACK_SCOPES: frozenset[str] = frozenset(- {- "app_mentions:read",- "users:read",- "users:read.email",- "chat:write",- "channels:history",- "groups:history",- "reactions:write",- }-)-# Onboarding-on-join dedupe TTL: just long enough to absorb Slack retries and# a near-simultaneous cross-region race during cutover. A real re-add after# this window should re-onboard — most likely the person forgot how it works.@@ -1642,8 +1622,8 @@ def send_assistant_install_welcome(integration: Integration) -> None:# The DM/agent surface needs the base coding-agent scopes plus the assistant container scopes.-# Kept separate from POSTHOG_CODE_REQUIRED_SLACK_SCOPES so the mention flow isn't gated on im:history.-_ASSISTANT_REQUIRED_SLACK_SCOPES = POSTHOG_CODE_REQUIRED_SLACK_SCOPES | frozenset({"assistant:write", "im:history"})+# Kept separate from REQUIRED_SLACK_SCOPES so the mention flow isn't gated on im:history.+_ASSISTANT_REQUIRED_SLACK_SCOPES = REQUIRED_SLACK_SCOPES | frozenset({"assistant:write", "im:history"})def _handle_assistant_dm_message(@@ -1953,7 +1933,7 @@ def route_posthog_code_event_to_relevant_region(return ROUTE_HANDLED_LOCALLYslack = SlackIntegration(mention_target)- missing = slack.missing_scopes(POSTHOG_CODE_REQUIRED_SLACK_SCOPES)+ missing = slack.missing_scopes(REQUIRED_SLACK_SCOPES)if missing:if untagged_followup_mapping is not None:logger.info(diff --git a/products/slack_app/backend/tests/test_channel_onboarding_routing.py b/products/slack_app/backend/tests/test_channel_onboarding_routing.pyindex 258219b750ba..a097987a4830 100644--- a/products/slack_app/backend/tests/test_channel_onboarding_routing.py+++ b/products/slack_app/backend/tests/test_channel_onboarding_routing.py@@ -4,13 +4,13 @@ from django.core.cache import cachefrom django.test import TestCase, override_settingsfrom django.test.client import RequestFactory+from posthog.helpers.slack_scopes import REQUIRED_SLACK_SCOPESfrom posthog.models.integration import Integrationfrom posthog.models.organization import Organization, OrganizationMembershipfrom posthog.models.team.team import Teamfrom posthog.models.user import Userfrom products.slack_app.backend.api import (- POSTHOG_CODE_REQUIRED_SLACK_SCOPES,ROUTE_HANDLED_LOCALLY,ROUTE_NO_INTEGRATION,_channel_onboarding_cache_key,@@ -43,7 +43,7 @@ class TestMemberJoinedChannelRouting(TestCase):team=self.team,kind="slack",integration_id=self.SLACK_TEAM_ID,- config={"scope": ",".join(sorted(POSTHOG_CODE_REQUIRED_SLACK_SCOPES))},+ config={"scope": ",".join(sorted(REQUIRED_SLACK_SCOPES))},sensitive_config={"access_token": "xoxb-test"},)diff --git a/products/slack_app/backend/tests/test_posthog_code_event_handler.py b/products/slack_app/backend/tests/test_posthog_code_event_handler.pyindex 1e808b3aa04a..bb07f61f2a32 100644--- a/products/slack_app/backend/tests/test_posthog_code_event_handler.py+++ b/products/slack_app/backend/tests/test_posthog_code_event_handler.py@@ -105,7 +105,7 @@ class TestPostHogCodeEventHandler(TestCase):class TestRoutePostHogCodeEventToRelevantRegion(TestCase):def setUp(self):- from products.slack_app.backend.api import POSTHOG_CODE_REQUIRED_SLACK_SCOPES+ from posthog.helpers.slack_scopes import REQUIRED_SLACK_SCOPEScache.clear()self.factory = RequestFactory()@@ -120,7 +120,7 @@ class TestRoutePostHogCodeEventToRelevantRegion(TestCase):team=self.team,kind="slack",integration_id="T12345",- config={"scope": ",".join(sorted(POSTHOG_CODE_REQUIRED_SLACK_SCOPES))},+ config={"scope": ",".join(sorted(REQUIRED_SLACK_SCOPES))},sensitive_config={"access_token": "xoxb-posthog-code-test"},)# Seed the Slack-user → email cache so routing can resolve U123 → self.user@@ -918,7 +918,7 @@ class TestChannelApprovalGate(TestCase):def setUp(self):from django.utils import timezone- from products.slack_app.backend.api import POSTHOG_CODE_REQUIRED_SLACK_SCOPES+ from posthog.helpers.slack_scopes import REQUIRED_SLACK_SCOPEScache.clear()self.factory = RequestFactory()@@ -933,7 +933,7 @@ class TestChannelApprovalGate(TestCase):team=self.team,kind="slack",integration_id="T12345",- config={"scope": ",".join(sorted(POSTHOG_CODE_REQUIRED_SLACK_SCOPES))},+ config={"scope": ",".join(sorted(REQUIRED_SLACK_SCOPES))},sensitive_config={"access_token": "xoxb-posthog-code-test"},)# Routing now resolves the Slack user to a PostHog user before any@@ -1073,7 +1073,7 @@ class TestChannelApprovalGate(TestCase):class TestAssistantEvents(TestCase):def setUp(self):- from products.slack_app.backend.api import POSTHOG_CODE_REQUIRED_SLACK_SCOPES+ from posthog.helpers.slack_scopes import REQUIRED_SLACK_SCOPEScache.clear()self.factory = RequestFactory()@@ -1084,7 +1084,7 @@ class TestAssistantEvents(TestCase):team=self.team,kind="slack",integration_id="T12345",- config={"scope": ",".join(sorted(POSTHOG_CODE_REQUIRED_SLACK_SCOPES))},+ config={"scope": ",".join(sorted(REQUIRED_SLACK_SCOPES))},sensitive_config={"access_token": "xoxb-test"},)diff --git a/products/slack_app/backend/tests/test_subscription_explore.py b/products/slack_app/backend/tests/test_subscription_explore.pynew file mode 100644index 000000000000..b26f81f0bada--- /dev/null+++ b/products/slack_app/backend/tests/test_subscription_explore.py@@ -0,0 +1,68 @@+from django.test import TestCase++from parameterized import parameterized++from posthog.helpers.slack_scopes import REQUIRED_SLACK_SCOPES, bot_is_ready+from posthog.helpers.slack_subscription_explore import build_explore_hint+from posthog.models.integration import Integration+from posthog.models.organization import Organization+from posthog.models.team import Team+++class TestBotIsReady(TestCase):+ def setUp(self) -> None:+ self.org = Organization.objects.create(name="Org")+ self.team = Team.objects.create(organization=self.org, name="Team")++ def _integration(self, scopes: frozenset[str]) -> Integration:+ return Integration.objects.create(+ team=self.team,+ kind="slack",+ integration_id="T1",+ config={"scope": ",".join(sorted(scopes))},+ sensitive_config={"access_token": "xoxb-test"},+ )++ @parameterized.expand(+ [+ ("full_scopes", REQUIRED_SLACK_SCOPES, True),+ ("missing_scopes", frozenset({"chat:write"}), False),+ ]+ )+ def test_bot_is_ready(self, _name: str, scopes: frozenset[str], expected: bool) -> None:+ assert bot_is_ready(self._integration(scopes)) is expected+++class TestBuildExploreHint(TestCase):+ def setUp(self) -> None:+ self.org = Organization.objects.create(name="Org")+ self.team = Team.objects.create(organization=self.org, name="Team")++ def _integration(self, scopes: frozenset[str]) -> Integration:+ return Integration.objects.create(+ team=self.team,+ kind="slack",+ integration_id="T1",+ config={"scope": ",".join(sorted(scopes))},+ sensitive_config={"access_token": "xoxb-test"},+ )++ def test_no_integration_returns_none(self) -> None:+ assert build_explore_hint(None, utm_tags="utm", ai_enabled=True) is None++ def test_ai_disabled_returns_none(self) -> None:+ # Org hasn't approved AI data processing — don't nudge toward the AI bot, even with a ready install.+ assert build_explore_hint(self._integration(REQUIRED_SLACK_SCOPES), utm_tags="utm", ai_enabled=False) is None++ def test_bot_ready_nudges_mention(self) -> None:+ hint = build_explore_hint(self._integration(REQUIRED_SLACK_SCOPES), utm_tags="utm", ai_enabled=True)+ assert hint is not None+ assert hint["type"] == "context"+ assert "@PostHog" in hint["elements"][0]["text"]++ def test_bot_not_ready_links_docs(self) -> None:+ hint = build_explore_hint(self._integration(frozenset({"chat:write"})), utm_tags="utm", ai_enabled=True)+ assert hint is not None+ text = hint["elements"][0]["text"]+ assert "docs/slack-app?utm" in text+ assert "Reply in this thread" not in textdiff --git a/products/slack_app/backend/tests/test_thread_message_routing.py b/products/slack_app/backend/tests/test_thread_message_routing.pyindex cbc6c94bdf77..5a8059cef9eb 100644--- a/products/slack_app/backend/tests/test_thread_message_routing.py+++ b/products/slack_app/backend/tests/test_thread_message_routing.py@@ -20,7 +20,7 @@ class TestRouteThreadMessage(TestCase):workflow so the webhook handler stays fast."""def setUp(self):- from products.slack_app.backend.api import POSTHOG_CODE_REQUIRED_SLACK_SCOPES+ from posthog.helpers.slack_scopes import REQUIRED_SLACK_SCOPEScache.clear()self.factory = RequestFactory()@@ -39,7 +39,7 @@ class TestRouteThreadMessage(TestCase):team=self.team,kind="slack",integration_id="T_SLACK",- config={"scope": ",".join(sorted(POSTHOG_CODE_REQUIRED_SLACK_SCOPES))},+ config={"scope": ",".join(sorted(REQUIRED_SLACK_SCOPES))},sensitive_config={"access_token": "xoxb-test"},)SlackUserProfileCache.objects.create(