The GAS Template is a broadly usable template to create scripts, that are to be used in connection with Habitica.
It provides users with a simple interface to install, update and deinstall their script - without the need to provide the Web App URL manually or to keep track of the installation status. On the other hand, it provides various helper functions to script authors and takes care of the most common tasks around Habitica webhooks. This also ensures reliable and consistent execution among all scripts using this template, since utility functions aren't implemented again and again, but updated on all scripts as soon a issue arises.
For users:
- simplified installation procedure
- visual interface for script maintenance (installation, updating, deinstallation)
For script authors:
- pre-written section for user options and customizations
- pre-formed functions for option validation and installation of triggers / webhooks
- ready-to-use functions for webhook and trigger processing
- API functions handling caching, rate limiting and error detection
- numerous utility functions for common actions
- improved logging capabilities
The installation instructions are given on the Wiki page.
Assuming you have some experience with scripting within Google Apps Script, the following steps are way less detailed than the instructions for users.
To start authoring your own script based on the GAS Template, the rough steps are as follows:
- Get a copy of the template
- either by making a copy via Google Apps Script
- or by forking the GitHub repository (my personal recommendation)
- Prepare everything for configuration and installation of your script in
setup.gs
- Enter your User ID under
AUTHOR_ID
and enter the name of your script inSCRIPT_NAME
for the X-Client header - Add options and customizations to the top of the script - accompanied by corresponding validations in
validateOptions()
- Modify
createTriggers
andcreateWebhooks
, adding everything your script will need
- Enter your User ID under
- Implement all your functionality in
code.gs
- There is an example function
processTrigger()
, that may be used for regularly recurring tasks - Webhooks are handled by the
processWebhook()
functions - one for immediate reactions and one for heavy work, that is not time critical
- There is an example function
For most applications, this should be more than enough to fulfill all your needs. But feel free to also look under the hood and modify the template, if something special is needed.
Users and authors alike can contribute to this template and a hassle-free script experience for everyone:
🐞 | Issues | If you detect an issue, feel free to raise it |
❔ | Questions | Any questions you have, are welcome |
💡 | Suggestions | I will be happy to discuss your suggestions |
- This template wildly extends the capabilities of the Streamlined Event-Driven (Webhook) Script Template
- Most of the code was inspired by bumbleshoot's Automate Habitica, thank you for paving the way ❤️