Add BSUID support - rename UserNumber to UserId - #407
Merged
Merged
Conversation
WhatsApp for Business is rolling out Business-Scoped User IDs (BSUIDs) to support privacy-focused username-based messaging. Users who opt for usernames will no longer expose their phone numbers to businesses. Changes: - User record gains Id (always set, phone or BSUID) and nullable Number (set only when a phone number is available and distinct from the Id) - IMessage.UserNumber renamed to UserId throughout the public API - Response and all subtypes (Text, Template, Reaction, Typing, CTA, Flow, Anonymous) updated accordingly - Message.jq updated to extract contacts[].user_id (BSUID) when present, falling back to messages[].from; Number only set when distinguishable - WhatsAppClientExtensions: all send methods now use UserId as the 'to' field without normalization; recipient_type is set dynamically: 'individual' for phone numbers, 'business_scoped_user_id' for BSUIDs - NormalizeNumber() removed from all send code; only applied in User constructor when setting the optional Number property - FlowDataRequest, FlowDataResponse, FlowToken updated to use UserId - Conversation, IConversationStorage, ConversationStorage, and ConversationHandler updated to use UserId as the partition key - Idempotency switches from User.Number to User.Id for partition keys - OpenTelemetryHandler telemetry tag updated to UserId - BsuidTests added to cover BSUID-specific webhook deserialization, recipient_type detection, and send-path behavior - AGENTS.md updated
Member
Author
🧪 Details on Ubuntu 24.04.4 LTSfrom retest v1.1.0 on .NET 10.0.7 with 💜 by @devlooped |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WhatsApp for Business is rolling out Business-Scoped User IDs (BSUIDs) for privacy. Users who opt for username-based messaging will no longer expose their phone numbers to businesses. This PR adds full SDK support for the new identifier type.
Key Changes
UserrecordUser(Name, Id, Number?)—Idis always set (phone or BSUID),Numberis nullableIsBSUIDcomputed property: true whenIdmatches the BSUID patternNumberin the constructorIMessage/ public APIUserNumbertoUserIdthroughout the public APIUserIdnow returnsUser.Id(BSUID or phone), notUser.NumberWebhook deserialization (
Message.jq)contacts[].user_id(BSUID) when present; falls back tomessages[].fromNumberis set only when a distinct phone number is availableSend path (
WhatsAppClientExtensions)recipient_typedetected dynamically:"individual"for phone numbers,"business_scoped_user_id"for BSUIDs{ISO 3166 alpha-2}.{1-128 alphanumeric}(e.g.US.13491208655302741918)NormalizeNumber()removed from send methods; only used inUserconstructorStorage / Idempotency
ConversationStorage,Idempotency: partition keys switch fromUser.NumbertoUser.IdFlows
FlowDataRequest,FlowDataResponse,FlowTokenupdated to useUserIdTests
BsuidTests.csadded with coverage for:IsBSUIDproperty onUserrecipient_typeselection based on id shapeBSUID Detection Heuristic
Format:
{ISO 3166 alpha-2 country code}.{up to 128 alphanumeric characters}(reference)US.13491208655302741918AR.aBc123XyZ549112233445554.aBc123XyZUSA.abc123Webhook Scenarios
Breaking Changes
IMessage.UserNumberrenamed toIMessage.UserIduserNumberparameter renamed touserIdIConversationStorage:numberparameters renamed touserIdConversationrecord:Numberproperty renamed toUserId