Using Todoist-Webhooks (https://developer.todoist.com/sync/v7/#webhooks)
App performs input validation and listens to a specific task title. If this specific task is completed, it creates another task for the day. I'm using it to remember when to clock out at work
Perform the following steps
$ git clone [email protected]:BenMatheja/todoist-flask.git
$ cd todoist-flask
$ virtualenv todoist-flask-env
New python executable in todoist-flask-env/bin/python
Installing setuptools............................done.
Installing pip...................done.
$ source todoist-flask-env/bin/activate
$ pip install -e .
$ gunicorn app:app --log-config gunicorn_log.conf
Adapt settings_sample.py to correspond with credentials.
# Configuration for Todoist-Flask
TODOIST_CLIENT_SECRET = ""
TODOIST_API_ACCESS = ""
# Configure maximum allowed working time here
# Its 10:43h for me here, because my company reduces the presence time by 45 minutes if you clocked in before 9:00
# 2 Minutes for application processing
WORKING_HOURS = 10
WORKING_MINUTES = 43
You may use this systemd unit file as template
[Unit]
Description=Gunicorn Application Server running todoist-flask
After=syslog.target network.target electrum.service
[Service]
User=www-data
Group=www-data
ExecStart=/bin/bash -c "source /opt/todoist-flask/todoist-flask-env/bin/activate ;
cd /opt/todoist-flask ;
exec gunicorn app:app --workers 4 --bind localhost:8050 --log-config gunicorn_log.conf"
Restart=always
[Install]
WantedBy=multi-user.target`
Use this sample Request from the Todoist-Webhooks Api generated by the amazing Postman for Curl
curl -X POST \
http://localhost:5000/todoist/events/v1/tasks \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: 07a1a0b2-026a-c7bc-b72a-ac279b0a20b7' \
-H 'user-agent: Todoist-Webhooks' \
-H 'x-real-ip: 127.0.0.1' \
-H 'x-todoist-delivery-id: 1855589' \
-H 'x-todoist-hmac-sha256: UEEq9si3Vf9yRSrLthbpazbb69kP9+CZQ7fXmVyjhPs=' \
-d '{
"event_name": "item:added",
"user_id": 1234,
"event_data": {
"day_order": -1,
"assigned_by_uid": 1855589,
"is_archived": 0,
"labels": [],
"sync_id": null,
"in_history": 0,
"has_notifications": 0,
"indent": 1,
"checked": 0,
"date_added": "Fri 26 Sep 2014 08:25:05 +0000",
"id": 33511505,
"content": "Task1",
"user_id": 1234,
"due_date_utc": null,
"children": null,
"priority": 1,
"item_order": 1,
"is_deleted": 0,
"responsible_uid": null,
"project_id": 128501470,
"collapsed": 0,
"date_string": ""
}
}'