Skip to content
  • Sign Up
  • Pricing
  • Savings Calculator
  • About
  • LinkedIn
  • Twitter
  • Home
  • Email Marketing
    • AI In Email
    • Email Deliverability
    • Email Segmentation
    • Amazon SES
    • Integration
  • Whatsapp Marketing
  • SMS Marketing
  • Customer Retention
CampaignHQ Blog Logo
CampaignHQ Blog Logo

CampaignHQ Blog | Email & WhatsApp Marketing Automation Tips

  • Home
  • Amazon SES
  • How to Integrate AWS WhatsApp API: A Step-by-Step Guide for Developers
Categories Amazon SES

How to Integrate AWS WhatsApp API: A Step-by-Step Guide for Developers

  • Vishal Singhal
  • Estimated read time 11 min read
  • May 7, 2025

WhatsApp dominates the messaging world with 2.3 billion active users and leads in over 100 countries. Did you know that?

AWS launched End User Messaging Social to help developers send WhatsApp messages to their end users. This integration lets developers build budget-friendly chatbots and manage AWS resources through WhatsApp messages. The results speak for themselves – Duolingo’s success story shows a 12% boost in verification rates and an impressive 87% cost reduction by combining SMS fallback with WhatsApp messaging.

Let’s walk through the AWS WhatsApp API integration using Amazon Pinpoint’s multichannel platform. The platform supports six different channels including SMS, email, and push notifications. You’ll learn everything from initial setup to testing your WhatsApp messaging system.

Does WhatsApp use AWS?

AWS and WhatsApp have a complex relationship. WhatsApp doesn’t run solely on AWS infrastructure, but AWS provides resilient services built for WhatsApp Business integration.

AWS End User Messaging Social lets developers connect WhatsApp Business Accounts directly to their AWS environments. This native integration makes it easier to build connections between customer WhatsApp interactions and AWS workloads.

The architecture works like this: AWS End User Messaging Social gets a WhatsApp message that triggers an Amazon Simple Notification Service (SNS) notification. This activates an AWS Lambda function. The function processes the request and sends the response back to users through WhatsApp. This setup powers complex business workflows and automated WhatsApp marketing campaigns.

AWS gives developers two ways to integrate WhatsApp:

  1. Direct integration – Set up a new WhatsApp Business Account through AWS’s self-guided onboarding
  2. Existing account connection – Connect your current WhatsApp Business Account to AWS End User Messaging

These setups work for both sending and receiving messages:

  • Outbound messaging: Amazon Pinpoint’s custom channel employs an AWS Lambda function that makes API calls to WhatsApp with the access token, customer’s mobile number, and message template
  • Inbound messaging: Amazon API Gateway acts as the callback URL while AWS Lambda handles authorization and messages

AWS End User Messaging Social sends cost metrics to CloudWatch. This helps track key data points like WhatsAppMessageFeeCount and WhatsAppConversationFeeCount.

The service runs in seven AWS regions, including US East (N. Virginia), US West (Oregon), Europe (London), and Asia Pacific (Singapore). WhatsApp Business Accounts need verification, which takes up to two weeks.

Note that WhatsApp has its own terms, policies, and fees beyond AWS services before you start any integration project.

Set Up WhatsApp Business API and AWS prerequisites

The WhatsApp Business API integration with AWS needs some groundwork before you start. You should create accounts and get the right credentials first.

Create a Meta Developer account and app

Log into your Facebook account to access the Meta for Developers platform. Here’s what you need to do:

  1. Click “Create App” in the dashboard
  2. Select “Business” as the app type
  3. Enter a display name and contact email
  4. Choose to attach a Business Account or create a new one
  5. After creation, go to WhatsApp section and click “Set up“

Meta will set up a temporary test phone number automatically for your development. You’ll need the Phone Number ID from the WhatsApp → API Setup page later.

Generate a permanent WhatsApp access token

Production systems can’t work with standard access tokens that expire in 24 hours. Here’s what to do instead:

  1. Open Meta’s Business Manager and select your business
  2. Go to Users → System Users and create a new system user
  3. Set its role as Admin and click “Create System User”
  4. Use “Add Assets” to link this user with your WhatsApp app
  5. Generate a token and select “Permanent” as expiration
  6. Choose both whatsapp_business_messaging and whatsapp_business_management permissions
  7. Store this token safely for later use

Create an Amazon Pinpoint project and custom endpoint

Your AWS messaging setup needs these steps:

  1. Access the Amazon Pinpoint console
  2. Create a new project with a unique name
  3. Enable the SMS channel in project settings
  4. Set up a CUSTOM endpoint in Pinpoint using a WhatsApp-registered phone number

Store WhatsApp credentials in AWS Secrets Manager

Your WhatsApp access credentials need proper protection:

  1. Access AWS Secrets Manager console
  2. Select “Store a new secret” and choose “Other type of secret”
  3. Enter your token as “Bearer “
  4. Name the secret “WhatsAppAccessToken“
  5. Save the secret’s ARN for later use

This setup creates a secure foundation for a reliable WhatsApp-AWS integration.

Want an Easier Way to Use the WhatsApp API?

Integrating the WhatsApp API through AWS can be complex and time-consuming. CampaignHQ makes WhatsApp automation simple—no AWS account, backend setup, or approvals required.

Try CampaignHQ’s WhatsApp Tool

Design the Messaging Architecture with AWS Services

A robust WhatsApp messaging architecture needs multiple AWS services to create reliable two-way communication channels. Your WhatsApp API prerequisites will help us design a system that handles both outbound and inbound messages well.

Amazon Pinpoint arranges outbound messages

Amazon Pinpoint provides a powerful multichannel platform that extends naturally to WhatsApp through its custom channel features. The process to send WhatsApp messages follows this efficient flow:

  1. Amazon Pinpoint campaign or experience targeting CUSTOM endpoint types triggers a Lambda function
  2. The function payload has endpoint data and the WhatsApp message template name
  3. Lambda gets the WhatsApp access token from Secrets Manager
  4. The function sends a POST request to WhatsApp’s API with the token, recipient’s number, and template
  5. WhatsApp delivers the message to the customer’s device

This approach helps you arrange WhatsApp communications among other channels like SMS and email. You can create unified customer experiences instead of disconnected messaging.

API Gateway and Lambda process inbound messages

WhatsApp needs a verification-ready Callback URL to handle incoming customer messages:

  1. Set up Amazon API Gateway as your WhatsApp webhook endpoint
  2. Create a Lambda function to process incoming webhook requests
  3. Lambda checks if the token matches the stored value when WhatsApp sends the original GET request
  4. Customer messages arrive as POST requests after verification
  5. The Lambda function gets vital data like phone number, timestamp, message ID, and content
  6. Lambda marks each processed message as “read” through WhatsApp’s API

This two-way setup lets you send messages and respond to customer interactions live.

Secrets Manager and environment variables protect message flow

Secure WhatsApp credentials are vital to build reliable integrations:

  1. Keep your WhatsApp access token in AWS Secrets Manager (format: “Bearer EEAEAE…”)
  2. Save verification tokens in Lambda environment variables
  3. Get credentials in Lambda functions only when needed
  4. Never hardcode sensitive values in your application code

CloudWatch metrics help you track WhatsApp activity through WhatsAppMessageFeeCount and WhatsAppConversationFeeCount. These metrics show your usage and costs over time.

Deploy the Integration Using AWS CloudFormation

The deployment process becomes simple once you have your prerequisites and architecture design ready. AWS CloudFormation helps you create all resources in one go.

Download and configure the CloudFormation template

CloudFormation templates let you deploy WhatsApp API integration through code-based infrastructure. Here’s how to start:

  1. Download the AWS CloudFormation template built for WhatsApp-Pinpoint integration
  2. Go to the AWS CloudFormation console in your preferred region
  3. Select “Create stack” and choose “With new resources“
  4. Under template selection, choose “Template is ready” and “Upload a template file”
  5. Upload your downloaded template file

This standard approach will give a consistent way to create all resources and makes future changes easier.

Set up API Gateway, Lambda, and Pinpoint parameters

After uploading the template, you need to set these key parameters:

  • ApiGatewayName: Name for your API Gateway resource
  • PhoneNumberId: Your WhatsApp phone number ID from Meta Developers console
  • PinpointProjectId: Amazon Pinpoint project ID created earlier
  • VerifyToken: An alphanumeric token (e.g., “123abc”) for webhook verification
  • WhatsAppAccessToken: Your permanent access token starting with “Bearer EEAEAE…”

CloudFormation automatically creates and connects all resources based on your architecture design after you submit these parameters.

Configure webhook callback URL in Meta Developer Console

After your stack creation succeeds:

  1. Copy the API Gateway endpoint URL from CloudFormation’s outputs tab
  2. Go to Meta Developers App dashboard and select “Webhooks”
  3. Under WhatsApp Business Account settings, click “Configure Webhooks”
  4. Enter your API Gateway endpoint as the Callback URL
  5. Input the same VerifyToken value used in CloudFormation
  6. Select “messages” under subscription fields
  7. Click “Verify and Save”

Your Lambda function must respond correctly to WhatsApp’s original verification request for the verification to work. Meta’s platform starts sending live notifications about incoming messages to your AWS environment after verification.

Test and Extend Your WhatsApp Messaging System

The time has come to test your WhatsApp-AWS integration framework’s functionality and discover its advanced features. This testing phase ensures everything works smoothly before customer deployment.

Send a WhatsApp message using a Pinpoint campaign

Here’s how to test outbound messaging:

  1. Go to Amazon Pinpoint Campaigns and create a new “Standard campaign”
  2. Name it “WhatsAppCampaign” and select “Custom” as your channel
  3. Choose a segment containing your CUSTOM endpoint
  4. Select the Lambda function named “WhatsAppSendMessageLambda”
  5. Under Custom data type, enter “hello_world” (your WhatsApp template)
  6. Review settings and click “Launch campaign”

Receive and log inbound messages in CloudWatch

Testing two-way communication is simple. Just send a message from your mobile to your WhatsApp Business number. The webhook processes these incoming messages automatically and stores details in CloudWatch. You can verify message receipt and processing by checking the “WhatsAppWebHookLambda” function’s logs.

Use dynamic variables in message templates

Your templates work better with personalization. Start by creating templates with variables like {{1}} and {{2}} in the Meta Developer Console. Then update your Lambda function to replace these placeholders with dynamic content:

"You made a purchase for {{1}} using a credit card ending in {{2}}."

These variables get their values from Pinpoint endpoint attributes during transmission.

Send custom text messages within 24-hour window

A 24-hour customer service window opens each time customers message your business. You can send freestyle text messages without templates during this period. Remember that approved templates are required for messages outside this window.

Add SMS fallback for non-WhatsApp users

Some customers don’t use WhatsApp. The solution is to implement SMS fallback that reaches everyone:

  1. Configure Pinpoint for both WhatsApp and SMS channels
  2. Monitor WhatsApp delivery status
  3. Trigger SMS fallback when WhatsApp fails

Conclusion

AWS WhatsApp API gives developers a chance to connect with the platform’s massive 2.3 billion active user base. This piece walked you through the key steps to build a resilient WhatsApp messaging system with AWS services. We started by showing the connection between WhatsApp and AWS. Next came the prerequisites needed to work with WhatsApp Business API. The design phase helped create an adaptable messaging setup using Amazon Pinpoint, API Gateway, Lambda, and Secrets Manager.

CloudFormation templates made the infrastructure deployment quick and simple. The system testing phase involved sending outbound messages and getting inbound communications through the new channels. Real-life results prove the value – Duolingo achieved 12% better verification rates and reduced costs by 87%.

WhatsApp integration brings great value, but you might want to add more messaging options by learning about AWS SES Connect for detailed email delivery options. This creates a unified way to communicate across different channels.

FAQ

How to integrate API to WhatsApp?

The API integration with WhatsApp happens through Meta’s developer platform. You’ll need to create a Meta Developer account and set up a business application first. Here’s how the process works:

  1. Set up a WhatsApp Business Account (WABA) through a WhatsApp Business Solution Provider or directly via AWS End User Messaging Social
  2. Get your business identity verified (this process can take up to 2 weeks)
  3. Set up a webhook callback URL to get up-to-the-minute message notifications
  4. Create a permanent access token with the right permissions

Once your account is ready, you’ll need a working webhook that responds to Meta’s verification challenges correctly. AWS API Gateway works perfectly for this need. Meta’s platform sends a verification code called “HubChallenge” and your webhook must send it back exactly to create the connection.

Can AWS send a WhatsApp message?

Yes, AWS can send WhatsApp messages in several ways. We used AWS End User Messaging Social as our main service to handle WhatsApp integration. This service lets you create new WhatsApp Business Accounts or connect your existing ones right from the AWS management console.

Amazon Pinpoint is another great way to send WhatsApp messages through its custom channel feature. Here’s how it works:

  • Create a Pinpoint campaign that targets CUSTOM endpoints
  • Use Lambda functions to get WhatsApp credentials from AWS Secrets Manager
  • Make API calls to WhatsApp with your access token and message template
Tags AWS AWS Account Suspension AWS End User Messaging Social AWS SES Sandbox Mode Integrate AWS WhatsApp

More From Author

AWS WhatsApp Chatbot

How to Build an AWS WhatsApp Chatbot: Step-by-Step Guide

  • May 8, 2025
WhatsApp through AWS

How to Build a WhatsApp Messaging System Using AWS: A Step-by-Step Guide

  • May 6, 2025
SES Sandbox Mode SES Sandbox Mode

How CampaignHQ Helps AWS Users Overcome SES Sandbox Mode Limitations

  • May 5, 2025
← How to Build a WhatsApp Messaging System Using AWS: A Step-by-Step Guide → How to Build an AWS WhatsApp Chatbot: Step-by-Step Guide
  • Sign Up
  • Pricing
  • Savings Calculator
  • About
  • About Us
  • Contact Us
  • Blog
  • FAQs
  • Privacy Policy
  • Terms Of Use
  • Acceptable Use Policy
Copyright © 2025 - KumoHQ Software Services LLP
 - Powered by Blogmarks.
  • Contact Us
  • FAQs
  • Savings Calculator
  • Home
  • Email Marketing
    • AI In Email
    • Email Deliverability
    • Email Segmentation
    • Amazon SES
    • Integration
  • Whatsapp Marketing
  • SMS Marketing
  • Customer Retention