Get Attachments Using Survey123 Webhooks, Integromat, and Eledo PDF Generator, and Add Them to the PDF Template

1413
5
01-31-2019 05:21 PM
Highlighted
Occasional Contributor II

I am attempting to use webhooks to retrieve a payload of submitted survey attributes, generate them into a PDF using Integromat and the Eledo PDF generator integration, and then send the PDF as an email attachment. So far all of this works pretty seamlessly. The only issue I have is that the feature service's related table that my surveys stem from has attachments enabled, which I would like to have added to the PDF as a dynamic image (or more advanced repeating dynamic images if more than one photo exists in the array). I can set the Eledo PDF template to use an Image Type of URL (preferred), or Image. However, I can't seem to get any of this to work, and I don't see enough information coming through the payload to figure it out. Additionally, making matters a bit more challenged is that my published service is not shared publicly. Has anyone attempted to do this? I like this route better than building reports in Survey123 or printing directly from the Survey123 website, since using webhooks makes it happen at submission time and doesn't require any manual steps. I had thought about using the REST endpoint of the service URL with something like Query Attachments, but I still wasn't seeing how to extract the image URL going that route, and I believe I will need to generate tokens as well. Any thoughts, tips, or advice would be extremely helpful.

5 Replies
Highlighted
Esri Esteemed Contributor

Hi Dave,

The applyEdits payload does not contain information about the final location of an attachment.  This must be derived by querying the feature service with a queyAttachments call (see Query Attachments (Feature Service/Layer)—ArcGIS REST API: Services Directory | ArcGIS for Developer... ) and then constructing the attachment's URL (of the pattern specified at Attachment (Feature Service)—ArcGIS REST API: Services Directory | ArcGIS for Developers ) from the result.

Highlighted
Occasional Contributor II

Thanks James! Your timing is impeccable. So it looks like the response I was typing out as you were also answering this question appear to be more or less on the right track. Glad to know there is a solution for it and I will look at testing this down the road, but for now I am moving on since attachments aren't needed for this specific project.

Reply
0 Kudos
Highlighted
New Contributor II

James,

I have an additional question. I see where on your link it states that "Note: Query attachment is supported if supportsQueryAttachments is true in the feature layer." Where do you enable or disable that? I can't seem to find it in the GIS Server, in the portal or in Survey123 Connect. The portal version is 10.51 and it states it was put in in version 10.50. Any advice would be helpful.

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Craig,

I'm not aware of a setting to specifically disable that; it may be possible in a hosted service to do so via an updateDefinition call.  In general, a number of these properties are reporting flags and not intended to be user-alterable settings (enableApplyEditsWithGlobalIds is an example of this).

Reply
0 Kudos
Highlighted
Occasional Contributor II

Rather than leave this hanging out here unresolved, I will attempt to answer my own question, but please keep in mind that I have yet to test it out, because the capability of adding image attachments is no longer required for this particular project. However, if inquiring minds would like to know I will share how this might be accomplished in Integromat. It appears that all the attachment attribute data needed to build a functioning URL to allow an attachment to stream-in does not get pushed to the webhooks payload by default, or at least I couldn't find it even with all the Survey123 webhooks "Event data" items checked on. Maybe I missed something, but I didn't see a way to construct a dynamic URL directly from the payload. So, perhaps the better way to make this work is to use Integromat's HTTP module to leverage specific calls using the ArcGIS REST API.

Again I have not tested this, but in my example from the OP above you would need to do two HTTP requests: 1) generate a token, and 2) get the specified dynamic parts of the attachment URL. Once those pieces have been retrieved then in the Elado one could create the image URL and use the Integromat Iterator to add images if there were more than one to add. Additionally, you would want to add repeats in the Elado template maker to handle multiple images as well. I am a little unsure about how to get the attachment ID numbers, but I did see that in the webhooks payload both GlobalIDs and parentGlobalIDs come through for the attachments, so that could be a possible way to get the relevant attachment IDs for the URL. Also, there is an UploadID field, which might prove useful in getting an answer. When all is said and done you should have a URL resembling the following below.

  

On paper, this seems to make sense, but again the challenge will be to get the right attachment IDs that are relevant to the correct images.