Add or Remove ChatIDs to a TICK Script Automatically

I’m trying to allow a user to “opt-in” or “opt-out” of receiving alerts via Telegram.
So far I know that I can have multiple ChatIDs per alerts as follows:

var triggerTemp = temp
.crit(lambda: “temp” > upperTempCrit OR “temp” < lowerTempCrit)
.message(deviceName + ’
Temperature changed to{{if eq .Level “CRITICAL”}} CRITICAL {{else if eq .Level “OK”}} OK {{end}}
Reading: {{ index .Fields “temp” }}°C
Time: {{ .Time.Local.Format “Mon, Jan 2 2006 at 15:04:05 MST” }}’)

Is there a way to add/remove/edit these TICK scripts with data from a database or text file or something similar so that when a user opts in or out they can be added or removed?

have you tried the sideload node ?
This allows the tick script to read in data from a configuration file.
I have used the functionality to read in maintenance windows, and server specific thresholds, but not to add a variable number of chat ids.

Alternatively you can define these scripts via the kapacitor API, so could you periodically read your database of subscribers and then using the API delete and re-define the tick script with the desired subscribers ?

I found the sideload docs, but I’m not 100% sure how I could use it to add or change the TICK script, could you perhaps provide an example of how you got yours working?