Prank calling people with Twilio
A simple guide on how you can prank call your friends and colleagues with Twilio.
Confessions of a prankster.
One of my favorite pranks is fake calling people with Twilio, especially when I'm in the same room as them. Fake calling goes like this:
First I pick a target. The only thing I need is his/her phone number and my Twilio account.
Then, I pick the scenario I want to call them with. A scenario is an XML file with a set of instructions of what Twilio should do. An example could be:
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Pause length="2"/>
<Play>https://urltofile.com/hallo.mp3</Play>
<Pause length="2"/>
<Play>https://urltofile.com/naamvanrossem.mp3</Play>
<Pause length="4"/>
<Play>https://urltofile.com/wordopgebeld.mp3</Play>
<Pause length="5"/>
<Play>https://urltofile.com/helemaalni.mp3</Play>
<Pause length="3"/>
<Play>https://urltofile.com/televisie.mp3</Play>
<Pause length="3"/>
<Play>https://urltofile.com/voorwatbellen.mp3</Play>
<Pause length="2"/>
<Play>https://urltofile.com/manmanmantoch.mp3</Play>
<Pause length="15"/>
</Response>
In this scenario we tell Twilio to:
- Pause 2 seconds (because the other party picks up the phone, they'll probably introduce themselves first, which takes 2 seconds on average)
- Play an MP3 file
- Pause another 2 seconds for the other person to reply
- etc..
This is far from perfect for obvious reasons, but that's all we have.
I have around five scenarios to choose from. Different scenarios for different...needs.
When I picked the right scenario, I make a simple API call to Twilio or I use the Twilio API explorer to make the call. An example API call (with curl) would be:
curl 'https://api.twilio.com/2010-04-01/Accounts/My Account SID/Calls.json' -X POST \
// the number I want to call
--data-urlencode 'To=+32498112233' \
// the number I bought in Twilio
--data-urlencode 'From=+32498445566' \
// URL of the XML file with the scenario I want to use
--data-urlencode 'Url=https://website.com/scenario.xml' \
// let's record the call!
--data-urlencode 'Record=true' \
-u AccountSID:AuthToken
When we make this API call, Twilio will hopefully give us a 2xx response in return with the RecordingSID. This is the unique ID of the recording of the call. As soon as the call is finished, the recording will be available for us to download.
curl 'https://api.twilio.com/2010-04-01/Accounts/MyAccountSID/Recordings/RecordingSID.json' -u AccountSID:AuthToken
This will return a JSON with links to a .WAV and .MP3 file for us to download.
You can then share this MP3 with your friends or colleagues in Slack and laugh all together about the fact that Dave from accounting thought he was really talking to Jean-Pierre van Rossem on the phone.