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

7191
12
11-08-2019 05:32 AM
Occasional Contributor II
9 12 7,191

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.

12 Comments
New Contributor III

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.

Occasional Contributor II

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.

Esri Frequent 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.

Occasional Contributor II

Hi Ismael,

Thank you for the confirmation.

Z

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?

Esri Frequent 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.

New Contributor III

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

Occasional Contributor II

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

New Contributor

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

Esri Frequent Contributor

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

New 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

Occasional Contributor II

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.

About the Author
GIS specialist with over 16 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. Former Esri Hungary and Esri UK staff. Feel free to connect or message.