I created a public survey using Survey 123, now my manager wants to get email notification whenever a survey is submitted. I understand can set up webhook using Power Automate or Make (formerly Integromat), but we don't have a Microsoft 365 subscription, so Power Automate isn't an option, and we lack a G workplace account, preventing the use of Make. I am stuck... Can anyone provide assistance? Is there a script, whether in Python, Java, or any other language, that can handle this workflow? Any help would be greatly appreciated.
Hi @JinMa2 ,
Here is what I found using Bing Chat Enterprise for you:
Sure, you can handle webhooks from Survey123 using Python on a local machine. Here’s a general approach:
Set up a local server: You can use a Python framework like Flask or Django to set up a local server that can listen for incoming HTTP requests.
Create an endpoint for the webhook: In your Python application, create an endpoint that Survey123 will call when a survey is submitted. This endpoint should be capable of handling POST requests, as webhooks typically send data via POST.
Parse the incoming data: When your endpoint receives a request, it will come with a payload containing the data from Survey123. You’ll need to parse this data from the request to use it in your application.
Process the data: Once you’ve parsed the data, you can process it as needed by your application.
Here’s a simple example using Flask:
from flask import Flask, request
app = Flask(__name__)
@app.route('/webhook', methods=['POST'])
def handle_webhook():
data = request.get_json()
print(data)
# Process the data here
return '', 200
if __name__ == '__main__':
app.run(port=5000)
Webhooks are probably the best approach for this type of thing, but an alternative would be to use a ArcGIS Online Notebook that scans your service for new emails at intervals using Python, for example every 15 minutes or every 30 minutes.
You'd want to create a feature service that has a table where you keep the last known count of surveys. When the script runs, check your current count against the old count and send an email that indicates how many new surveys have been submitted. After doing so, update your table's count.
If you'll be deleting surveys, you'll want to enable edit tracking, store a "last checked" timestamp rather than a count, and scan for records that are newer than your last timestamp.
As an alternative to a single email, you could send one email for each new record you find.
The main downside of this approach is the delay between submission and notification, however the delay will be at most 15 minutes, if that's how you configure your notebook.
Hi @JinMa2,
Here is what Ismael Chivite write in 2018 about this topic: A simple e-mail notification system for Survey123 ... - Esri CommunityP
...probably much more authoritative than Bing Chat Enterprise 😊
Cheers
Stefano