I was wondering if there was a way to trigger a Python script after a hosted feature layer is edited. Right now, the Python script runs every 15 minutes on Task Scheduler. This works fine, but seems excessive as the script really only needs to run after the hosted feature layer is edited. TIA.
ArcGIS Notebook server allows for this using feature service webhooks and python in an ArcGIS Notebook.
https://developers.arcgis.com/rest/enterprise-administration/notebook/execute-notebook/
Unfortunately the execute notebook API is only available in ArcGIS Enterprise, and not ArcGIS online. We are relegated to scheduled runs in agol hosted notebooks.
It should be similar for task scheduler. Options scheduling, but to allow for an external process to invoke a local python script... Seems problematic.
Do your edits require ArcPy, or can they be done using the ArcGIS API for Python? If it's the latter you could create a serverless function (AWS Lambda, Azure Functions, etc.) and put the editing script in it, then have a webhook call it. If I remember correctly the webhook should pass a token that the serverless function can use for authentication when calling edit_features.
If you aren't already doing this, you could minimize the amount of editing your notebook is doing using timestamps and edit tracking:
Like the others have said, there isn't a way to automatically trigger a python script whenever certain edit criteria is met. However, with the release of power automate for arcgis there could be potential for some kind of automated trigger event to execute the script. I would need to dig in deeper to find if there is such a thing.