How to Use Templates

What Are Templates?

Templates are essentially blueprints where certain parts can be replaced with specific data. They consist of fixed text along with placeholders denoted by double curly brackets ({{ }}). These placeholders will be substituted with actual values when the template is rendered.

Example Usage

Consider the following template:

New Issue in Hooks.im Repository, Opened by {{ .issue.user.login }} - Title: {{ .issue.title }}

When rendered with a GitHub issues.opened (documentation) JSON webhook body:

The output will be:

New Issue in Hooks.im Repository, Opened by john_doe - Title: Fixing authentication bug

Selectors and JSON Webhook Bodies

Currently, only webhook bodies of type application/json are supported for template interpretation. A pure Go implementation of jq is used to process the selectors. Please note that as this relies on a third-party library, not all jq features may be supported.

Warning: As the jq library is a third-party tool, some features may not be fully supported. We are working on providing a template-playground soon to make testing and experimenting with templates easier.

Sample Templates

Name Target Description Template Example
GitHub Issue GitHub Template for GitHub issue creation. New Issue in hooks.im repository, opened by {{ .issue.user.login }} with the title: {{ .issue.title }} New Issue in hooks.im repository, opened by krizz with the title: Template is not working!