




<!-- SDK loading --> <script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js"></script> <script> // SDK initialization window.fbAsyncInit = function() { FB.init({ appId: '<APP_ID>', // your app ID goes here autoLogAppEvents: true, xfbml: true, version: '<GRAPH_API_VERSION>' // Graph API version goes here }); }; // Session logging message event listener window.addEventListener('message', (event) => { if (!event.origin.endsWith('facebook.com')) return; try { const data = JSON.parse(event.data); if (data.type === 'WA_EMBEDDED_SIGNUP') { console.log('message event: ', data); // remove after testing // your code goes here } } catch { console.log('message event: ', event.data); // remove after testing // your code goes here } }); // Response callback const fbLoginCallback = (response) => { if (response.authResponse) { const code = response.authResponse.code; console.log('response: ', code); // remove after testing // your code goes here } else { console.log('response: ', response); // remove after testing // your code goes here } } // Launch method and callback registration const launchWhatsAppSignup = () => { FB.login(fbLoginCallback, { config_id: '<CONFIGURATION_ID>', // your configuration ID goes here response_type: 'code', override_default_response_type: true, extras: { setup: {}, } }); } </script> <!-- Launch button --> <button onclick="launchWhatsAppSignup()" style="background-color: #1877f2; border: 0; border-radius: 4px; color: #fff; cursor: pointer; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; height: 40px; padding: 0 24px;">Login with Facebook</button>
<!-- SDK loading --> <script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js"></script>
// SDK initialization
window.fbAsyncInit = function() {
FB.init({
appId: '<APP_ID>', // your app ID goes here
autoLogAppEvents: true,
xfbml: true,
version: '<GRAPH_API_VERSION>' // Graph API version here
});
};
| Placeholder | Description | Example value |
|---|---|---|
<APP_ID> | Required. Your app ID. This is displayed at the top of the App Dashboard. | 21202248997039 |
<GRAPH_API_VERSION> | Required. Graph API version. This indicates which version of Graph API to call, if you are relying on the SDK’s methods to perform API calls. In the context of Embedded Signup, you won’t be relying on the SDK’s methods to perform API calls, so we recommend that you just set this to the latest API version: v25.0 | v25.0 |
// Session logging message event listener
window.addEventListener('message', (event) => {
if (!event.origin.endsWith(‘facebook.com’)) return;
try {
const data = JSON.parse(event.data);
if (data.type === 'WA_EMBEDDED_SIGNUP') {
console.log('message event: ', data); // remove after testing
// your code goes here
}
} catch {
console.log('message event: ', event.data); // remove after testing
// your code goes here
}
});
{ data: { phone_number_id: '<CUSTOMER_BUSINESS_PHONE_NUMBER_ID>', waba_id: '<CUSTOMER_WABA_ID>', business_id: '<CUSTOMER_BUSINESS_PORTFOLIO_ID>', <!-- only included if customer selected ad accounts --> ad_account_ids: ['<CUSTOMER_AD_ACCOUNT_ID_1>', '<CUSTOMER_AD_ACCOUNT_ID_2>'], <!-- only included if customer selected Facebook Pages --> page_ids: ['<CUSTOMER_PAGE_ID_1>', '<CUSTOMER_PAGE_ID_2>'], <!-- only included if customer selected datasets --> dataset_ids: ['<CUSTOMER_DATASET_ID_1>', '<CUSTOMER_DATASET_ID_2>'], <!-- only included if customer selected catalogs --> catalog_ids: ['<CUSTOMER_CATALOG_ID_1>', '<CUSTOMER_CATALOG_ID_2>'], <!-- only included if customer selected Instagram accounts --> instagram_account_ids: ['<CUSTOMER_IG_ACCOUNT_ID_1>', '<CUSTOMER_IG_ACCOUNT_ID_2>'], <!-- only included for multi-WABA flows --> waba_ids: ['<CUSTOMER_WABA_ID_1>', '<CUSTOMER_WABA_ID_2>'] }, type: 'WA_EMBEDDED_SIGNUP', event: '<FLOW_FINISH_TYPE>', }
| Placeholder | Description | Example value |
|---|---|---|
<CUSTOMER_BUSINESS_PHONE_NUMBER_ID> | The business customer’s business phone number ID | 106540352242922 |
<CUSTOMER_WABA_ID> | The business customer’s WhatsApp Business Account ID. | 524126980791429 |
<CUSTOMER_BUSINESS_PORTFOLIO_ID> | The business customer’s business portfolio ID. | 2729063490586005 |
<CUSTOMER_AD_ACCOUNT_ID> | Only included if the customer selected ad accounts during the flow. The business customer’s ad account ID. | 4052175343162067 |
<CUSTOMER_PAGE_ID> | Only included if the customer selected Facebook Pages during the flow. The business customer’s Facebook Page ID. | 1791141545170328 |
<CUSTOMER_DATASET_ID> | Only included if the customer selected datasets during the flow. The business customer’s dataset ID. | 524126980791429 |
<CUSTOMER_CATALOG_ID> | Only included if the customer selected catalogs during the flow. The business customer’s catalog ID. | 8827498273649182 |
<CUSTOMER_IG_ACCOUNT_ID> | Only included if the customer selected Instagram accounts during the flow. The business customer’s Instagram account ID. | 1749204838281942 |
<CUSTOMER_WABA_ID> (in waba_ids array) | Only included for multi-WABA flows. Array of the business customer’s WhatsApp Business Account IDs. | 524126980791429 |
<FLOW_FINISH_TYPE> | Indicates the customer successfully completed the flow. Possible Values:
| FINISH |
{ data: { current_step: '<CURRENT_STEP>', }, type: 'WA_EMBEDDED_SIGNUP', event: 'CANCEL', }
| Placeholder | Description | Example value |
|---|---|---|
<CURRENT_STEP> | Indicates which screen the business customer was viewing when they abandoned the flow. See Embedded Signup flow errors for a description of each step. | PHONE_NUMBER_SETUP |
{ data: { error_message: '<ERROR_MESSAGE>', error_code: '<ERROR_CODE>', session_id: '<SESSION_ID>', timestamp: '<TIMESTAMP>', }, type: 'WA_EMBEDDED_SIGNUP', event: 'CANCEL', }
| Placeholder | Description | Example value |
|---|---|---|
<ERROR_MESSAGE> | The error description text displayed to the business customer in the Embedded Signup flow. See Embedded Signup flow errors for a list of common errors. | Your verified name violates WhatsApp guidelines. Please edit your verified name and try again. |
<ERROR_CODE> | Error code. Include this value if you contact support. | 524126 |
<SESSION_ID> | Unique session ID generated by Embedded Signup. Include this ID if you contact support. | f34b51dab5e0498 |
<TIMESTAMP> | Unix timestamp indicating when the business customer used Embedded Signup to report the error. Include this value if you are contacting support. | 1746041036 |
<CURRENT_STEP> values and the screens they correspond to.console.log('message event: ', data); // remove after testing
console.log('message event: ', event.data); // remove after testing
// Response callback
const fbLoginCallback = (response) => {
if (response.authResponse) {
const code = response.authResponse.code;
console.log('response: ', code); // remove after testing
// your code goes here
} else {
console.log('response: ', response); // remove after testing
// your code goes here
}
}
code constant.console.log('response: ', code); // remove after testing
console.log('response: ', response); // remove after testing
onclick event that registers the response callback from the previous step and launches the Embedded Signup flow.// Launch method and callback registration
const launchWhatsAppSignup = () => {
FB.login(fbLoginCallback, {
config_id: '<CONFIGURATION_ID>', // your configuration ID goes here
response_type: 'code',
override_default_response_type: true,
extras: {
setup: {},
}
});
}
<!-- Launch button --> <button onclick="launchWhatsAppSignup()" style="background-color: #1877f2; border: 0; border-radius: 4px; color: #fff; cursor: pointer; font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; height: 40px; padding: 0 24px;">Login with Facebook</button>