Skip to content

Interface Language for Salesforce Webhook#3201

Open
relyks wants to merge 3 commits intomasterfrom
chore/sc-43219/interface-language-for-salesforce-webhook
Open

Interface Language for Salesforce Webhook#3201
relyks wants to merge 3 commits intomasterfrom
chore/sc-43219/interface-language-for-salesforce-webhook

Conversation

@relyks
Copy link
Copy Markdown
Contributor

@relyks relyks commented Apr 1, 2026

Description

Sends the user's interface language to Salesforce so English and Hebrew users can be differentiated for marketing campaigns related to the Library Assistant

@relyks relyks self-assigned this Apr 1, 2026
@relyks relyks marked this pull request as draft April 1, 2026 01:29
… testing on cauldron with Salesforce sandbox"

This reverts commit 973d3a8.
@relyks relyks marked this pull request as ready for review April 17, 2026 21:00
@yitzhakc yitzhakc requested review from Copilot and yitzhakc and removed request for Copilot April 26, 2026 14:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds the user’s interface language to the Salesforce “chatbot opt-in” webhook payload so English vs Hebrew users can be segmented for Library Assistant marketing.

Changes:

  • Extend send_chatbot_opt_in_webhook / dispatch_chatbot_opt_in_webhook to accept an interface_language argument and include it in the webhook JSON (interfaceLanguage).
  • Plumb interface_language from UserProfile.settings["interface_language"] when firing the webhook on experiment opt-in/out changes.
  • Update unit/integration tests to pass/expect the new language field in webhook payloads and dispatch calls.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
sefaria/helper/crm/tasks.py Adds interface_language parameter and sends it to Salesforce in the webhook payload.
sefaria/helper/crm/chatbot_webhook_test.py Updates webhook tests to include/assert interfaceLanguage; updates dispatch tests to call with the new argument.
reader/tests/experiments_admin_test.py Updates expectations for webhook dispatch calls to include the interface language.
reader/models.py Reads interface_language from the user profile and forwards it into webhook dispatch.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

dispatch_chatbot_opt_in_webhook("user@example.com", True)
dispatch_chatbot_opt_in_webhook("user@example.com", True, "english")

mock_task.apply_async.assert_called_once()
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

test_dispatch_celery_enabled_uses_apply_async currently only asserts that apply_async was called, but not that the new interface_language argument is actually forwarded. Since this PR adds interface_language support, this test should assert apply_async was called with the expected args (including the interface language) and queue, to prevent regressions where the new field silently stops being sent when Celery is enabled.

Suggested change
mock_task.apply_async.assert_called_once()
mock_task.apply_async.assert_called_once()
_, kwargs = mock_task.apply_async.call_args
assert kwargs["args"] == ["user@example.com", True, "english"]
assert "queue" in kwargs
assert kwargs["queue"]

Copilot uses AI. Check for mistakes.
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.

3 participants