> ## Documentation Index
> Fetch the complete documentation index at: https://docs.honeycomb.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Webhook Functions

> Transform JSON template data in your Honeycomb webhook payloads using Go template functions to format, filter, and restructure alert content before delivery.

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](/notify/webhooks/#customize-your-webhook).
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:

```go-template theme={}
{{ .Environment | upper | quote }}
```

When evaluated with an Environment of prod, the result will be `"PROD"`.

All the standard Go template [actions](https://pkg.go.dev/text/template#hdr-Actions), [functions](https://pkg.go.dev/text/template#hdr-Functions), and a dozen or so additional template functions are available for use when authoring templates.

### date

`date` formats a timestamp:

```go-template theme={}
{{ now | date "2006-01-02" }}
```

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:

```go-template theme={}
{{ list group1 group2 group3 | join "," }}
```

The above returns `group1,group2,group3`.

### lower

`lower` converts the entire string to lowercase:

```go-template theme={}
{{ lower "HELLO" }}
```

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:

```go-template theme={}
{{ quote .Environment }}
```

The above returns `"prod"` assuming the value of ".Environment" is `prod`.

### sort

`sort` sorts a list of strings into alphabetical (lexicographical) order:

```go-template theme={}
{{ list orange apple banana | sort }}
```

The above returns `[apple banana orange]`.

### split

`split` splits a string into a list of strings:

```go-template theme={}
{{ split ":" "one:two:three" }}
```

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.

```go-template theme={}
{{ list apple banana orange | toJson }}
```

The above returns `["apple", "banana", "orange"]`.

### trim

`trim` removes whitespace from either side of a string:

```go-template theme={}
{{ trim "  hello  " }}
```

The above returns `hello`.

### trunc

`trunc` truncates a string by a specified number of characters:

```go-template theme={}
{{ trunc 5 "hello world" }}
```

The above returns `hello`.

```go-template theme={}
{{ trunc -5 "hello world" }}
```

The above returns `world`.

### upper

`upper` converts the entire string to uppercase:

```go-template theme={}
{{ upper "hello" }}
```

The above returns `HELLO`.

### duration

`duration` formats a given amount of seconds in human-readable time:

```go-template theme={}
{{ duration 95 }}
```

The above returns `1m35s`.
