A demo showing how completed assignments can be stored in SQLite database and pushed to a slack channel in near real-time or emailed to you.
- Install Conda or Miniconda (plus requests) and the ArcGIS API for Python package as described here.
- Clone or download this repository
- Install the repo requirements via Conda
- Set up Slack webhook and/or Gmail account (with permissions for "less secure apps"). Use the yagmail directions here to store credentials for your Gmail account before running this script
- Modify the config.ini file to use your ArcGIS online credentials, the workforce project, (optionally) the slack web-hook, (optionally) Gmail email credentials, and the log file.
- Run the script as
python assignment_monitor.py
- Open a workforce project as a worker on an android or ios device and complete an assignment.
- The script polls the feature service every 5 seconds so you should see a slack notification on your designated channel within 5 seconds.
In a real-world scenario, this script can be modified to run once (not loop forever). It would be called every so often (ie. once per minute) by a task scheduler such as Windows Task Scheduler or Cron.
- It creates a SQLite database and the required table (if necessary)
- It then loads into memory any GlobalID values stored in the database
- It queries the assignment feature service of the specified workforce project to find completed assignments
- It checks each assignment to see if it was already added to the database, if not, then it is inserted
- If there was a newly completed assignment, some details of it are posted to the configured slack channel.
- It then waits for 5 seconds and repeats steps 3-6 until manually stopped (CTRL-C)