Webhook Notification Template
A webhook represents a service destination, where an incoming notification can be consumed programmatically. For example, an incoming notification about an event can trigger a webhook destination to a backend microservice to act based on the content of the incoming notification.
For more information about the Webhook destination, see here.
Constructing a webhook notification template
Construct the template block. Make sure the template is a well-formed JSON that adheres to the Handlebars template syntax and semantics.
Handlebars is a templating language that allows for dynamic content generation within templates.Handlebars can be used to customize notification messages using template variables and conditional logic.
If the UI is used to create the template , Handlebars is used to create the payload for the body of the template. If API/CLI is used to create the template the payload must be encoded to the Base64 format. Refer the sample template for UI or AI/CLI.
UI webhook notification template example
{
{{#equal data.alert_definition.severity "Critical"}}
"severity": 1,
{{/equal}}
{{#equal data.alert_definition.severity "Info"}}
"severity": 2,
{{/equal}}
{{#equal data.alert_definition.severity "Error"}}
"severity": 2,
{{/equal}}
"console": "toc",
"version": "1.0",
"crn": {
"version": "v1",
"ctype": "public",
"cname": "bluemix",
"resource_type": "object",
"resource": "event-notifications",
"service_name": "event-notifications"
},
"alert_id": "{{data.alert_definition.id}}",
"tribe_name": "Mobile",
"disable_pager": "false",
"source": "{{source}}",
"tip_msg_type": "create.notice",
"situation": "{{ibmendefaultshort}}",
"customer_impacting": "false",
"runbook_toc_enabled": "false",
"short_description": "{{ibmendefaultshort}}",
"product_ready_compliance": "true",
"long_description": "{{data.alert_definition.description}}",
"timestamp": "{{time}}",
"alert_ui_url": "{{data.links.view_alert}}",
"runbook_url": "{{data.alert_definition.meta_labels.runbook}}"
}
API or CLI webhook notification template example
{
"name": "Template for TIP",
"params": {
"body": "ewogIHt7I2VxdWFsIGRhdGEuYWxlcnRfZGVmaW5pdGlvbi5zZXZlcml0eSAiQ3JpdGljYWwifX0KCQkic2V2ZXJpdHkiOiAxLAoJe3svZXF1YWx9fQogIHt7I2VxdWFsIGRhdGEuYWxlcnRfZGVmaW5pdGlvbi5zZXZlcml0eSAiSW5mbyJ9fQoJCSJzZXZlcml0eSI6IDIsCgl7ey9lcXVhbH19CiAge3sjZXF1YWwgZGF0YS5hbGVydF9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