You can use your PostHog event data to send SMS messages via Twilio. Here's everything you need to get started.
Requirements
Using this requires either PostHog Cloud with the data pipelines add-on, or a self-hosted PostHog instance running a recent version of the Docker image.
Configuring Twilio
First, you'll need to create a Twilio account if you don't have one already. Then, gather the following credentials from your Twilio dashboard:
- Account SID: Found on your Twilio Console Dashboard
- Auth Token: Found on your Twilio Console Dashboard
- From Phone Number: This is the Twilio phone number you'll be sending messages from. You can find or purchase one in the Phone Numbers section of your Twilio account.
Configuring PostHog's Twilio destination
- In PostHog, click the Data pipeline tab in the left sidebar.
- Click the Destinations tab.
- Click New destination and choose Twilio's Create button.
Enter your Account SID, Auth Token, and From Phone Number from Twilio. The recipient phone number can be extracted from your event properties.
Important: The SMS body template has a character limit of 1600 characters. Messages exceeding this limit will fail to send.
Filtering
Make sure to filter events to only those that contain a valid phone number property, as this is required for sending SMS messages.
Testing
Once you've configured your Twilio destination, click Start testing to verify everything works the way you want. Switch off Mock out async functions in order to send a test SMS message via Twilio.
Option | Description |
---|---|
Account SID Type: string Required: True | |
Auth Token Type: string Required: True | |
From Phone Number Type: string Required: True | Your Twilio phone number (e.g. +12292109687) |
Recipient Phone Number Type: string Required: True | The phone number to send SMS to (e.g. +491633950489) |
SMS Body Template Type: string Required: True | Limited to 1600 characters - exceeding this will cause failures. |
FAQ
Is the source code for this destination available?
PostHog is open-source and so are all the destinations on the platform. The source code is available on GitHub.
What happens if the SMS body exceeds 1600 characters?
If your SMS body template generates a message longer than 1600 characters, the message will fail to send. Make sure to keep your templates concise or include logic to truncate long messages.
What phone number format is required?
Phone numbers should be in E.164 format (e.g., +1234567890). This includes the country code preceded by a plus sign, followed by the phone number without spaces or special characters.
Who maintains this?
This is maintained by PostHog. If you have issues with it not functioning as intended, please let us know!
What if I have feedback on this destination?
We love feature requests and feedback. Please tell us what you think.
What if my question isn't answered above?
We love answering questions. Ask us anything via our community forum.