-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(templates): add Opt In Builder template #261
Open
cweems
wants to merge
38
commits into
twilio-labs:main
Choose a base branch
from
cweems:optin-builder
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
f4eabba
Initial commit
cweems a4390a0
Working dynamic values
cweems b1fefd7
Working variable save
cweems d3f6ba4
Working webhook integration
cweems 2e06b06
Refactor to move functions to utils, add authentication
cweems 236f510
Update Readme and make data tab pills update from settings
cweems bddf0a6
Save data source to backend
cweems 036d0ba
Fix bug on TOS page
cweems a3a2b26
Update Readme
cweems d1e792f
Fix Segment and Airtable
cweems 9d39e64
Add screenshot to readme
cweems a95bbd2
Fix json stringify issue in get-settings.js, layout html for cwarren …
cweems 87beb12
Add more flexible message frequency editor
cweems 195c53a
Merge pull request #3 from cweems/dev
cweems c8fe0a7
Add tests for get-settings
cweems 3f01b81
Working save-settings test, removed baseUrl as unnecesasry
cweems 8cfe35d
Working send-sms tests
cweems c60581b
Working back-end tests for compliance language warning
cweems 309dd0b
Add compliance warning
cweems f883cd7
Rename tests and add comments to .env
cweems 394fb6e
Add 'optin-builder/' from commit 'f883cd7dd18c028403b35edf76de15b467e…
cweems f61aefb
Change invalid prettier settings, lint public.js
cweems 6e91e2c
Fully linted project with prettier/eslint passing
cweems b46d0fe
Fix get settings tests
cweems 619ee76
Add dependencies to function-templates
cweems a58095c
Add .env file to optin-builder
cweems 4d33998
Add additional packages to main function-templates package.json
cweems e2da4e2
Update tests with relative import
cweems 15738ef
Change references to Twilio response in tests
cweems 4ea6dd8
Add gitignore file
cweems 1cdc4a1
Update templates.json with required information
cweems 4c5aadf
Working receive-sms test
cweems 423ae03
Merge branch 'main' into optin-builder
cweems 07532cf
Expand tests on receive-sms
cweems e566dd3
Merge branch 'optin-builder' of github.com:cweems/function-templates …
cweems 208014a
Fix base-url generation and simplify receive-sms function
cweems c285f5a
Fix merge conflict with main
cweems e585675
Remove .gitignore, .twilio-tunctions, .twiliodeployinfo
cweems File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# description: Your Twilio phone number for sending and receiving messages. | ||
# format: phone_number | ||
# required: true | ||
TWILIO_PHONE_NUMBER= | ||
|
||
# description: Set your phone number as the username for making edits to your app. | ||
# format: secret | ||
# required: true | ||
ADMIN_PHONE_NUMBER= | ||
|
||
# description: Set a password for your app. You'll use this later to change your opt-in settings. | ||
# format: secret | ||
# required: true | ||
ADMIN_PASSWORD= | ||
|
||
# description: Public URL to the organization's logo. | ||
# configurable: false | ||
LOGO_URL="/placeholder-icon.png" | ||
|
||
# description: Title of the opt-in campaign. | ||
# configurable: false | ||
CAMPAIGN_TITLE="" | ||
|
||
# description: Brief description of the opt-in campaign. | ||
# configurable: false | ||
CAMPAIGN_DESCRIPTION="" | ||
|
||
# description: Statement of how often the subscriber will receive messages (e.g. 4 msgs / month.). | ||
# configurable: false | ||
MESSAGE_FREQUENCY="" | ||
|
||
# description: Text on the registration button. | ||
# configurable: false | ||
BUTTON_CTA="Join" | ||
|
||
# description: Keyword that users can text to opt-in to the campaign. | ||
# configurable: false | ||
OPT_IN_KEYWORD= | ||
|
||
# description: Confirmation message sent to user once they have subscribed. | ||
# configurable: false | ||
SUBSCRIBE_CONFIRMATION= | ||
|
||
# description: Contact information for Terms of Service. | ||
# configurable: false | ||
CONTACT_INFORMATION="" | ||
|
||
# description: Public URL to a custom CSS file that will be loaded when the form renders. | ||
# configurable: false | ||
CUSTOM_CSS= | ||
|
||
# description: Background color of the page. | ||
# configurable: false | ||
BACKGROUND_COLOR= | ||
|
||
# description: Font color of the page. | ||
# configurable: false | ||
FONT_COLOR= | ||
|
||
# description: Link to your organization's privacy policy. | ||
# configurable: false | ||
PRIVACY_POLICY_LINK="" | ||
|
||
# description: Indicates which type of data storage will be used (Segment, Airtable, or Webhook). | ||
# configurable: false | ||
DATA_SOURCE= | ||
|
||
# description: Segment write key. | ||
# configurable: false | ||
SEGMENT_WRITE_KEY= | ||
|
||
# description: Airtable API key. | ||
# configurable: false | ||
AIRTABLE_API_KEY= | ||
|
||
# description: Airtable Base ID. | ||
# configurable: false | ||
AIRTABLE_BASE_ID= | ||
|
||
# description: Airtable table name. | ||
# configurable: false | ||
AIRTABLE_TABLE_NAME= | ||
|
||
# description: Airtable phone number column name. | ||
# configurable: false | ||
AIRTABLE_PHONE_COLUMN_NAME= | ||
|
||
# description: Airtable opt-in column name. | ||
# configurable: false | ||
AIRTABLE_OPT_IN_COLUMN_NAME= | ||
|
||
# description: Webhook URL to send opt-in events to. | ||
# configurable: false | ||
WEBHOOK_URL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"projects": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"AC139e28468482228e22b97bf74b16518e": { | ||
"serviceSid": "ZS59e342d129924a76c27c60fd9ef35c7e", | ||
"latestBuild": "ZBbe5f6c20c73f970079280f6a7e1d6a17" | ||
}, | ||
"AC6c5eeabad12e491f36ab59fed35282ba": { | ||
"serviceSid": "ZS5bd403bfd197f0f7d05c04cd5e0e93d8", | ||
"latestBuild": "ZB45c88c27989d049f9519f6c9deeb41b7" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Twilio Opt-In Builder | ||
|
||
Easily create an embedable SMS Opt-In form to collect contacts for your campaign. | ||
|
||
 | ||
|
||
## Key Features | ||
|
||
* Live editor allows you to preview your signup form. | ||
* Customizable logo, content, and colors. | ||
* Generate compliance language and terms of service. | ||
* Track opt-ins via webhook, Segment, or Airtable. | ||
* Supports one-click keyword opt-in on Android and iOS. | ||
|
||
## Pre-requisites | ||
|
||
1. Install the [Twilio CLI](https://www.twilio.com/docs/twilio-cli/quickstart#install-twilio-cli) | ||
2. Install the [serverless toolkit](https://www.twilio.com/docs/labs/serverless-toolkit/getting-started): | ||
|
||
```shell | ||
twilio plugins:install @twilio-labs/plugin-serverless | ||
``` | ||
## Setup | ||
|
||
3. Clone the repository and `cd` into it: | ||
```shell | ||
git clone [email protected]:cweems/twilio-keyword.git | ||
|
||
cd twilio-keyword | ||
``` | ||
4. Install dependencies: | ||
```shell | ||
npm install | ||
``` | ||
5. Create `.env` file and set environment variables: | ||
```shell | ||
cp .env.example .env | ||
``` | ||
> Note: you'll need to set `ACCOUNT_SID`, `AUTH_TOKEN`, `TWILIO_PHONE_NUMBER`, `ADMIN_PHONE_NUMBER`, and `ADMIN_PASSWORD` before deploying. All other environment variables can be set by the opt-in builder. If you're using Quick Deploy, these initial environemnt variables will be set for you. | ||
|
||
6. Deploy to Twilio Serverless: | ||
```shell | ||
twilio serverless:deploy | ||
|
||
# View your opt-in builder at https://[my-runtime-url].twil.io/index.html | ||
``` | ||
|
||
7. Optional: develop locally if you want to edit HTML / CSS / JavaScript: | ||
```shell | ||
twilio serverless:start --live | ||
``` | ||
|
||
### Environment Variable Reference | ||
If you're running this project locally, you'll need to manually set environment variables in your `.env` file. When run on Twilio Serverless, environment variables are automatically set when you click the `Save Settings` button. | ||
|
||
To keep your tokens and secrets secure, make sure to not commit the `.env` file in git. When setting up the project with `twilio serverless:init ...` the Twilio CLI will create a `.gitignore` file that excludes `.env` from the version history. | ||
|
||
| Environment Variable | Description | Required? | | ||
|-----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------| | ||
| ACCOUNT_SID | Your Twilio Account SID | Required | | ||
| AUTH_TOKEN | Your Twilio Account Auth Token | Required | | ||
| TWILIO_PHONE_NUMBER | The phone number that you will send SMS opt-ins from. | Required | | ||
| ADMIN_PHONE_NUMBER | Your personal phone number, we use this as a username when you save settings, and also to send you and SMS when your configuration changes. | Required | | ||
| ADMIN_PASSWORD | Your password for updating settings via the live editor. | Required | | ||
| LOGO_URL | A publicly accessible link to your organization's logo. | Recommended | | ||
| CAMPAIGN_TITLE | The title of your opt-in page campaign. It should indicate what kinds of SMS your user is signing up for. | Required for compliance | | ||
| CAMPAIGN_DESCRIPTION | A brief description of your opt-in campaign. What types of messages will the user receive? | Required for compliance | | ||
| MESSAGE_FREQUENCY | The number of messages and cadence that a user will receive messages. | Required for compliance | | ||
| BUTTON_CTA | The text on the button to register for the campaign. | Recommended | | ||
| OPT_IN_KEYWORD | The keyword that the user must respond with for double opt-in. | Required for compliance | | ||
| SUBSCRIBE_CONFIRMATION | The message that the user will receive once they have confirmed using double opt-in. | Required for compliance | | ||
| CONTACT_INFORMATION | Your organization's contact information for compliance purposes (included in the Terms of Service). This could be a support email or toll-free number. | Required | | ||
| CUSTOM_CSS | A link to a custom stylesheet. | Optional | | ||
| BACKGROUND_COLOR | The background color for your signup page. | Optional | | ||
| FONT_COLOR | The font color for your signup page. | Optional | | ||
| PRIVACY_POLICY_LINK | A link to your organization's privacy policy. | Recommended required for compliance | | ||
| DATA_SOURCE | The data storage destination for your opt-ins. Can be `webhook`, `airtable`, or `segment`. | Optional | | ||
| SEGMENT_WRITE_KEY | The write key for your Segment Node.js source. Will be used to track opt-in events. | Optional | | ||
| AIRTABLE_API_KEY | API key for your Airtable base if you are storing opt-ins in Airtable. | Optional | | ||
| AIRTABLE_BASE_ID | Base ID for the Airtable base where you'll be storing opt-ins. | Optional | | ||
| AIRTABLE_TABLE_NAME | Name of the table where you'll be storing your opt-ins. | Optional | | ||
| AIRTABLE_PHONE_COLUMN_NAME | Name of the Airtable column where you'll store the phone numbers of your opt-ins. We'll check this column for existing opt-ins and remove the opt-in if the user responds with a stop word. | Optional | | ||
| AIRTABLE_OPT_IN_COLUMN_NAME | Name of the column where you'll store opt-in status in Airtable. Values can be true / false. | Optional | | ||
| WEBHOOK_URL | URL to a webhook on your own custom app that will receive Opt-In events. | Optional | | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was receiving errors from prettier saying that
allow
was deprecated, so I updated these configurations to match their new convention.