Integrating Twilio with Microsoft Power Pages enables you to send real-time alerts via SMS or WhatsApp when users submit forms, upload documents, or perform any predefined actions. Twilio offers reliable global messaging APIs, making it a powerful tool for instant user engagement.
In this guide, you’ll learn how to:
- Trigger messages from Power Pages submissions
- Set up Twilio SMS/WhatsApp alerts using Power Automate
- Secure and scale the integration for enterprise-grade use
Use Cases
- OTPs for user registration or authentication
- Confirmation messages after form submissions
- Alerts to admins for new submissions or file uploads
- Customer support workflows and appointment reminders
Architecture
mathematicaCopyEditUser → Power Pages Form → Dataverse → Power Automate → Twilio API → SMS/WhatsApp
Prerequisites
- Microsoft Power Pages Site
- Dataverse Table (e.g., for registrations)
- Power Automate Access
- Twilio Account
- SMS number / WhatsApp-enabled number
- Verified sender (for WhatsApp sandbox)
- Auth Token and Account SID
Step-by-Step Integration
Step 1: Setup Your Twilio Account
- Go to https://www.twilio.com
- Sign up / log in
- Get your:
- Account SID
- Auth Token
- Phone Number (SMS or WhatsApp enabled)
For WhatsApp, follow the Twilio Sandbox setup:
Messaging → Try It Out → Send a WhatsApp Message → Join the sandbox
Step 2: Create a Dataverse Table
- In Power Apps, create a table like
UserMessages
- Add columns:
- Full Name
- Phone Number (Text)
- Message Sent (Yes/No)
- Channel (SMS/WhatsApp)
- Create a form in Power Pages bound to this table
Step 3: Configure Power Pages Form
- Navigate to Power Pages Studio
- Add a Basic Form bound to
UserMessages
- Publish your site
- Ensure the phone number input is valid (country code included)
Step 4: Create Power Automate Flow to Send SMS/WhatsApp
A. Trigger
- Type: Automated Cloud Flow
- Trigger:
When a row is added
(Dataverse) - Table Name:
UserMessages
- Scope: Organization
B. Compose Message Content (Optional)
- Add
Compose
action:
plaintextCopyEditHi @{triggerOutputs()?['body/FullName']}, thanks for contacting us. We'll get back to you shortly!
C. Send Message via Twilio API
- Add an HTTP action
For SMS
- Method:
POST
- URL:
https://api.twilio.com/2010-04-01/Accounts/{AccountSID}/Messages.json
- Authentication: Basic
- Username:
AccountSID
- Password:
AuthToken
- Username:
- Headers:
{
"Content-Type": "application/x-www-form-urlencoded"
}
- Body:
To=+91XXXXXXXXXX
&From=+1XXXXXXX (Twilio Number)
&Body=Hi [Name], your form is received!
For WhatsApp
- Same as SMS, but:
To=whatsapp:+91XXXXXXXXXX
From=whatsapp:+1XXXXXXXXXX
D. Update the Record
- Add
Update a row
(Dataverse) - Mark
Message Sent = true
Optional: Add Conditions Based on Channel
If your table has a column Channel
, use a Condition:
- If
Channel = WhatsApp
→ use WhatsApp API - Else → use SMS API
Security and Governance
- Store Twilio Auth tokens in Azure Key Vault or Power Automate environment variables
- Use phone number validation in Power Pages with RegEx
- Limit message frequency (no spam)
- Monitor API usage via Twilio Console
Best Practices
- Always prepend
+CountryCode
to phone numbers (e.g., +91) - Use WhatsApp Templates for pre-approved messages
- For production, use verified numbers (especially WhatsApp)
- Add logging in Power Automate for error tracking
- Implement retry logic if messages fail
Testing
- Submit a form on your Power Pages site
- Open your mobile device
- Check for real-time message from Twilio (SMS or WhatsApp)
- Review Twilio dashboard for delivery status
Real-Life Scenarios
Scenario | Message |
---|---|
OTP/Verification | “Your code is 5729. Do not share it with anyone.” |
Appointment Confirmed | “Hi James, your appointment is confirmed for 3:00 PM on April 26.” |
Submission Received | “Hello Riya, we have received your document. Thank you!” |
Admin Alert | “New inquiry submitted by Paul at 10:15 AM” |
Common Errors & Fixes
Issue | Solution |
---|---|
Message not sent | Check Twilio Auth Token, From/To format |
Invalid WhatsApp number | Join WhatsApp Sandbox or use approved senders |
Rate limiting | Monitor Twilio account usage, increase limits |
Power Automate error | Review Flow Run history for status codes (401, 403, 500) |
Advanced Extensions
- Send Bulk Messages using
Apply to each
in Power Automate - Store message logs in SharePoint or Dataverse
- Integrate with Dynamics CRM to automate lead follow-ups
- Set expiry timers for OTPs using scheduled flows
- Two-way chat using Twilio Studio and Azure Bot Framework