We have all been in that situation where we are stuck chatting with someone we want to run away from but we can't. It could be at a party, a convention, anywhere basically, but it happens.
At that point, all that we hope for is someone's phone call to let you pull yourself away from the absolute madness you have to deal with in the name of social behaviour!
At that moment, you can never know whether your saviour shall appear in the form of a tring tring from your phone, but what if I told you that you could make that "call" happen without someone else calling you anyway?
Ladies and gentlemen, I present to you all...๐ฅ๐ฅ๐ฅ
๐ต๏ธโโ๏ธ FakeACall ๐ฒ
FakeACall is an application that I made for my Wear OS by Google smartwatch to fake a phone call to my phone to get out of tricky situations. It has been built with Xamarin.Android and uses an Azure Function and Twilio Programmable Voice to achieve this aim.
The best part about this app is that we can all build it for ourselves. And that's exactly what we're going to do now!!!
Step 1: Understand the Application Flow
In this app, there will be two major components:
- The Azure Function to call the Twilio Programmable Voice API
- This will be responsible for making the phone call to your phone from your Twilio number
- The Wear OS smartwatch app built using Xamarin.Android to call the Azure Function
- This will be responsible for triggering the Azure Function to ensure that the call is made
Let's go ahead with developing our Azure Function first.
Step 2: Build an Azure Function to call the Twilio Programmable Voice API using .NET
Azure Functions is a serverless solution that allows you to write less code, maintain less infrastructure, and save on costs. Instead of worrying about deploying and maintaining servers, the cloud infrastructure provides all the up-to-date resources needed to keep your applications running. Twilio Programmable Voice is Twilio's API that allows you to quickly make and receive voice calls in your application.
We will build an Azure Function to call the Twilio Programmable Voice API which will make a call to your mobile phone. For this task, you will need the following:
- A Microsoft Azure Account
- You can create an Azure account for free here. In case you're currently an enrolled student with a .edu email address, you can get $100 worth of Azure credits by availing the Azure For Students offer too.
- A Twilio Account and Phone Number
- Head over to the Twilio website and sign up for an account if you don't have one already. Add a phone number to your account that has calling and SMS capabilities. If you're a student, you can get $50 worth of Twilio credits for free through the GitHub Student Developer Pack. Read more about this here.
-
Visual Studio Code along with the relevant extensions
- We will be using VS Code to build our Azure Function here. You can also use Visual Studio, the Azure Portal, etc. to achieve the same. Once you have VS Code installed, please also install the C# extension and the Azure Functions extension.
-
Azure Functions Core Tools version 3.x
- Azure Functions Core Tools lets you develop and test your functions on your local computer from the command prompt or terminal. Your local functions can connect to live Azure services, and you can debug your functions on your local computer using the full Functions runtime. You can even deploy a function app to your Azure subscription. Please install Azure Functions Core Tools from here.
-
.NET Core 3.1
- As we will be building our Azure Function with C# and .NET, you must install the .NET Core 3.1 SDK. You can build Azure Functions using other languages such as Java, JavaScript, Python. etc. as well.
Note: In case you have never tried building an Azure Function with .NET, please check out this little tutorial.
Once we have all of our necessities, let's begin:
- In VS Code, choose the Azure icon in the Activity bar, then in the Functions area, select the Create new project... icon.
Select a directory location for your project.
-
Provide the following information at the prompts:
- Select a language for your function project: Choose
C#
- Select a template for your project's first function: Choose
HTTP trigger
- Provide a function name: Type
FakeCall
- Provide a namespace: Type
Company.Function
-
Authorization level: Choose
Anonymous
- Select how you would like to open your project:
Open in current window
- Select a language for your function project: Choose
VS Code will use all this info to generate an Azure Functions project with an HTTP trigger.
Once that is done, navigate over to the FakeCall.cs
file visible in your directory and replace the existing template with the following code:
This Azure Function here will utilise the Twilio SDK for C# and .NET to interact with the Voice API and make a phone call.
Make sure that you install the Twilio NuGet package using the .NET Core command-line tools by running the following command in your command prompt/shell:
dotnet add package Twilio
You will also have noticed that there are 4 environment variables:
-
TWILIO_ACCOUNTSID
: The Account SID from your Twilio dashboard -
TWILIO_AUTHTOKEN
: The Auth Token from your Twilio dashboard -
NUMBERTOCALL
: The phone number you intend to call, i.e. your own phone number -
TWILIO_PHONENO
: The Twilio phone number you added to your account
We will add these to our Azure Function App in the portal after deployment. To do that, complete the following steps:
- Choose the Deploy to function app... button in the Functions area we visited earlier
-
Provide the following information at the prompts:
- Select subscription: Choose the subscription to use (you won't see this if you only have one subscription)
- Select Function App in Azure: Choose
- Create new Function App
- Enter a globally unique name for the function app: Type a name that is valid in a URL path
- Select a location for new resources: For better performance, choose a region near you.
Select View Output in the notification that will appear to view the creation and deployment result. You will be able to find the URL generated for the function here. If you miss the notification, select the bell icon in the lower right corner to see it again.
We also have to add the environment variables to our Azure Function, so log in to the Azure portal, visit your Function App, and find Configuration under Settings in the left pane. You can add your environment variables there as a New application string.
And our Azure Function is ready to run! You can send either a GET or a POST HTTP Request to the Function URL and it will call your phone.
Let us now build the Wear OS app for our smartwatch that we will use to call this Azure Function and thus, fake a phone call.
Step 3: Build the Wear OS smartwatch app with Xamarin.Android
Xamarin is an open-source platform for building modern and performant applications for iOS, Android, and Windows with .NET.
We will build a Wear OS app using Xamarin.Android, which, for our smartwatch now to call the Azure Function we just built. For this task, you will need the following:
-
Visual Studio IDE with Mobile development with .NET workload
- Visual Studio is the officially supported IDE for Xamarin development. If you have not yet, go ahead and install the Community edition for free from here. When setting it up, download and install the Mobile development with .NET workload, which will install all Xamarin-related components. Once you do that, you will need to verify that you have the right versions of Xamarin.Android, Android SDK, and Java JDK installed. You can find the minimum requirements needed to build a Wear OS app here.
Note: In case you have never tried building a Wear OS smartwatch app, do try the Hello, Wear tutorial.
Now we can go ahead, create a new project using the Android Wear App (Xamarin) template and name the solution FakeACall.
As soon as that is done, let's get coding:
-
Create the UI
Visit the ./Resources/layout folder in the app directory, open the
activity_main.xml
file and replace the template with the following code:What we're essentially doing here is adding a Button with some text. This text will change when the application runs in order to notify you whether the call occurred successfully or not.
As soon as that is done, we will go ahead and create the backend for the app.
Create the backend
Go over to the MainActivity.cs
file in the app directory and replace the template with the following code:
Here, we are making a POST HTTP Request to our Azure Function and then closing the app automatically once the app notifies us whether the app sent the POST Request successfully or not.
Make sure that you install the following NuGet packages using the NuGet Package Manager through Visual Studio:
Once this step is complete, your app is ready for testing.
Step 4: Test the app and enjoy
You can now go ahead and test your app. Debugging the app on your Wear OS device instead of the emulator will deploy it there for usage later too, so you can do that instead by following the instructions here. In case you do so, make sure that your Wear OS device is connected to your smartphone before you run the app. I will recommend saving the Twilio number as a contact to make your fake call seem more legitimate (for the demo, I saved it as Work Twilio
).
If all has gone well, your experience will be the same as my demo:
And that is all for today folks!
If you reached the end, my heartiest congratulations to you!
One of the best parts about this app here is that the Azure Function can be called from any device capable of making HTTP requests, so you can extend this functionality to other platforms too. Slight tweaking of the message content in the Twilio API can also turn this into a very useful SOS app.
I sincerely hope this app will be able to help you in case you're stuck in any troublesome situation. I am sharing my original GitHub repo for this app below as well. If you like it, do show some love by giving it a โญ
adityaoberai / FakeACall
Wear OS smartwatch app that can fake a phone call to get out of tricky situations
FakeACall
Description
FakeACall is an Android Wear application that allows the smartwatch owner to fake a phone call in order to get out of situations they may want to. It has been built using Xamarin.Android and uses an Azure Function and Twilio Programmable Voice to fake a phone call.
Components
-
The
main
branch contains the Xamarin.Android project used to build the Android Wear OS app. -
The
twilio_function
branch contains the Azure Function that uses Twilio Programmable Voice to fake a call.
Demo
Learn How To Build It
You can learn how to build this app for yourself by reading the article here
Top comments (6)
This FakeACall app is genius! I've been in those awkward situations too. Kudos for crafting a digital escape plan. I love how tech can save us from social craziness. I'm definitely gonna give this a spin for those "emergency" moments. I also already use whocalled.co.uk, and it's pretty handy. Thanks for the cool hack!
Haha thanks
Very detailed yet such an interesting idea to implement! More life hack solutions please!
Thank you for your kind words @bijoy26 ๐โค๏ธ
Never Imagined that A Fake Phone Call App had so much going on behind it, Thanks Aditya for sharing this, If I ever get a chance I will try to make such a project!
Really great article overall!โคโค
Thanks a ton @prathameshshanbhag ๐๐โค๏ธ