I'm implementing WhatsApp integration using AWS End User Messaging Social in a Python Lambda function. While I can successfully receive WhatsApp messages via SNS webhooks and create cases in my application, I'm unable to send WhatsApp messages back to customers due to persistent InvalidParametersException errors.
Environment Details
Service: AWS End User Messaging Social
Region: eu-central-1
Runtime: Python 3.13 Lambda
boto3: Latest version
Phone Number ID: I have a verified WhatsApp Business number with a phone number id
Current Setup
WhatsApp Business Account properly linked to AWS End User Messaging Social
Receiving incoming messages works perfectly (webhook → SNS → Lambda → case creation)
IAM permissions include: social-messaging:SendWhatsAppMessage, social-messaging:GetWhatsAppMessageMedia
Phone number verified and active for receiving messages
The Issue
When attempting to send WhatsApp messages using send_whatsapp_message(), I consistently get InvalidParametersException with varying error messages depending on the format used:
Error Variations:
"Failed to parse WhatsApp message request" - with certain message formats
"Invalid message version" - with different API versions
Code Attempts
I've tried multiple combinations based on AWS documentation:
Message Format Variations:
python# Attempt 1: Base64-encoded bytes
message_data = base64.b64encode(json.dumps(whatsapp_message).encode('utf-8'))
Attempt 2: Base64-encoded string
message_data = base64.b64encode(json.dumps(whatsapp_message).encode('utf-8')).decode('utf-8')
Attempt 3: JSON string
message_data = json.dumps(whatsapp_message)
Attempt 4: JSON bytes
message_data = json.dumps(whatsapp_message).encode('utf-8')
API Versions Tested:
v20.0, v19.0, v18.0, v17.0, v16.0, v15.0, v14.0, v13.0
WhatsApp Message Structure:
pythonwhatsapp_message = {
"messaging_product": "whatsapp",
"to": "254719123***", # Kenya phone number (cleaned, international format)
"type": "text",
"text": {
"body": "Hi {name}, Thank you for contacting our support team"
}
}
API Call:
pythonresponse = social_messaging_client.send_whatsapp_message(
originationPhoneNumberId="phone-number-id-{id}",
metaApiVersion="v20.0", # Also tried v15.0, v18.0, etc.
message=message_data
)
What Works vs What Doesn't
✅ Working: Receiving WhatsApp messages via webhooks
✅ Working: Parsing incoming message data
✅ Working: Creating support cases from WhatsApp messages
❌ Not Working: Sending WhatsApp messages back to customers
Questions
What is the correct message parameter format for send_whatsapp_message()? Should it be Base64-encoded bytes, Base64-encoded string, or raw JSON?
Which metaApiVersion is supported by AWS End User Messaging Social? The documentation mentions v15.0, but I've seen references to v20.0 in Meta's documentation.
Are there any specific requirements for the WhatsApp message structure when using AWS End User Messaging Social vs direct Meta WhatsApp Business API?
Has anyone successfully implemented bidirectional WhatsApp messaging using AWS End User Messaging Social in Python? If so, could you share a working code example?
Use Case Context
We're building a multi-channel customer support platform that handles:
Email support (working ✅)
Web portal submissions (working ✅)
WhatsApp support (partially working - can receive but not send)
The goal is to provide automatic acknowledgement messages when customers contact us via WhatsApp, and enable agents to reply from our dashboard.
What I've Already Tried
Followed AWS End User Messaging Social documentation exactly
Tested all combinations of message formats and API versions
Verified IAM permissions and WhatsApp Business Account setup
Confirmed phone number formatting (international format, 10-15 digits)
Contacted AWS Support (got general guidance but no working example)
Any help or working examples would be greatly appreciated! This seems like it should be straightforward, but the documentation lacks specific Python implementation details for the message parameter format.