Fake call using Twilio API

Saravanan Manoharan
3 min readFeb 13, 2021

Stuck in the middle of a boring conversation? Want to fake a call to escape the situation? Here’s Twilio to rescue!

You can do this in just 10 steps!

  1. First things first, you need to signup for Twilio.
  2. Make sure you verify your phone number. With the free tier, you can message or call only your verified phone number. For other phone numbers, you need to upgrade your account.
  3. Then you need to get your free Twilio phone number.
  4. After getting your Twilio phone number, your console will look similar to this:
Twilio Dashboard

Before moving to the next steps, here’s how Twilio works:

Image source: https://www.twilio.com/docs/sms/tutorials/how-to-receive-and-reply-python

When someone sends a text message to your Twilio number, Twilio can call a webhook that you create using Python from which you can send a reply back using TwiML.

5. So, we need to create a webhook right now. This is fairly simple. I have used Python flask library to create my webhook and AWS to host it (you can use any medium to host it).

Here is my code. You can find the same in my repository too.

Source code to make a fake call

In order to host this on AWS, do check out my article here: https://medium.com/dev-genius/host-your-python-flask-on-aws-ec2-91735aa7127a

6. You can push this code onto the EC2 instance and can run it from there.

7. After running your code on EC2, your webhook will be on your EC2 Public IPv4 DNS port 5000.
Eg: http://ec2-3-87-112-121.compute-1.amazonaws.com:5000/sms

Note: Your IPv4 will be different. /sms is the flask end point.

8. So, now back to the Twilio account. Add this webhook link to your Twilio Phone number.

9. Go to https://www.twilio.com/console/phone-numbers/incoming and click on your number. Change the default Webhook under Messaging from https://demo.twilio.com/welcome/sms/ to python webhook your created (point 7).

Twilio phone number console after adding Webhook under Messaging

10. Once, this is done. Text to your Twilio phone number with the words “Fake call” and see the magic ;)

Successfully called message displayed in my EC2 console.
Screenshot with the fake call from the “Twilio phone number”

“Woah! Someone is calling. I got to take this. Catch you later” :P

--

--