Closed rneppell closed 4 years ago
@tedrick Any ideas? We are using Zapier to Slack and explain more in a virtual meeting soon.
The Survey123 webhook does not send attachments with the payload; this would significantly increase the payload size (attachments start at 100KB; the survey portion is normally on the order of 10KB at most). Attachments can be retrieved through:
1) Make a queryAttachment
call to the feature service using the objectID from the payload:
Ex (note: you will need to supply token parameter for secured services): https://services5.arcgis.com/jMCHJcLe13FaKCFB/arcgis/rest/services/survey123_3dcffd324ac64f60ad84cc43e3f105a7_stakeholder/FeatureServer/0/queryAttachments?objectIds=1&f=pjson
Response:
{
"fields" : [
{
"name" : "ObjectId",
"type" : "esriFieldTypeOID",
"alias" : "ObjectID",
"sqlType" : "sqlTypeOther",
"domain" : null,
"defaultValue" : null
},
{
"name" : "globalid",
"type" : "esriFieldTypeGlobalID",
"alias" : "GlobalID",
"sqlType" : "sqlTypeOther",
"length" : 38,
"domain" : null,
"defaultValue" : null
}
],
"attachmentGroups" : [
{
"parentObjectId" : 1,
"parentGlobalId" : "7ae30340-b999-4655-806b-a5f0e13448de",
"attachmentInfos" : [
{
"id" : 1,
"globalId" : "87361b48-35d4-4436-855b-0e5c0cfb7be9",
"name" : "image_1_20190926093246.jpg",
"contentType" : "image/jpeg",
"size" : 242695,
"keywords" : "image_1",
"exifInfo" : null
},
{
"id" : 2,
"globalId" : "12fdaa6f-6873-4f85-87fb-fbfb16c65f3d",
"name" : "signature-20190926093302348.png",
"contentType" : "image/png",
"size" : 34012,
"keywords" : "image_2",
"exifInfo" : null
},
{
"id" : 3,
"globalId" : "d277927d-d5cc-434e-8794-d4d23afbf9b9",
"name" : "signature-20190926093302370.png",
"contentType" : "image/png",
"size" : 34713,
"keywords" : "image_3",
"exifInfo" : null
}
]
}
]
}
2) Based on the id, the URL of the attachments can be determined as <FEATURE SERVICE>/<FEATURE OBJECTID>/attachments/<ATTACHMENT ID>
:
3) Retrieve the attachment within the workflow and then process as a file attachment.
We are continuing to develop this workflow.
I looked into whether it was possible for me to add image attachments to the Slack posts for those submissions that include attachments. At the moment, I don't think I've got the data needed to do so, but wanted to see if Paul/Jared could look on the Survey123 side and see if there might be a way to tell it to send attachment info in more detail.
At the moment, the attachment/image info doesn't come through anywhere except in the big 'applyEdits' field that contains all the data; within that there's a section that looks similar to:
attachments: {u'adds': [{u'parentGlobalId': u'{266aea7e-4bb7-46db-8556-2e51f3394bfb}', u'globalId': u'{6bfbafbb-9dc5-460a-813f-ed2e65913932}', u'uploadId': u'c343d1524c9040f1adf24cb1d04001c3', u'keywords': u'iaImage', u'name': u'image0.jpeg'}]}
...there may be a way to combine the various filenames/variables in there to form an image URL, but it's not immediately obvious to me how to do that.
So: if y'all could take a look and see if there might be anything that looks tweak-able on the Survey123 side to provide more data on the attachment images, let me know if any options present themselves there...