Build call forwarding with caller ID using Twilio Lookup

March 11, 2022
No Translation Text Exists for this Label Key and Language.
No Translation Text Exists for this Label Key and Language.

TItle image: build call forwarding with caller id using Twilio Lookup

Like most people these days, I don't answer my phone when I get a call from an unknown number. Unfortunately for me, phone calls are still an incredibly useful form of communication for many businesses. Fortunately for me, Twilio has useful products like Lookup to help determine whether an incoming call is from my dentist or if it's spam.

This blog post will show you how to quickly launch a call forwarding service that sends you an SMS with Caller ID details when available (Caller name information is sourced through CNAM and currently only available for phone numbers owned by carriers in the US.) The service will send an SMS like the one below right before it forwards the call.

Text message with incoming call message from Dr Dentist and carrier Twilio

Best of all, there's no code required! You will deploy your personal instance of this call forwarding service using Quick Deploy with our CodeExchange service. But you will be able to customize the application in code if that is what you want.

Prerequisites for caller ID and call forwarding

Before you can launch your call forwarding application you'll need:

Quick Deploy a Twilio Lookup application

Make sure you're logged in to Twilio and head over to the call forwarding application on CodeExchange. Select your Twilio phone number from the dropdown in step 2. This is the number you'd give to someone to call instead of your personal number. Then add your personal number under “My phone number” in E.164 format.

Next, click "Deploy this application". After a few seconds you should see a button to "Go to live application": click that to head to your new application.

Once you deploy your application you're all set! The web page will describe how the application works and provide some troubleshooting tips in case you have any issues.

Test it out by calling your Twilio Phone Number - you'll get an SMS with caller ID information. Call forwarding won't work if you call from the same number you're forwarding the call to, but that's expected. For the full experience, borrow a friend's phone to make the call to your Twilio number!

Customize your Caller ID message

The whole application is hosted on Twilio, so you can make changes directly from the Twilio Console. Select the caller-id-forwarding service from the Twilio Functions dashboard and open up the forward-call function:

Screen shot of Twilio Functions console showing forward call function text

You can edit the body of the SMS message on the line starting with const body. For example, if you don't need the carrier information, delete it. If you're only using this number for a specific project or category like getting quotes for renter's insurance or scheduling medical appointments, you could add that detail to the message like:

const body = `Incoming call about your Insurance Quote from ${callerName === null ? 'Unknown' : callerName}`

After you’ve made your changes to the function, click the “Deploy All” button to save and publish the updated application.

Learn more about caller authentication and spam blocking

US regulation around SHAKEN/STIR aims to reduce spam calls and Twilio has the tools to get started with call authentication. The technology will make it easier to detect legitimate calls and, importantly, to track down and punish scammers.

Here's more information about maintaining a good caller reputation, check if an incoming call is from Twilio, and how to report suspected spam or unwanted calls from Twilio.

You also might like these CodeExchange projects for more inspiration:

I can't wait to see what you build!