Skip to content

Automatically send Twilio voice notifications for undelivered Twilio SMS messages

License

Notifications You must be signed in to change notification settings

mdvickst/voice-notifications

Repository files navigation

Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

This project shows an example of how to build an automated Voice Notification fallback for failed Twilio SMS messages. For users who are unable to receive SMS messages using a phone call to deliver the message and provide businesses with a way to connect with their customers. Leveraging Answering Machine Detection and high quality text to speech models also allows users to leverage visual voicemail to receive the intended message.

(back to top)

Getting Started

In order to test out this project you will need to open a Twilio Account and purchase at least one Twilio Phone Number.

Prerequisites

This is an example of how to list things you need to use the software and how to install them.

  • Twilio CLI
    brew tap twilio/brew && brew install twilio
    twilio login

Installation

Below is an example of how you can instruct your audience on installing and setting up your app. This template doesn't rely on any external dependencies or services.

  1. Get a free API Key at https://example.com

  2. Clone the repo

    git clone https://github.com/mdvickst/voice-notifications
  3. Deploy to Twilio Serverless using the CLI

    cd voice-notifications
    twilio serverless:deploy
  4. Create Twilio Event Sink using the Function domain created in the previous step

    twilio api:events:v1:sinks:create --description "SMS Undelivered Sink" \
     --sink-configuration '{"destination":"https://${function_domain}/eventStreamWebhook","method":"POST","batch_events":false}' \
     --sink-type webhook
  5. Create Event Streams Susbcription using the Sink SID from the previous ttep

    twilio api:events:v1:subscriptions:create \
     --description "Subscription to SMS undelivered events" \
     --sink-sid <sink id validated above DGxxx> \
     --types '{"type":"com.twilio.messaging.message.undelivered","schema_version":3}' 

(back to top)

Usage

Call the sendSMS function with a "To" (subscriber phone number), "From" (your Twilio Phone Number), and "Body" parameters to a number which cannot receive SMS messages or is unsubscribed (texted STOP to your Twilio Number) to test.

curl --location --request POST 'https://voice-notifications-6377-dev.twil.io/sendSMS' \
--header 'Content-Type: application/json' \
--data-raw '{
    "From": "+19197377453",
    "To": "+17048193222",
    "Body": "Hello, your table is ready now. Please proceed to the host stand."
}'

For more examples, please refer to the Documentation

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Mark Vickstrom - [email protected]

Project Link: https://github.com/mdvickst/voice-notifications

(back to top)

About

Automatically send Twilio voice notifications for undelivered Twilio SMS messages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published