This guide explains where to create or find:
WHATSAPP_ACCESS_TOKENWHATSAPP_PHONE_NUMBER_IDWHATSAPP_VERIFY_TOKENWHATSAPP_APP_SECRET
Use these official Meta/WhatsApp websites:
- Meta for Developers: https://developers.facebook.com/
- Your Meta apps: https://developers.facebook.com/apps/
- WhatsApp Developer Hub: https://whatsappbusiness.com/developers/developer-hub/
- Meta Business Suite: https://business.facebook.com/
- Graph API Explorer: https://developers.facebook.com/tools/explorer/
- Access Token Debugger: https://developers.facebook.com/tools/debug/accesstoken/
- Go to https://developers.facebook.com/
- Log in with your Facebook account.
- Complete developer account registration if Meta asks.
- Go to https://developers.facebook.com/apps/
- Click Create App.
- Choose a business/business messaging app type if Meta asks.
- Create or select your Meta Business Portfolio.
- Finish creating the app.
- Open your app in Meta for Developers.
- In the left menu, find Add product.
- Add WhatsApp.
- Open WhatsApp > API Setup or WhatsApp > Getting Started.
Meta may create a test WhatsApp number and WhatsApp Business Account for you during this flow.
Use this first for testing.
- Open your Meta app.
- Go to WhatsApp > API Setup or WhatsApp > Getting Started.
- Copy the Temporary access token.
- Paste it into
.env:
WHATSAPP_ACCESS_TOKEN=your-temporary-access-tokenTemporary tokens expire. They are okay for testing, not production.
In the same WhatsApp > API Setup page, find:
- Test number
- Phone number ID
- WhatsApp Business Account ID
Copy Phone number ID into .env:
WHATSAPP_PHONE_NUMBER_ID=your-phone-number-idImportant: this is not the visible phone number. It is Meta's internal ID for that WhatsApp sender number.
For test mode, Meta only sends messages to verified recipient numbers.
- In WhatsApp > API Setup, find the recipient/to phone number area.
- Add your personal phone number as a test recipient.
- Meta will send a verification code.
- Enter the code in the dashboard.
Now your app can send test messages to your phone.
You create this yourself. Meta does not generate it.
Example:
openssl rand -hex 32Copy the generated value into .env:
WHATSAPP_VERIFY_TOKEN=your-random-long-secretYou will paste the same value into Meta when setting up the webhook.
First run the local app:
npm startExpose it with ngrok:
ngrok http 3000Copy the HTTPS ngrok URL.
In Meta:
- Open your app.
- Go to WhatsApp > Configuration or Webhooks.
- Click Edit for callback URL.
- Callback URL:
https://your-ngrok-url/webhook
- Verify token:
same value as WHATSAPP_VERIFY_TOKEN
- Click Verify and Save.
- Subscribe to the WhatsApp messages webhook field.
If verification fails, check:
- Your local app is running.
- ngrok is running.
- The callback URL ends with
/webhook. - The verify token matches exactly.
- Your server returns the
hub.challengevalue.
This project already handles that in src/whatsapp/webhook.js.
This is optional for local testing but recommended.
- Open your app in Meta for Developers.
- Go to App settings > Basic.
- Find App secret.
- Click show/copy.
- Put it in
.env:
WHATSAPP_APP_SECRET=your-meta-app-secretThis lets the server verify that webhook calls came from Meta.
Do this after temporary token testing works.
- Go to https://business.facebook.com/
- Open Business settings.
- Go to Users > System users.
- Create a system user.
- Assign assets:
- your Meta app
- your WhatsApp Business Account
- Generate a token for your app.
- Select permissions:
whatsapp_business_messagingwhatsapp_business_management
- Copy the token immediately and store it safely.
- Replace
WHATSAPP_ACCESS_TOKENin.envor AWS Lambda environment variables.
For production, store this token in AWS Systems Manager Parameter Store or AWS Secrets Manager instead of plain text.
For MVP testing, use Meta's test number first.
For a real number:
- Go to Meta Business Suite or WhatsApp Manager.
- Open your WhatsApp Business Account.
- Go to Phone numbers.
- Click Add phone number.
- Enter business display name and phone number.
- Verify using SMS or voice call.
- After verification, copy the new Phone number ID.
- Update:
WHATSAPP_PHONE_NUMBER_ID=your-real-phone-number-idImportant:
- The phone number should be able to receive SMS or voice calls.
- A normal WhatsApp/WhatsApp Business app number may need to be removed or migrated before Cloud API registration.
- Your display name may need Meta review before production messaging.
PORT=3000
OPENAI_API_KEY=sk-your-openai-api-key
OPENAI_MODEL=gpt-5.5
WHATSAPP_ACCESS_TOKEN=your-meta-token
WHATSAPP_PHONE_NUMBER_ID=your-phone-number-id
WHATSAPP_VERIFY_TOKEN=your-random-verify-token
WHATSAPP_APP_SECRET=your-meta-app-secret
DRY_RUN=true
AUTO_REPLY=trueStart with DRY_RUN=true. Change to DRY_RUN=false only after webhook testing works.