How often did you consider masking your private phone number? At first, this question may seem odd but imagine the situation when you order a taxi and, after the trip, the driver starts calling you. That’s not what you normally expect from a taxi service, right? The same is true for the driver: it wouldn’t be great if previous customers would call and distract the driver on the ride or (even worse) on vacation.
First, having a delicate distance between yourself and service workers is much better than having no distance at all. Second, it is important that both parties have the fastest way to contact each other. The Voximplant cloud can easily address these requirements with a phone number masking approach. This article will guide you through all the necessary steps to implement this feature for a simplified case of a single driver and a few customers. Note that this solution is scalable for any number of drivers and customers.
WHAT YOU NEED
To implement the solution, you will need:
- Voximplant developer account. If you don’t have one, sign up here
- A simple backend. We will use the node.js server
- A phone number that is purchased from Voximplant. It will be our "call center" number. We will use a "virtual" phone number for demonstration
- A JS scenario. It will be created during this tutorial
To get things done quickly, we suggest using the Express framework for node.js.
Create an index.js file with the following code:
Now we have the backend server that could store and give the number of the last caller (customer). Note that we use different request methods for saving/giving.
Install node.js and express.js on any server platform (AWS, Azure, or any VDS, etc.). You can also test the solution locally, by using ngrok, which allows testing demo applications without deploying them. In case of using ngrok, do the following:
node index.jsto start your server locally on
- Then go the folder where you've downloaded ngrok and run
./ngrok http 3000to tunnel your running local server to a public URL. Pay attention to the public URL generated, we will use a bit later:
2. PHONE NUMBER
In the VoxImplant control panel, on the left menu, select Numbers and click Buy new phone number in the upper right corner.
The Buy new phone number dialog page will be displayed. Switch to Test numbers, select a number in the list and click Buy selected to buy a virtual phone number.
3. APPLICATION AND JS SCENARIO
As was mentioned above, our example includes only one driver, that’s why this number won’t be changed. Therefore we can save the driver’s number right in the JS scenario for demonstration purpose.
For every incoming call, we need to check the caller’s number:
- If the incoming call number doesn’t match the driver’s number, we will save this number to the backend, call the driver and establish a connection with the customer.
- If the incoming call number matches the driver’s number, we will retrieve the last customer’s number from the backend, call the customer and establish a connection with the driver. The logic is simple but effective in our context. Let’s see how to implement this logic in the Voximplant JS scenario. Pay attention to the callerId variable, its value should be the number you bought (see paragraph 2). Also, replace the driverNumber with a real phone number, and paste the ngrok public URL to the Net.httpRequest method calls:
As you might know, there is an Applications concept in Voximplant. The Applications allow linking scenarios, phone numbers, users, and call queues. Go to Applications, click New application, type the name of a new application ("taxi", for example) and then click Create.
Then add the scenario with the code above: go to your new application, switch to Scenarios, create a call-handling scenario. Don't forget to save it.
Next, switch to the Routing tab of your Taxi application and click New rule. Name it Incoming call; use the created JS scenario in the rule and leave the default call pattern ( .* ).
For more information about rules and applications, see the corresponding articles:
4. NUMBER + APPLICATION + RULE
Finally, go to the Numbers tab of the application, choose the Available tab, select a purchased number and click Attach. In an opened window match the number with a newly created rule, click Attach.
Well done! We’ve just linked the phone number to the JS scenario! Actually, our solution is ready to serve customers.
5. HOW TO USE THE DEMO
First of all, start your backend server. As our backend initially has no customer number, it would be better if a customer made the first call.
When a customer calls the purchased number, our cloud receives the call and executes the JS scenario to handle it. According to the JS scenario:
- The customer’s number will be saved to the backend.
- The cloud will call the driver.
- When the driver answers the call, a connection to the customer will be established.
Since the backend now stores the customer number, the driver can call the customer. The driver calls the purchased number and the JS scenario causes the following to happen:
- The cloud requests the customer number from the backend.
- If the backend successfully returns the customer number, the cloud will call the customer.
- When the customer answers the call, a connection to the driver will be established.
6. NEXT STEPS
This demo is pretty simple but represents the general idea of phone number masking. There’s no magic but the power of cloud telephony. The described approach allows you to create safe, convenient, and – what’s hugely important – scalable solutions. Add the additional checks in the scenario, make the cloud play music while establishing a connection, build a sophisticated backend structure, etc. Do whatever you need to provide the best service. Make the machine suffer for the sake of satisfied customers!