Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

optimizely/twilio-serverless-sms-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

twilio-serverless-sms-demo

An example of running an Optimizely Full Stack experiment with the Node SDK on a Twilio Programmable SMS service through their Serverless Function capability.

Tutorial

Optimizely Project Setup

Set up an Optimizely Full Stack project by following our getting started guide.

Twilio Runtime Function Configuration

  1. Get a Twilio phone number by following Twilio's getting started guide.
  2. Create a Twilio Runtime Function
  3. Go to the Configure dashboard of Runtime Functions
  4. Click Enable ACCOUNT_SID and AUTH_TOKEN to make initializing Twilio Client easier.
  5. Add optimizely-server-sdk as a dependency at 1.4.2 or use the latest version.
  6. Add 'request' as a dependency at 2.83.0.
  7. Add 'request-promise' as a dependency at 4.2.2.

Implementing the Twilio Runtime Function

Example implementation can be found in index.js.

  1. Create a new function from the Hello SMS template.

  2. Name the twilio function and give it a path.

  3. Copy and paste the initialization code for the Optimizely SDK from the "Create an Optimizely Client" section of the Node getting started guide.

  4. Grab the incoming message body. var incomingMessage = event.Body;

  5. Grab the incoming phone number. var userId = event.From;

  6. Import and initialize a hash object to anonymize phone numbers.

    var crypto = require('crypto');
    var md5sum = crypto.createHash('md5');
    var userId = md5sum.update(event.From).digest('hex');
  7. Check if the message body is "Hello"

  8. Activate the experiment and send back messages of different variations.

  9. Check if the message body is "Yes" or "No"

  10. Track the responses and thank them for participating.

About

An example of running an Optimizely Full Stack experiment with the Node SDK on a Twilio Programmable SMS service through their Serverless Function capability.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published