{"id":19935102,"url":"https://github.com/optimizely/twilio-serverless-sms-demo","last_synced_at":"2025-05-03T12:31:00.288Z","repository":{"id":71780630,"uuid":"107189624","full_name":"optimizely/twilio-serverless-sms-demo","owner":"optimizely","description":"An example of running an Optimizely Full Stack experiment with the Node SDK on a Twilio Programmable SMS service through their Serverless Function capability.","archived":true,"fork":false,"pushed_at":"2017-12-20T22:58:45.000Z","size":6,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-16T13:42:15.182Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/optimizely.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-16T22:25:54.000Z","updated_at":"2023-09-25T16:05:15.000Z","dependencies_parsed_at":"2023-09-15T14:00:25.936Z","dependency_job_id":null,"html_url":"https://github.com/optimizely/twilio-serverless-sms-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Ftwilio-serverless-sms-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Ftwilio-serverless-sms-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Ftwilio-serverless-sms-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/optimizely%2Ftwilio-serverless-sms-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/optimizely","download_url":"https://codeload.github.com/optimizely/twilio-serverless-sms-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252190669,"owners_count":21708922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T23:18:47.704Z","updated_at":"2025-05-03T12:31:00.280Z","avatar_url":"https://github.com/optimizely.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# twilio-serverless-sms-demo\nAn example of running an Optimizely Full Stack experiment with the Node SDK on a Twilio Programmable SMS service through their Serverless Function capability.\n\n## Tutorial\n### Optimizely Project Setup\nSet up an Optimizely Full Stack project by following our [getting started guide](https://developers.optimizely.com/x/solutions/sdks/getting-started/index.html?language=node).\n\n### Twilio Runtime Function Configuration\n1. Get a Twilio phone number by following Twilio's [getting started guide](https://www.twilio.com/docs/quickstart/node/programmable-sms#get-a-twilio-phone-number).\n2. Create a [Twilio Runtime Function ](https://www.twilio.com/docs/quickstart/runtime/programmable-sms#create-a-runtime-function)\n3. Go to the [Configure dashboard ](https://www.twilio.com/console/runtime/functions/configure)of Runtime Functions\n4. Click `Enable ACCOUNT_SID and \tAUTH_TOKEN` to make initializing Twilio Client easier.\n5. Add [`optimizely-server-sdk`](https://github.com/optimizely/node-sdk) as a dependency at `1.4.2` or use the [latest version](https://github.com/optimizely/node-sdk/releases/latest).\n6. Add ['request'](https://github.com/request/request) as a dependency at `2.83.0`.\n7. Add ['request-promise'](https://github.com/request/request-promise) as a dependency at `4.2.2`.\n\n### Implementing the Twilio Runtime Function\nExample implementation can be found in `index.js`.\n\n1. Create a new function from the `Hello SMS` template.\n2. Name the twilio function and give it a path.\n3. Copy and paste the initialization code for the Optimizely SDK from the \"Create an Optimizely Client\" section of the [Node getting started guide](https://developers.optimizely.com/x/solutions/sdks/getting-started/index.html?language=node).\n4. Grab the incoming message body. `var incomingMessage = event.Body;`\n5. Grab the incoming phone number. `var userId = event.From;`\n6. Import and initialize a hash object to anonymize phone numbers. \n\n    ```javascript\n\tvar crypto = require('crypto');\n\tvar md5sum = crypto.createHash('md5');\n\tvar userId = md5sum.update(event.From).digest('hex');\n\t```\n\n7. Check if the message body is \"Hello\"\n8. Activate the experiment and send back messages of different variations.\n9. Check if the message body is \"Yes\" or \"No\"\n10. Track the responses and thank them for participating.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimizely%2Ftwilio-serverless-sms-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foptimizely%2Ftwilio-serverless-sms-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foptimizely%2Ftwilio-serverless-sms-demo/lists"}