Integrate Anaplan with Siri and IOS Shortcuts

We now live in a connected world, and Anaplan provides us with Connected Planning—but what about extending that connectivity even further? Every day, we carry mobile phones in our pockets that are amazing in the possibilities they offer to our lives. Anaplan has a great mobile app so that you can review your dashboards and input forecasts from wherever you are, but how about extending that connectivity to exact times, your location, or even running Anaplan via your voice?

IMG_D4595E7519DE-1.jpegApple has an awesome app that will be installed by default on your iPhone/iPad called Shortcuts. With Shortcuts, you can create powerful "If-Then Do" logic that can either be automated or run manually. A common example would be to create a Shortcut to automatically switch the lights on when you arrive home at night. I was thinking to myself recently it would be amazing to extend this ability across Anaplan.

 

Imagine creating a Shortcut that would:

  • Run an Anaplan process at a specified time each day and then log the result to your Notes or Email.
  • Run an Anaplan process when you reached a specific location i.e. your office.
  • Log the status of your models each morning to a file on Dropbox.
  • Allow you to run an Anaplan Process by just asking Siri.

So, I set about looking further into Shortcuts and found the secret sauce!

Anaplan has a very strong API having been designed for the cloud. You can review all the documentation here:

Having a strong API means that we can easily create POST and GET commands to interact with Anaplan.

Within IOS Shortcuts, there is then a command called "Get Contents of URL" that allows you to execute the POST/GET etc.

Let's walk through an example of how to build:

  • A Shortcut that authenticates with Anaplan.
  • Retrieves the Processes within a Workspace/Model.
  • Executes a Process.
  • Is then automated at any time or location.
In this screenshot, you can see I have a number of Shortcuts. Some were downloaded from the galley and some were developed from scratch by me. IMG_46CB66101FD2-1.jpeg

Let's start with how I built the "Anaplan Processes" Shortcut to return the processes within a model, as I need the ID of a Process in order to run it.

In order to authenticate with Anaplan, I did the following:

  • Use a Text command (found under Documents) to hold my Username:Password (it has to be in this format and be careful not to have any line breaks).
  • Insert a Scripting command to do a "Base64 Encode."
  • Set a variable to be the output of the Base64 Encode so I can re-use it elsewhere in my Shortcut.

N.B. Authentication here is based on basic authentication and will then need to be amended every three months with the new password. Using a certificate would help to make this auth process more secure and less prone to code amendments.

IMG_3342785B59A8-1.jpeg

  • Let's hold the URL to authenticate against in a URL command https://auth.anaplan.com/token/authenticate.
  • If we now use a "Get Contents from URL" command, we can use the URL in the "Get Contents of" field.
  • Ensure the Method is set to POST.
  • Add one header with Authorization as the key and the value being Basic and then the name of your variable output from the Base64 Encode. Be sure to leave a space between Basic and your variable i.e. Basic vUserPass.
  • If you were to play this Shortcut at this stage, you should hopefully receive a successful authentication result. What we want though is out of the JSON message, and we need the text from the tokenValue in order to use this Token when making further API calls.
  • In Shortcuts you can use a Dictionary to store or retrieve data in a Key:Value format similar to JSON. So if we use a "Get Dictionary Value" command we can retrieve the Value for tokenInfo.tokenValue.
  • We use tokenInfo.tokenValue as it represents the path to that value within the JSON.
IMG_567172673DB5-1.jpeg

Now that we have the authentication in place, we can run a request to get a list of processes within a workspace/model. We need this as a way to find the ID of the Process we want to execute anyway. In order to get a list of Processes we:

  • Add a URL command and use the URL where {workspaceId} and {modelId} are specific to your environment. You can easily find them from the URL on your browser when you are logged into a model.
  • I have included Set Variable command to retrieve the output of the Dictionary value that contains our tokenValue.
  • Adding a "Get Contents of URL" command we can now reference the URL, ensure the method is set to GET, and then add two headers.
  • Authorization with a value of AnaplanAuthToken, then a space, and then our token variable.
  • Content-Type with a value of application/json.
IMG_CD1D08D6CB85-1.jpeg

You will now be able to run this shortcut by pressing the play button in the bottom right. On finish, you should see a successful JSON return message consisting of all the Processes, their names, and their IDs. Make note of the ID of the Process you want to execute. If you need to debug your shortcut you can add Show Notification commands or even create an IOS Note of outputs to analyze.

Let's leave this Shortcut in place working and copy it, so we can reuse the majority of the Shortcut but edit it slightly to execute Process instead of listing Processes. To copy a shortcut, just hold your finger down on the shortcut until a menu appears and select Duplicate.

The edits required on the shortcut to execute a process are:

    • Rename this shortcut.
    • Leave all the authentication command in place.
    • Change the URL to this URL where {processId} is the ID of the Process you obtained from the other shortcut.
    • Change the Method to be POST instead of GET.
    • Press play and check your process executes.
 IMG_E799072D885A-1.jpeg

 

N.B. The way the IDs are retrieved currently means that if IDs change you update the URLs called by their codes. A way to address that point would be to add a step that will look for all IDs based on the name, using the endpoint "/models".

Now you have a working shortcut, you can execute it at any time by just pressing the shortcut. If you want to automate it though, you go onto the next screen— "Automation". Here you can create new automation from the + menu item and select "Create Personal Automation" with an Event "Time of Day" and a Do of Run Shortcut and then just select your shortcut. You can change the timing to be any day/time or even sunrise/sunset.

The shortcut could be enhanced further by retrieving the outcome of the process (Did it fail? How many records are rejected?) and then notifying the user of the outcome of the process.

IMG_74B52E45AB9F-1.jpeg IMG_166768C6A89C-1.jpeg IMG_C42BE6139AD7-1.jpeg

Now you have created automation with Anaplan. Imagine now extending it to run an Anaplan process based upon your geolocation, arriving at your office, a change in the weather, or maybe a change in the exchange rate. Of course, the coolest thing now is you can execute the Anaplan Process just by talking. Just say "Hey Siri, run the shortcut Anaplan Run Process". That will certainly surprise people in your next meeting.

 

The content in this article has not been evaluated for all Anaplan implementations and may not be recommended for your specific situation.
Please consult your internal administrators prior to applying any of the ideas or steps in this article.
Contributors
Latest Articles
2 weeks ago
User Provisioning
Best Practices
3 weeks ago
by Misbah
Transactional API Tutor
Best Practices
3 weeks ago
Labels (2)