Skip to main content
On occasion, there is a need to transform JSON template data in order to use it with an integration’s endpoint. Use functions to further customize your webhook payloads. The Go template language – and other tools that make use of it – uses template functions and pipelines to make transformation flexible and powerful. Template functions follow the syntax function arg1 arg2…, and pipelines draw on the UNIX concept of chaining together a series of template commands to express a series of transformations separated by a “pipe” (|) character. An example combining functions and pipelines together looks like this:
When evaluated with an Environment of prod, the result will be "PROD". All the standard Go template actions, functions, and a dozen or so additional template functions are available for use when authoring templates.

date

date formats a timestamp:
The above returns 2024-11-22. Useful in conjunction with .Alert.Timestamp

join

join joins a list of things into a single string with the provided separator:
The above returns group1,group2,group3.

lower

lower converts the entire string to lowercase:
The above returns hello.

now

now returns the current time at the time of template execution. Most useful with date.

quote

quote wraps the string in double quotes:
The above returns "prod" assuming the value of ”.Environment” is prod.

sort

sort sorts a list of strings into alphabetical (lexicographical) order:
The above returns [apple banana orange].

split

split splits a string into a list of strings:
The above returns [one two three].

toJson

toJson encodes an item into a JSON string. If the item cannot be converted to JSON, then the function returns an empty string.
The above returns ["apple", "banana", "orange"].

trim

trim removes whitespace from either side of a string:
The above returns hello.

trunc

trunc truncates a string by a specified number of characters:
The above returns hello.
The above returns world.

upper

upper converts the entire string to uppercase:
The above returns HELLO.

duration

duration formats a given amount of seconds in human-readable time:
The above returns 1m35s.