Creating Power Automate (aka MS Flow) webhooks for Survey123 surveys in ArcGIS Online - Part 1

16518
15
11-08-2019 05:32 AM
zkovacs
Occasional Contributor III
10 15 16.5K

Update: Microsoft recently renamed Flow to Power Automate - link.

Starting with Survey123 for ArcGIS 3.0, webhooks can be set up and activated when a survey response is submitted. What does this mean? Basically, when a survey is successfully submitted, different workflows can be triggered based on the content of the submission: sending notification emails, adding results to a spreadsheet and so on.

There are a wide variety of workflow services available, such as Power Automate (aka MS Flow), Integromat, tray.io, Zapier, IFTTT, n8n.io, CloudHQ and the list goes on. Most (if not all) of them can be used to incorporate Survey123 as a trigger to build your automated process. Out of these, Integromat and Power Automate have a Survey123 connector making it easier to implement your processes. This article guides through an example using Power Automate.

What will you need to create Survey123 webhooks?

  • ArcGIS Online (AGOL) Organisational account
  • Your Survey123 form published into AGOL
  • Office 365 account to access Power Automate

Below is a workflow for creating a webhook that triggers an alert email if the submitted data meets a condition (for example the weather is Adverse).

1.  Open Power Automate (go to your O365 account and search for the app), go to My flows and click on + New > Automated - from blank :

2.  Give your webhook a meaningful name, so you know which one to edit/disable later if needed when you have more of them.

3.  Search for ‘Survey123’ under Choose your flow’s trigger, select When survey response is submitted and log in to your AGOL account (you only need to log in once, the connection is stored in your Flow profile). No alt text provided for this image

4.  Select your survey from the drop-down and click on New Step.

 No alt text provided for this image

5.  Choose an action: for example Condition

No alt text provided for this image

and add your survey field(s) and the value(s) you want the webhook to be triggered for. You can select your survey fields from the Dynamic content part for the condition:

 No alt text provided for this image

Under the If yes branch, add a new step (click on the ‘+’ sign) and search for Send an email (Outlook). Set up the required details and save your flow – use both Save buttons: one at the bottom and one in the top right corner! 

No alt text provided for this image

You should be able to see the webhook triggered on the webhook’s page under Runs

No alt text provided for this image

If you click on an item on the list, you can see the details of that run. You can use this to see if a run failed (and why). No alt text provided for this image

6.  Download your survey in the Survey123 app and test your trigger. If you downloaded the survey before the trigger was added, delete the survey and re-download it. Otherwise your webhooks won’t work.

In Part 2 we will discuss how to add the survey time to your webhook/flow and convert time zones.

15 Comments
LiamHarrington-Missin
Occasional Contributor II

Thanks for sharing Zoltan Kovacs,

I'm curious to know whether you have tried to embed the "attach a feature report" to the workflow yet.  There is an article on how to do it in Integromat (Adding Survey123 Feature Report as Output File to Integromat Workflow ) but I'd love to know how this is possible in MS Flow.

zkovacs
Occasional Contributor III

Hi Liam,

Thank you for your comment. I had a quick look in MS Flow and I couldn't find an action for creating feature reports like in Integromat.

Ismael Chivite‌, James Tedrick‌ - can you please let us know if there should be an action in Flow for creating feature reports or is it only available in Integromat? Thank you.

IsmaelChivite
Esri Notable Contributor

Nice article Zoltan! Thanks for putting this together! We have not implemented the Create Feature Report operation in Microsoft Flow. Unfortunately, this is not a straight-forward thing to do.

zkovacs
Occasional Contributor III

Hi Ismael,

Thank you for the confirmation.

Z

IvanKozoletov1
New Contributor III

Hi Ismael,

so if I was planning to use feature reports and designed template I need to use Integromat for my webhooks as MS Flow is not set up that way?

IsmaelChivite
Esri Notable Contributor

Hi Ivan. I am afraid so. Unfortunately, we have not been able to implement Feature Report functionality within Microsoft Flow. We only have this capability within Integromat.

by Anonymous User
Not applicable

In a PDF that was posted relating to this- it said that a future document for creating webhooks with MSFlow (power Automate) in Enterprise will be coming soon. Do you have an idea when. We can not use Integromat because their servers are outside the US and our IT security will not allow access

zkovacs
Occasional Contributor III

Hi John,

The Enterprise version of the webhook guide is yet to be authored as I'm very busy with project work recently, so everything else is put on hold at the moment. Also, our Enterprise/Portal environment will be moved (and upgraded to 10.7.1) to a new host so I cannot really play around with webhooks right now (as the main focus on consolidating and migrating existing services).

You have 2 options:

- If you have an AGOL organisation account, you can connect to your hosted (or SDE) feature services in Portal. You probably need to do some updates to your existing surveys (if any) so you can use the existing FS (you connect to in AGOL) in your surveys. Then you can use MS Flow and it's existing Survey123 connector to log in to AGOL and author your flows. (As mentioned above by Ismael, there is no feature report generation available in Flow - and by the sound of it it will not come to that platform as it is very hard to implement. You can create a custom workflow to populate a Word template with the submitted survey data in Flow, but it may require Premium connectors not included in the standard O365 business plans.)

- There is documentation available on how to create and configure your webhooks manually in Enterprise/Portal and send the payload to Flow/etc. to use in your workflows. I'm afraid I cannot help with that at the moment, but Esri Support should be able to do so if you get stuck.

NB: you need to be a Portal admin to create and configure webhooks in Enterprise/Portal. Creating webhooks in there is a manual process at the moment and I hope the guys at Esri are working on a more user-friendly option...

Enterprise Help section for webhooks: https://developers.arcgis.com/rest/users-groups-and-items/create-webhooks.htm

Related ArcGIS API section: https://developers.arcgis.com/rest/users-groups-and-items/create-webhooks.htm

I hope this helps.

Zoltan

SamuelMackenzie
New Contributor

Does anyone know if accessing data from repeats has been added?

IsmaelChivite
Esri Notable Contributor

Hi Samuel Mackenzie‌. This is currently in development. Targeting 3.10 or 3.11.

HelenCooper
Occasional Contributor III

Thanks for sharing this useful guide. I've followed the instructions to automate an email send when a new survey is added - however I can't seem to trigger the same email when a survey is edited - am I missing something?

Many thanks, 

Helen

zkovacs
Occasional Contributor III

Hi Helen

By default, only new records submitted are captured by the webhook. If you need it to be triggered when a submitted record is edited too, you can enable/change that on the specific webhook. You need to go to the survey123 website and log in to your AGOL account. Under 'Webhooks' you need to enable the 'Existing record edited' option. Make sure that the survey form is updated on the field devices for it to take effect.

I hope this helps.

Z.

erica_poisson
Occasional Contributor III

I am wondering if there has been a change to webhooks from Power Automate with Survey123.

Previously, I was able to create multiple webhooks per survey in Power Automate. I'd created them in Power Automate and then see multiple webhooks listed in Survey123 > Settings > Webhooks. Now, when I create my second webhook it appears to 'overwrite' the original. 

Has anyone experienced this?

mattmerc
New Contributor II

I am seeing the same thing that Erica mentions in the post above. Is this a power automate issue / limitation or a survey123 webhooks issue?

KimberlyMcCallum
New Contributor III

This is great and very useful! Our organization will not allow us to use Integromat which seems a bit more capable and intuitive than MS Power Automate. 
Does anyone know if you can use PA to 'get' an attachment from the Survey123 payload? I can access the REST API URL and put that in the email but that's not too useful as the user would need to create a token to get the file? 

Basically, I'd like to include the attachments from the survey as attachments in the email. 

Thanks in advance if anyone has any info!

About the Author
GIS specialist with over 20 years of professional experience providing consultancy, technical support, training and delivering high quality solutions and support for projects that have a requirement for spatial data interpretation and analysis. Main areas of expertise include (but not exclusively) data management, spatial analysis and modelling, cartography, desktop, mobile and web GIS, Python/ArcPy and webhooks with Power Automate/MS Flow. Former Esri Hungary and Esri UK staff.