Retrieve phone number details, request verification codes, configure conversational automation, and check throughput.
- GET /{PHONE_NUMBER_ID}?fields
- GET /{WABA_ID}/phone_numbers
- POST /{PHONE_NUMBER_ID}/request_code
- POST /{PHONE_NUMBER_ID}/verify_code
- POST /{PHONE_NUMBER_ID}/conversational_automation
- GET /{PHONE_NUMBER_ID}?fields=conversational_automation
- GET /{PHONE_NUMBER_ID}?fields=throughput
- Fields can be a comma-separated string or string array.
- Verification
code_methodisSMSorVOICE. - Conversational automation supports welcome messages, prompts, and commands.
import WhatsApp from 'meta-cloud-api';
const client = new WhatsApp({
accessToken: process.env.CLOUD_API_ACCESS_TOKEN!,
phoneNumberId: Number(process.env.WA_PHONE_NUMBER_ID),
businessAcctId: process.env.WA_BUSINESS_ACCOUNT_ID!,
});
const allNumbers = await client.phoneNumbers.getPhoneNumbers();
const phoneInfo = await client.phoneNumbers.getPhoneNumberById([
'display_phone_number',
'verified_name',
]);
await client.phoneNumbers.requestVerificationCode({
code_method: 'SMS',
language: 'en_US',
});
await client.phoneNumbers.setConversationalAutomation({
enable_welcome_message: true,
prompts: ['Book a flight', 'Talk to support'],
});
const throughput = await client.phoneNumbers.getThroughput();getPhoneNumberslists numbers for the configured WABA.getPhoneNumberByIdaccepts a fields array likedisplay_phone_numberandverified_name.requestVerificationCodeusescode_methodandlanguageto deliver the code.setConversationalAutomationtogglesenable_welcome_messageand sets user-facingprompts.getThroughputreads throughput info for the phone number.