Recently, we talked about using Integromat to send emails that link to an Infomaptic report. Since then, we’ve been doing a lot of work with Microsoft’s Power Automate. We even got shared by the illustrious Derek Law (@GIS_Bandit)!
Many folks have asked us how to attach a PDF generated by Infomaptic to an email in Power Automate. We don’t offer a Power Automate widget yet (we are thinking about that, though, so let us know if you would find that helpful), but you can still accomplish this using the out-of-the-box tools in Power Automate. So let’s take a look!
Power Automate always needs a trigger. For our purposes, we will use Survey123’s “When a Survey Response is Submitted”. You can use any trigger that you like, but other triggers might require an additional step. More on that later. Start by creating a new flow that starts with “When a Survey Response is Submitted”. Alternatively, you can use the template “Send an email when a survey response is submitted in Survey123”.
Select the survey you want to trigger based on. You’ll probably want to select the same feature service that is powering the Infomaptic template.
Next, add an HTTP action and fill it out as shown below.
The URI connects directly to Infomaptic’s API, so it looks a little different than last time. You will need to get the Item ID for the template out of ArcGIS Online, just like we did in our previous post when we added secured images to Infomaptic.
And build the URI like this: https://app.infomaptic.com/api/report/[item-id-goes-here]/view
Afterward, configure the following queries:
key
– The value of the key used to inflate the report. Most likely it is the ObjectId, in which case you’d get that from the “Feature result objectId” property. (@{triggerBody()?['feature']?['result']?['objectId']
)type
– Hard code this to pdf
since we want to get a PDF filetoken
– This is the token used to access the data for the template. Infomaptic supports using ArcGIS tokens so you can pass the token directly from “Portal Info Token” (@triggerBody()?['portalInfo']?['token']
).Finally, add and configure the “Send an Email” action. Under the Advanced section, you can add an attachment. You need to specify both the file name and the file content. In this example, I used a field to specify the name of the PDF. For the content, use the Body
result from the HTTP action (@{base64(body('HTTP'))}
).
That’s it! Now run a test. You might have to submit a new survey to get the Test section of Power Automate to work, but after that, you should get an email with your PDF report.
You may have noticed that we used the token from the Survey123 trigger to call infomaptic. Great! But what should you do if you have a different trigger? You can use the HTTP action again. You can make an HTTP call directly to the ArcGIS generateToken
(documentation here) endpoint using credentials and get a token back. Just use that token to call Infomaptic. You can even be super safe by using an Application ID and Secret instead of your credentials.
Photo by Campaign Creators on Unsplash