geoform-template-js icon indicating copy to clipboard operation
geoform-template-js copied to clipboard

GeoForm notification system

Open driskull opened this issue 9 years ago • 16 comments

Need an option to be able to get notified of a submission

check out geoevent extension, it can send an email.

driskull avatar Jul 21 '15 23:07 driskull

:+1:

pjdohertygis avatar Aug 05 '15 00:08 pjdohertygis

I did email notifications for a customised geoform site using mandrill. They have simple API for sending messages. https://mandrillapp.com/api/docs/messages.JSON.html

Just had to add the call to their API in the applyEdits handler

this._formLayer.applyEdits([featureData], null, null, lang.hitch(this, function (addResults) {

$.ajax({
    type: "POST",
    url: "https://mandrillapp.com/api/1.0/messages/send.json",
    data: {
        'key': '<your-api-key>',
        'message': {
            'from_email': '[email protected]',
            'to': [{
                'email': '[email protected]',
                'type': 'to'
            }],
            'autotext': 'true',
            'subject': 'New Geoform submission',
            'html': 'There is a new submission from ' + featureData.attributes['First_Name'] + ' ' + featureData.attributes['Last_Name'] + ' (' + featureData.attributes['Organisation'] + '). Contact at ' + featureData.attributes['Email'] + ' or ' + featureData.attributes['Phone'] + '.'
        }
    }
}).done(function (response) {
    console.log(response);
});

davetimmins avatar Aug 07 '15 02:08 davetimmins

it seems that Mandrill is not free anymore (https://mandrill.zendesk.com/hc/en-us/articles/217467117). Does anyone has another solution for generate a notification from geoform while there is a new entry? Thanks in advance!

angelinasavchuk avatar Apr 11 '16 14:04 angelinasavchuk

SparkPost looks like a good alternative https://www.sparkpost.com/mandrill-migration-guide

davetimmins avatar Apr 11 '16 19:04 davetimmins

We configured our app to use http://www.formget.com/jquery-contact-form/ along with a simple .asp app.

srkiley avatar Apr 11 '16 20:04 srkiley

Can you develop, please, a little bit more how you did it? I never really worked with code, there is too much technical details for me.. Thanks in advance!

angelinasavchuk avatar Apr 13 '16 09:04 angelinasavchuk

I actually was incorrect. We tested using formget.com, but instead wen with the .asp page. Just create a file of type .asp in the root folder of your GeoForm app and add the code below: `<% set ObjSendMail = CreateObject("CDO.Message") ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.gmail.com" ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="[email protected]" ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="youremailPW"

ObjSendMail.Configuration.Fields.Update

emailbody = request.form("html") emailsubject = request.form("subject") from = request.form("from_name") &"<"& request.form("from_email") &">" emailto = request.form("name") &"<"& request.form("email") &">" attach = request.form("attachment") bcc = request.form("bcc")

ObjSendMail.To = emailto ObjSendMail.Subject = emailsubject ObjSendMail.From = from ObjSendMail.Bcc = bcc ObjSendMail.AddAttachment attach

ObjSendMail.HTMLBody = emailbody

ObjSendMail.Send Set ObjSendMail = Nothing %>`

** Notice that you will need access to a web based email account like gmail.

Then add the call to the .asp page in the applyEdits handler similar to as was suggested with Mandrill.

$.ajax({ type: "POST", url: "email.asp", data: { 'name': featureData.attributes['Name'], 'email': featureData.attributes['Email'], 'from_email': '[email protected]', 'from_name': "GeoForm auto response", 'idea': featureData.attributes['Idea'], 'bcc': '[email protected];[email protected];', 'subject': featureData.attributes['Name'] + ' - ' + featureData.attributes['Idea'], 'attachment': 'https://somesite.com/Logo.png', 'html': '<font face="Tahoma" size="2"><p>Hello ' + featureData.attributes['Name'] + ',</p>' + 'This is an automated response confirming your submission to The GeoForm.<br><br>Your submission has been received. <br><br>Thanks,<br><br>GeoForm</font><br><br>' + '<a href="' https: //somesite.com"><img alt="'https://somesite.com/Logo.png" id="Picture_x0020_1" src="cid:ATT00001.png" width="150" height="145">' } }).done(function (response) { console.log(response); })

Sorry about the lack of formatting in the JavaScript. It's just how it came in using the insert code button.

srkiley avatar Apr 13 '16 13:04 srkiley

I have used scheduled python scripts to just check the editor tracking fields and shoot off emails periodically.

clm42 avatar Apr 13 '16 21:04 clm42

Thanks @srkiley !

Can you please specify in which file you added the ajax code? Because I'm using geoForm from arcgis online and I cannot find that easily the needed file. Should I maybe upload it via "Update code" with a special name?

angelinasavchuk avatar Apr 18 '16 12:04 angelinasavchuk

Sorry about that. I forgot to add that the applyEdits handler is in the main.js file (inside the js folder).

srkiley avatar Apr 18 '16 13:04 srkiley

It doesn't work.. I even contacted Esri, but since it's not an official feature, but a private solution, they cannot help..

I created email.asp file `<% set ObjSendMail = CreateObject("CDO.Message") ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.gmail.com" ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="[email protected]" ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="XXXXX"

ObjSendMail.Configuration.Fields.Update

emailbody = request.form("html") emailsubject = request.form("subject") from = request.form("from_name") &"<"& request.form("from_email") &">" emailto = request.form("name") &"<"& request.form("email") &">" attach = request.form("attachment") bcc = request.form("bcc")

ObjSendMail.To = emailto ObjSendMail.Subject = emailsubject ObjSendMail.From = from ObjSendMail.Bcc = bcc ObjSendMail.AddAttachment attach

ObjSendMail.HTMLBody = emailbody

ObjSendMail.Send Set ObjSendMail = Nothing %>`

than in native main.js file I added this :

$.ajax({ type: "POST", url: "email.asp", data: { 'name': featureData.attributes['Name'], 'email': featureData.attributes['Email'], 'from_email': '[email protected]', 'from_name': "GeoForm auto response", 'idea': featureData.attributes['Idea'], 'bcc': '[email protected];', 'subject': featureData.attributes['Name'] + ' - ' + featureData.attributes['Idea'], 'html': '

Hello ' + featureData.attributes['Name'] + ',

' + 'This is an automated response confirming your submission to The GeoForm.

Your submission has been received.

Thanks,

GeoForm


' } }).done(function (response) { console.log(response); })

Than I create a js.zip file and I upoad it via Arcgis Online "Upload code"

capture

Could the problem be arcgisonline? I didn't host the web app on the web server and all app configuration is did via web-interface.

Thank you very much for answering!

angelinasavchuk avatar Apr 18 '16 14:04 angelinasavchuk

I'm pretty sure you cannot push this modified app back into ArcGIS Online to be hosted there. Anything with this level of customization typically requires the app be hosted on your own web server.

srkiley avatar Apr 18 '16 15:04 srkiley

Right. AGOL doesn't let you use custom code that you upload, just share it for download. Anything custom has to be hosted elsewhere.

clm42 avatar Apr 18 '16 15:04 clm42

Thanks a lot for all your answers! I tried it, but because of many technical reasons and because I'm not a programmer, but a geography student - it doesn't work. Esri proposed to vote for this on their Ideas site, to integrate it like a function, so we don't have to write anycode. Here is the link, you can vote : https://c.na9.visual.force.com/apex/ideaView?id=087E0000000CwMPIA0. I hope they will consider this, beause it's a bit strange to create a open for all users form, and to be forced to check it mannualy for new entries..

angelinasavchuk avatar Apr 19 '16 14:04 angelinasavchuk

I found this discussion very helpful. Thanks to all that contributed. myplacebook, I was not able to follow your link to the idea's page (probably because of the update a few months back) so I have added the link to the idea I believe you were referencing. https://geonet.esri.com/ideas/10344

memblue13 avatar Jul 07 '16 11:07 memblue13

@memblue13 you're absolutely right :) hope they're going to fix it!

angelinasavchuk avatar Jul 09 '16 21:07 angelinasavchuk