This example shows how to use the automationcli package to build your own CLI tool for running automation routines from the command-line. This is a basic example. For setting up your production routines, and running them on a schedule using GitHub actions or other means, you can fork the template-clarify-automation repo to get started quickly.
The example contains the following automation routines:
- devdata/save-signals: Update meta-data for a status signal in Clarify. No requirements.
- devdata/insert-random: Insert a state for the status signal. No requirements.
- publish: Insert a state for the status signal. Require setting
CLARIFY_EXAMPLE_PUBLISH_INTEGRATION_ID
. - evaluate/detect-fire: Log a message to the console if a fire is detected.
First, you myst download a credentials file for your integration, and a configure the integration to have access to all namespaces. This require that you are an admin in your clarify organization. To avoid passing in options each time, we will export it as a environment variable:
export CLARIFY_CREDENTIALS=path/to/clarify-credentials.json
Secondly, load the database using the devdata routines. Note that the routines are run in an alphanumerical order.
go run . -v devdata
Now, let's publish the signals. For that we need to know the integration ID we should publish from. You can find the integration ID in the Admin panel. Ideally, we would edit the routine code to hard-code the integration IDs to publish from. However, for this example, we allow parsing the information from the environment:
export CLARIFY_EXAMPLE_PUBLISH_INTEGRATION_ID=...
go run . -v publish
Now, let's run our evaluation routine. For that, we need to know the ID from the item that was just published. You can get this ID from the console output, or from Clarify.
export CLARIFY_EXAMPLE_STATUS_ITEM_ID=...
go run . evaluate/detect-fire
You should now have about 45 % chance to see the text "FIRE! FIRE! FIRE!".