Using the Reserved Numbers and Auto-Create functionalities to support the “online directory” scenarios
The auto-create functionality of the Out Of Session callback webhook and the Reserved functionality for the Phone Numbers can be used in conjunction to implement a solution for the special - but rather frequent - use cases where businesses need to display a Phone Number forwarding all incoming calls/texts to a specific person and don’t know who will contact it. In the typical Proxy scenarios, you know in advance who both the Participants of your Proxy Session will be. In this case, you only have half of the needed information; you have the destination endpoint, but you still don’t know who will be the customer calling in.
Let’s use the example below to show how the auto-create functionality of the Out Of Session callback webhook and the Reserved functionality for the Phone Numbers.
Let’s assume there is a site called ShoppingPlace.com where people can post items for sale and other people can purchase them. One feature that the seller wants is for the two parties to be able to correspond by text or call without giving out personal Phone Numbers. At the same time, sellers might want their customers to always use the same Phone Number to contact them. Here’s what ShoppingPlace.com should do.
- Create a Proxy Service and mark a set of Phone Numbers from the pool as “reserved”. More specifically, as many Phone Numbers as the number of Sellers on the platform.
- Within their internal system, record the association between each Seller and a specific Reserved Phone Number.
- Let’s assume that there are two Sellers:
- Tom (private Phone Number +1 415-234-5555) - with reserved Phone Number +1 415-111-1111
- Beth (private Phone Number +1 209-987-6666) - with reserved Phone Number +1 209-222-2222
This tells Proxy to:
- Create a voice and message capable Session named “autoCreatedSession23423” that will expire in 3360 seconds (or 3360 seconds after the last interaction between the seller and buyer).
- Add the buyer as a Participant to the Session (Proxy has the buyer’s Phone Number because they initiated the interaction) with the Proxy Identifier as the Reserved Phone Number +1 415-111-1111 (which is the Proxy Phone Number published on the website and associated to Tom).
- Add Tom as the second Participant using Tom’s private number (+1 415-234-5555) as the Identifier and allowing Proxy to select an unreserved Phone Number from the Proxy pool as the seller’s Proxy Identifier.
Note that mapping (recorded into ShoppingPlace.com database) between Tom and the reserved Proxy Phone Number +1 415-111-1111 doesn’t mean that Tom’s Proxy Identifier is +1 415-111-1111.
Now that Proxy has created the Session with the desired Participants, it can forward the message or call just as it would have if the Session had been pre-created. Now that there is a Session with the correct Participants, the buyer and seller can go on corresponding via masked communication.
Need some help?
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.