Demonstrating how to use Optimizely to test Twilio SMS content.
- Access to Optimizely Full Stack, sign up for a free dev account
- Access to Twilio functions and a phone number
- Create a new function in Twilio, copy & paste the contents of the
function.js
file into the thecode
section of your function. - Check the box above the
code
container toCheck for valid Twilio signature
. This will ensure that your Twilio Account SID and auth token are added safely to be referenced by any Twilio clients in your function. - Under the
Configure
tab of your Twilio function, check the box forEnable ACCOUNT_SID and AUTH_TOKEN
. - In this same section, add the following dependencies:
Name: @optimizely/optimizely-sdk; Version: 4.1.0
Check here for the latest Optimizely SDK version for NodejsName: request-promise; Version: 4.2.5
- Create an Optimizely Full Stack Project, retrieve your datafile URL and replace the datafile URL in the
function.js
file. - Create an experiment in Optimizely and replace the experiment key and variation keys with what you've assigned in the Optimizely app.
- Finally associate your Optimizely-Twilio function with a phone number in the Twilio app and test it out!
Optimizely does not accept PII which includes phone numbers, use the built in module crypto
to hash phone numbers before we send them as the user id
, or unique identifier, in the Optimizely activate
method. When activate
is invoked the Optimizely SDK automatically dispatches an even to Optimizely to record that this user was activated in an experiment with the experiment_key
defined and variation_key
they were bucketed into.