Sending an SMS with Twilio
Sending encrypted data to a third-party.
Let’s create three Twilio environment variables inside Replit.
Paste this code into your
index.js file to initialize the Twilio SDK:
Next, update the
if block of your
POST /submit handler to include the following:
This is what your completed
index.js file should look like:
If you submit the form with your real phone number, you should receive an SMS:
Hello, Claude Shannon!.
That’s it! You’ve built a fully-functioning encrypted app with Evervault.
Let’s summarize what you’ve built. You’ve:
- Created an Express.js server (
- Created a HTML form for collecting a name and a phone number from a user (
- Connected your HTML form to your Express.js server,
- Integrated Evervault Relay so that phone numbers submitted to your form are encrypted before they enter your server,
- Included the Evervault SDK so that outbound requests from your server are automatically decrypted,
- Deployed a Cage to verify that phone numbers are valid, and
- Integrated the Twilio SMS API to send a user a text — without ever handling their phone number in plaintext.