Phone automation — Automate Whatsapp messages with NFC, Tasker & Auto Input in 15 mins

Image for post
Image for post
Created using Canva & Pexels

I have (had?) a problem — every morning when I reach my office, I ping my wife that I’ve reached the said office. Some days, I forget. And she, being an Indian wife, worries a tad too much and I end up getting calls and pings asking if the road split open and swallowed me whole — rendering me incapable of sending a simple message of ‘reached’ to her.

I’m a lazy person. I also know that necessity is the mother of all invention. And that it is the grand-aunt of automation. So without further ado, here is how we’ll wire up the phone to send my wife a message every time I reach office.

The Flow

Image for post
Image for post

As you can see, there are a few apps involved that do most of the heavy lifting for us. The main flow is:

  1. NFC tag activates the NFC Tasks app along with the Tasker task name

Step 1 — Preparation

This is a fairly straight forward exercise. Install the following apps from the Play store:

  1. NFC Tools
Image for post
Image for post
NFC tag from the inside

Purchase a NFC tag with a 3M sticker. You’ll get this online for really cheap (link).

Note, when you’re buying these, make sure they’re writable and NXP MiFare compliant.

Please test the NFC tags for write/read capability before going ahead.

Step 2 — The Task

Before we wire the system up together, we’ve to build the task on Tasker. I won’t go into details on Tasker itself, but think of it as a really powerful MS Excel Macro tool for your phone — except that you’re not restricted to a spreadsheet and it’s more for your phone.

Image for post
Image for post

Here is a step by step logic breakdown:

a. We first determine if the day is a working day. Hence the regex:
[^(Fri)|(Sat)]{3} (we work Sunday to Thursday here in the GCC)

What this does is checks if the first 3 characters ({3}) are not Fri or Sat. The Day of the week variable is %DAYW in Tasker, which you can get by tapping on the Variable icon in the task.

b. Now that we know we’ve to send the message, we’ve to determine what the message is — for this, we need to know the time. Typically, I reach office anywhere between 7am to 11am, depending upon work. And I leave anytime after 3pm and before 10pm. Based on that, I have to send different messages.

To get the timing right, we need to split the %TIME variable (output is hh.mm) and get the hh part. Variable split helps in breaking down the %TIME variable on ‘.’ and putting the values in %TIME1 (hh) and %TIME2 (mm). Once we determine the IF logic, we can write the message values to a variable %MSG.

c. Since we’ve determined the message, the only thing left is to send the message. Whatsapp API comes in handy here — https://api.whatsapp.com/send?phone=<phoneNumber>&text=%MSG

Image for post
Image for post
Auto Input config: com.whatsapp:id/send

d. Now, so far, we’ve opened the Whatsapp application and entered the message. But the message isn’t sent till you press on the ‘Send’ button. That’s where Auto Input comes to the rescue. Auto Inputs allows you to fake inputs to your phone. We’ll use Auto Input to press the send button.

Image for post
Image for post
Preference setup for external access

e. Now that the message has been sent, we just need to go back home, without disturbing the phone!

f. Enable External access on your Tasker. It’s a configuration that allows other apps to trigger any of Taskers Tasks. You can find this in the Preferences, as shown to the left.

Step 3 — Write to the tag

Here is how to do that using NFC tools. Remember you need NFC Task to run the task:

Image for post
Image for post
Write to the Tag

Step 4: Profit!

Alright, let’s talk about the problems with this approach and how we can solve it in the future:

  1. The trigger for this is manual — the NFC tag sits in my car/on my desk that forces me to tap it. If I remember to tap, I can remember to send!

And there you have it folks! An easy 3 step guide to make automation a reality in your life.

Thank you for reading!

Written by

Simplifying Complexities for a Living | rkakodker.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store