Skip to main content

Scenario

WhatsApp Business messages carry a different conversational register than SMS — longer messages, richer context, and more emotional language. This job pulls WhatsApp messages from Twilio’s Messages API, creates personas representing different customer segments, then runs each persona through Mavera Speak to generate insights about how each segment perceives your brand based on real WhatsApp interactions. Flow: Twilio GET /Messages.json (filter WhatsApp) → Cluster by theme → Mavera POST /personasPOST /speak → Persona insight report

Code

Example Output

Error Handling

WhatsApp numbers use whatsapp:+{E.164} format. Filter messages by To or From containing whatsapp: prefix. The Twilio Sandbox uses whatsapp:+14155238886.
WhatsApp Business API requires customers to message first (or opt in). You can only respond within 24 hours of the last customer message. After that, you need pre-approved templates.
WhatsApp messages may include images, documents, and voice notes. The Messages API returns media URLs via MediaUrl fields. This code processes text only — extend with media download for richer analysis.