Build a Modern Hotline with Twilio Programmable Voice and Sync
Time to read: 4 minutes
In this article, you will unlock the powers of using a Twilio Programmable Voice's conference bridge to connect your loved ones in a single phone call. This blog post could work for Healthcare, Corporate, or Educational Institutions – I’ll show you all the steps you’ll need to connect a list of numbers in a single conference call.
Prerequisites
To get you started with this article, you need the following
- Twilio phone number
A number that connects the institution with its emergency contacts through a conference call. - Twilio Studio access
A visual builder to create, edit, and manage communication workflows in Twilio Studio. Our low-code/no-code application builder makes complex implementations extremely easy. - Twilio Sync services
Twilio Sync is Twilio's state synchronization service, offering two-way real-time communication between browsers, mobiles, and the cloud. Using Sync helps you avoid building all the real-time infrastructure. - Twilio Cli
Twilio-CLI allows you to manage your Twilio resources from your terminal or command prompt.
Architecture
The following diagram shows what we’re building today. An Admin of an institution – pictured on the left – will use a variety of Twilio services to connect users to a conference bridge.
In today’s tutorial, we will build a hotline for a school to quickly conference a number of parents.
Implementation
Clone the following project. Navigate to the folder /twilio/serverless
and run the following commands.
This command returns the following output:
Save the information generated with the domain name; in our case, it is serverless-xxx-dev.twil.io
.
Create a Studio Flow
Open the Twilio Studio executions page from the Twilio Console, create a new Studio Flow, and import /twilio/studio/Parent-Hotline-Outbound.json
.
Call the number purchased to grab the flow SID from the logs. Flow SID can also be derived from the REST API.
Next, create a new Studio Flow and import /twilio/studio/Parent-Hotline-Inbound.json
from the git repository. Open the SetGlobalVariables
widget to configure the key/value pairs for the following variables:
The SERVERLESS_DOMAIN_NAME
value is set to the domain name generated by the serverless CLI code above; in our case, it is serverless-xxx-dev.twil.io
. SYNC_SERVICE_SID
can be obtained and set from the previous studio's Parent-Hotline-Outbound
Flow SID. And finally, SYNC_SERVICE_SID
by adding a sync service.
Create a Sync Service” to store near & dear phone numbers
Open the Sync console by navigating through the explore products menu in the Twilio console.
- Create a new Sync Service, then create a new Sync Document.
- Add the following fields to the document:
- Unique Name:
Twilio Phone Number
- Document Data:
{"Parents":["+1XXXXXXXXXX","+1XXXXXXXXXX"]}
- Unique Name:
Upon completion of the Sync service in the console, the Sync ID is generated. Use it to set SYNC_SERVICE_SID
in the Studio execution above. This completes the initial setup process and ensures that the Studio execution is published and saved.
Understanding the Studio Flows
Parent-Hotline-Outbound
In this execution, when the institution, such as a school, calls a Twilio number, we trigger a RESTful API call. We grab the institution number and create a conference bridge with the institution and the Twilio number.
Parent-Hotline-Inbound
Since there is an incoming call to the Twilio number, we have another separate Studio Flow that grabs a few parameters such asSYNC_SERVICE_SID
, which is a service to store all the near and dear phone numbers. (In our example, it's the parent's number).
Also, we set the values of the serverless Sync domain to obtain the Sync records and parents' phone numbers and, finally, the conference flow ID to connect the institution to the parents.
As you see in the diagram above, we are looping through the Sync document to fetch individual phone numbers by making an HTTP request to the sync service. This would call both the parents and add them to the bridge so that the teacher and institution can contact the parents of a child to update their health condition or remind them of early pick-up, or anything else that requires group communications.
Testing
Testing is straightforward – dial the Twilio number, and see if the bridge connects all the numbers listed in the Sync document to a conference call.
Conclusion
Congratulations! You’ve now built a conference bridge that solves the problem of linear calling when a mass call needs to be placed. And it’s not just limited to schools – for example, say a hospital needed to call all a patient's family and friends in one go, they could use this solution to debrief everyone on a single call. Similarly, it would help if a school wanted to connect with both the parents of a child or a business wanted to relay a message to a few employees. A conference bridge is an awesome companion.
Try this solution and lessen your CTA time calling linearly. We can’t wait to see what you build!
Biography
Anthony Wong is a Principal Solutions Engineer at Twilio. He’s focused on building integration between Twilio and companies like Salesforce, so adoption is one-click away. He can be found at anwong [at] twilio.com
Pooja Srinath is a Principal Solutions Engineer at Twilio. She's focused on learning new software technologies that help create solutions, address use cases, and build apps solving some of the industry's toughest requirements. Pooja uses Twilio's powerful communication tools & APIs to build these ideas. She can be found at psrinath [at] twilio.com
Related Posts
Related Resources
Twilio Docs
From APIs to SDKs to sample apps
API reference documentation, SDKs, helper libraries, quickstarts, and tutorials for your language and platform.
Resource Center
The latest ebooks, industry reports, and webinars
Learn from customer engagement experts to improve your own communication.
Ahoy
Twilio's developer community hub
Best practices, code samples, and inspiration to build communications and digital engagement experiences.