Who says you can't be romantic during a quarantine? Although it's fun to send flowers, chocolates, and gifts to your loved ones for Valentine's Day, you can also have fun sending a virtual Valentine gram as well!
With the help of Twilio Functions, you can deliver a romantic Valentine's Day gram over the phone to your gal pals, best buddies, a special someone, or to yourself! With a project as fun as this, it's hard to restrict yourself from using it on only one day out of the year.
In this article, you'll be using JavaScript, TwiML, and Twilio Functions to call a phone number and deliver a Valentine's Day message.
Tutorial requirements
- A free or paid Twilio account. If you are new to Twilio get your free account now! (If you sign up through this link, Twilio will give you $10 credit when you upgrade.)
- Some prior knowledge in JavaScript or a willingness to learn.
Create a Twilio Bin
TwiML Bins work well with Twilio Functions because they help you explore Twilio's capabilities to the fullest. By using Twilio's Markup Language (TwiML), you save yourself the hassle of having to write complex code or connect your own web server in order to execute a simple call.
If you haven't done so already, search and purchase a Twilio phone number from the console. Make sure that the phone number you choose is set to the same country or region of your personal number to avoid international fees when you pick up calls from the number.
On the Twilio Console, click on the (...) icon and scroll down to the Runtime section. Select TwiML Bins. Click on the red (+) sign to create a new TwiML Bin.
Give the TwiML Bin a friendly name such as "valentinesdaygram". The TwiML text box will contain the script for the voice recording that you will hear when you call the number.
Before we move on further, let's take some time to meet our new friend alice
. Alice is a talented friend of Twilio also known as a text-to-speech (TTS) engine that converts text into a human-sounding voice. Thus, Alice is the perfect way to deliver the Valentine message. Alice is capable of speaking in 26 total dialects and offers the voice of a man
or a woman
.
For now, we'll have Alice speak in their normal voice and recite a line that Leslie Knope said in Parks and Recreation. However, feel free to change the XML to whatever you please. Copy and paste the following XML into the text box and click the Create button at the bottom of the page: