Skip to content
Serverless Framework example with Twilio
HTML JavaScript CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
frontend
.gitignore
.npmignore
README.md
event.json
handler.js
package.json
sample-env.json
serverless.yml

README.md

Made with Serverless Norfolk JS Inspired

Send SMS Message with Twilio

This example demonstrates how to send SMS messages with the Twilio SDK and AWS lambda.

Live the live demo

Use Cases:

  • Sending users confirmation text messages

Setup -

  1. Set up your AWS Credentials

  2. Sign up for a Twilio account

  3. Create a new phone number in your Twilio trial account

  4. Grab your ACCOUNT SID and AUTH TOKEN from the Twilio console and plug those into the env.json file in the next step

  5. Create env.json variables in serverless.yml with your Twilio account values

environment:
  # replace these env variables with your twilio account values
  TWILIO_ACCOUNT_SID: ${file(./env.json):TWILIO_ACCOUNT_SID}
  TWILIO_AUTH_TOKEN: ${file(./env.json):TWILIO_AUTH_TOKEN}
  TWILIO_PHONE_NUMBER: ${file(./env.json):TWILIO_PHONE_NUMBER}
  1. Invoke the function and send an SMS message

Update the to phone number the event.json file and message to send in the SMS

Then invoke the function with the serverless CLI. Set the --path event.json so the function knows where to send the SMS.

serverless invoke -f sendText --path event.json
  1. (Optional) Deploy the front-end application

Update the API_ENDPOINT variable in the /frontend/index.html file and deploy the /frontend folder to a static host of your choice.

You can’t perform that action at this time.