If you’re like me you’ve sat in front of ArcMap with a process running in the background, waiting to see that light blue pop-up with, hopefully, a green check mark. The wait is long and boring, especially if, like me, you don’t touch your laptop while it’s running for fear of a random error. Or maybe the background server is having a bad day and it randomly “throws an exception”.

Well fear no more! Thanks to Python and Twilio, you will no longer have to sit in front of your computer, potentially wasting time while your process runs. In the following steps I will be describing how I set up ArcMap so that I can start a process, walk away from my laptop, and receive a text message when the process has completed.

Disclaimer: This workflow is for Windows, Python 2.7, ArcGIS 10.4.1; however, it should work for most versions of Python and ArcGIS.

Step 1: Create a free Twilio account

Twilio allows programmers to easily add communications (i.e. messaging, voice, video, and authentication) into web and mobile apps. It is available for most of the popular programming languages, in this case Python.

Twilio offers a free trial account to all customers. According to Automate the Boring Stuff you can use this free trail account indefinitely free of charge, but it seems as though Twilio is not continuing this practice. Once the free balance you are allotted runs out, you will either have to upgrade your account or find an alternative service.

Visit Twilio.com and sign up for a free account. Once you do, you will need to verify the phone number that you will be using with their service (this is done to prevent people from creating an account and spamming multiple numbers). When you have verified your phone number, you can login to Twilio and view your ‘Twilio Phone Number’, ‘Account SID’ and ‘Authentication Token’ on your dashboard. We will be using these numbers shortly.

Step 2: Install the Twilio module on your computer

The easiest way to install the Twilio module on your computer is using Pip. Pip is already installed with Python. Open the command prompt (in the Windows start menu search for “cmd”), and navigate to C:\Python27\ArcGIS10.4\Scripts\. (Be sure to check which version of Python and ArcGIS you are running and navigate to the appropriate folder.)

Once you have the correct path showing in the command prompt, type “pip install twilio” and hit ‘enter’. The Twilio module will download and install.

Step 3: Write the Python program

The following code we will use is taken directly from Automate the Boring Stuff. It’s short and simple and does exactly what we need. Open Python IDLE and create a new file (File > New File), then copy and paste the following code:

from twilio.rest import TwilioRestClient

accountSID = ‘ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’

authToken = ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’

twilioCli = TwilioRestClient(accountSID, authToken)

myTwilioNumber = ‘+1XXXXXXXXXX’

myCellPhone = ‘+1XXXXXXXXXX’

myMessage = ‘ArcMap Process Complete’

message = twilioCli.messages.create(body=myMessage,from_=myTwilioNumber,to=myCellPhone)

There should be 8 lines of code. Replace accountSID, authToken, myTwilioNumber, and myCellPhone with your information.

Since we’re going to use this script strictly with ArcMap, go to your ‘Documents’ folder, then ‘ArcGIS’, and create a folder called ‘MyScripts’. Save your Python file here. You can now test your program! Run your program by going to the ‘Run’ tab and clicking ‘Run Module’ (or press F5). If everything was set up correctly, you should receive a message on your phone that reads “Sent from your Twilio trial account – ArcMap Process Complete”.

Step 4: Add your script to ArcMap

In order to add a script to ArcMap, you have to create your own Toolbox. As custom toolboxes must be inside of a geodatabase, the easiest way to accomplish this is by going to your default.gdb, right click, hover over ‘New’, and select ‘Toolbox’. Name it whatever you like.

Then right click your toolbox, hover over ‘Add’, and select ‘Script’. Choose a name (no spaces), and then a label. The label is the text that will show up in the Catalog menu. I used ‘Process Complete SMS’, and gave it the description ‘Sends a text message when the running process is complete.’ Leave ‘Stylesheet’ blank, and uncheck both check boxes. Then click ‘Next’. Navigate to the Python file you saved earlier and select it. Make sure ‘Run Python script in process.’ is checked! This will add it to ArcMap’s process queue. Then click ‘Next’ and click ‘Finish’.

Step 5: Try out your cool new tool!

In ArcToolbox, double click on your new tool. When it opens, click ‘OK’. If you’ve set up everything correctly. You should receive a text message just like before. It’s that simple!

The next time you run a process that you know will take a while (and you don’t want to sit around waiting for it to finish), open up your tool and run it as well. ArcMap will continue with the first process until it is complete, and then it will run the next process in the queue, which is your tool! This means that no matter where you are or what you are doing, ArcMap will send you a text message letting you know that your process has completed.

Pretty cool, huh!