Git Product home page Git Product logo

signal2021-devs's Introduction

Talon 1 Microsite

About

This project was built as part of the SIGNAL 2021 Developer Spotlight Session. It served as the demo application that we developed on during the session but it's also the code that powers the actual Talon 1 microsite.

Supercharge your Twilio Development

This page serves as a collection of all of the resources and demo code covered during the SIGNAL session. If you want to try out the different tools you can use the Twilio CLI and SIGNAL Developer Mode and it's checkout functionality by copy pasting the respective code snippet at the beginning of each section which will open all relevant resources or clone the respective projects onto your system.

Example:

twilio signal:checkout 6f7d66b

Slides

πŸ“Š You can find the slides over on Speaker Deck

Prototyping

twilio signal:checkout b380e61

Covered Products

Source Code

Relevant Docs

Local Development

twilio signal:checkout 051c794

πŸ’» View Code Changes prototype...ui-setup

Covered Products

Source Code

Setup Project

twilio serverless:init example --template=verified-broadcast

Run local development

cd example
twilio serverless:start

Setup build tools and scripts in your package.json

npm install --save-dev react react-dom prop-types parcel-bundler concurrently ncp rimraf

In your package.json

  "scripts": {
+    "prebuild": "rimraf dist"
+    "build": "parcel build src/index.html -d dist",
+    "postbuild": "ncp assets dist",
+    "predeploy": "npm run build",
    "deploy": "twilio-run deploy",
+    "start:web": "parcel watch src/index.html -d dist",
+    "start:twilio": "twilio-run",
+    "prestart": "ncp assets dist",
-    "start": "twilio-run",
+    "start": "concurrently npm:start:web npm:start:twilio"
  },

Modify .twilioserverlessrc to specify an output directory for Assets

{
	"commands": {},
	"environments": {},
	"projects": {},
	// "assets": true 	/* Upload assets. Can be turned off with --no-assets */,
-	// "assetsFolder": "" 	/* Specific folder name to be used for static assets */,
+	"assetsFolder": "dist" 	/* Specific folder name to be used for static assets */,
	// "buildSid": null 	/* An existing Build SID to deploy to the new environment */,

Twilio Paste UI Code

Checkout the code in the src/ directory

Relevant Docs

DevOps | CI/CD

twilio signal:checkout 7b42975

πŸ’» View Code Changes devops-start...devops

Covered Products

Source Code

Terraform script for establishing resources

Deployment process

Automatic End-to-End (E2E) test with Mock API

GitHub Actions CI/CD Example

Relevant Docs

Monitoring Insights

twilio signal:checkout 797e820

πŸ’» View Code Changes monitoring-start...monitoring

Covered Products

Source Code

Create track events from the UI

In useOtp.js:

  function sendVerifyToken(phoneNumber) {
+    analytics.track('Start subscription');

    fetch('/start-verify', {

Retrieving an anonymous ID to send to the backend

In useOtp.js:

+    let anonymousId;
+    try {
+      anonymousId = analytics.user().anonymousId();
+    } catch (err) {
+      anonymousId = undefined;
+    }

    fetch('/subscribe', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
-      body: JSON.stringify({ to: phoneNumber, code, tags }),
+      body: JSON.stringify({ to: phoneNumber, code, tags, anonymousId }),
    })

Create a track event from Twilio Functions

In subscribe.js

    } else {
+      if (event.anonymousId) {
+        analytics.track({
+          anonymousId: event.anonymousId,
+          event: 'Failed Verification',
+        });
+        await analytics.flush();
+      }
      console.error('Incorrect token.');
      response.setStatusCode(401);

Relevant Docs

Other Tools

Run the demo application

For a full set of instructions on how to set up this application for local development check out the contributing guide.

License

MIT

signal2021-devs's People

Contributors

dkundel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.