feat: Add BSUID (Business-Scoped User ID) support for WhatsApp usernames#243
Open
yHugirat wants to merge 1 commit intonetflie:mainfrom
Open
feat: Add BSUID (Business-Scoped User ID) support for WhatsApp usernames#243yHugirat wants to merge 1 commit intonetflie:mainfrom
yHugirat wants to merge 1 commit intonetflie:mainfrom
Conversation
Starting March 31, 2026, WhatsApp webhooks will include Business-Scoped User IDs (BSUIDs) and may omit phone numbers for users who enable the username feature. This change makes the SDK forward-compatible with these API changes while maintaining full backward compatibility. Changes: - Customer: Make phone_number and wa_id nullable, add user_id (BSUID), username, and parent_user_id fields with accessor methods - MessageNotificationFactory: Safely handle missing `from` and `wa_id` fields, extract new `from_user_id`, `user_id`, `username`, and `parent_user_id` from webhook payloads - StatusNotification: Make recipient_id nullable, add recipient_user_id and parent_recipient_user_id fields - StatusNotificationFactory: Safely handle missing `recipient_id`, extract `recipient_user_id` and `parent_recipient_user_id` All changes are backward-compatible - existing phone-based flows work unchanged. New BSUID fields are captured when present in webhooks. See: https://developers.facebook.com/docs/whatsapp/business-management/business-scoped-user-ids
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Starting March 31, 2026, WhatsApp webhooks will begin including Business-Scoped User IDs (BSUIDs) and may omit phone numbers for users who enable the new username feature. This PR makes the SDK forward-compatible with these breaking API changes while maintaining full backward compatibility.
See Meta's documentation: Business-scoped user IDs
Changes
Support\Customer$id(wa_id) and$phone_number(from) nullable — these fields will be omitted when a user enables usernames and the phone number cannot be included$user_id(BSUID),$username,$parent_user_iduserId(),username(),parentUserId()identifier()(returns best available ID),hasPhoneNumber(),hasBsuid()MessageNotificationFactoryfromandwa_idfields using null coalescing (?? null)user_id,from_user_id,username,parent_user_id,from_parent_user_idCustomerconstructorStatusNotification$customer_id(recipient_id) nullable — will be omitted for BSUID-targeted messages$recipient_user_idand$parent_recipient_user_idfieldsrecipientUserId(),parentRecipientUserId(),recipientIdentifier()StatusNotificationFactoryrecipient_idusing null coalescingrecipient_user_idandparent_recipient_user_idfrom status webhooksBackward Compatibility
All changes are fully backward-compatible:
customer()->phoneNumber()continues to work (returns phone when available)nullstringto?stringwhere fields may now be omittedTimeline
recipientfieldTest plan
from, nowa_id)Customer::identifier()returns phone when available, BSUID as fallbackStatusNotificationhandles missingrecipient_id