Notification Subscription Templates

From FojiSoft Docs

FojiSoft's Notification Subscriptions utilize Handlebars template expressions to dynamically insert and format data within notifications. This guide explains the available expressions, helper functions, and variables to help you create meaningful and informative notifications.


Handlebars Expressions Overview

Handlebars expressions are used to embed dynamic content within templates. These expressions are enclosed in {{ }} and allow access to variables and helper functions. Complete Handlebars documentation is available at https://handlebarsjs.com/guide/expressions.html

Example:

{{variableName}}

Helper Functions

Helpers provide additional functionality to format or manipulate data. In FojiSoft Notifications, the following helper is available:

now

The now helper renders the current date and time. It supports the following optional hash parameters:

  • format: Specifies the date/time format. Refer to the date-fns format documentation for available options.
  • timeZone: Specifies the time zone in which the date/time should be rendered.

Example:

{{now format="yyyy-MM-dd HH:mm:ss" timeZone="UTC"}}

Available Variables

The variables in FojiSoft Notification Subscriptions are grouped based on specific contexts such as Agent Pools, Billing, Events, Incidents, Pathways, and Visualize. Below is a detailed breakdown of these variables.

1. Agent Pools

These variables provide details about the affected agent pool:

  • agents: Number of connected agents in the affected pool.
  • id: ID of the affected pool.
  • name: Name of the affected pool.

2. Billing

Billing-related notifications are categorized as Invoice Created and Payment Received.

Invoice Created

  • charges: Total amount of charges.
  • credits: Total amount of credits applied to the invoice.
  • invoiceNumber: Invoice number.
  • period: Billing period (From - To dates).
  • url: URL to view the invoice.

Payment Received

  • amount: Total payment amount.
  • invoiceNumber: Associated invoice number.
  • paymentNumber: Payment number.
  • period: Billing period.
  • transactionId: Transaction ID from the financial system.
  • url: URL to view the payment receipt.

3. Events

Event notifications include the following variables:

  • data: A data object passed from the source system. Use path expressions to access additional values.
  • description: Optional descriptive text for the event.
  • labels: A string map of label values for the event. Access values using path expressions.
  • name: Name of the event.
  • severity: Numeric severity level of the event (0-100).
  • url: Optional URL passed from the source system.

4. Incidents

Incident notifications are categorized as Event Correlated and Incident Created.

Event Correlated

  • category:
    • id: ID of the Incident Category.
    • name: Name of the Incident Category.
  • event: Object containing event information (see the "Events" section).
  • incident:
    • events: Number of events correlated in the incident.
    • id: ID of the incident.

Incident Created

  • category:
    • id: ID of the Incident Category.
    • name: Name of the Incident Category.
  • incident:
    • id: ID of the incident.

5. Pathways

Pathways variables are tied to the "Send Notification" task within a Pathway.

  • data: Data object containing fields defined in the "Send Notification" task. Values are accessible using path expressions.
  • path:
    • id: ID of the Pathway.
    • name: Name of the Pathway.
  • text: Text value defined in the "Send Notification" task.

6. Visualize

Visualize variables relate to alerts and dashboards.

  • data:
    • dashboard: URL to the related dashboard.
    • labels: String map of label values for the alert. Access values using path expressions.
    • panel: URL to the related panel.
    • status: Status of the alert (firing or resolved).
    • values: Map of values for each expression in the alert rule. Access values using path expressions.
  • firing: Boolean indicating if the alert status is firing.
  • labels: String map of label values for the alert.
  • resolved: Boolean indicating if the alert status is resolved.
  • url: URL to view the related panel for the alert.

Path Expressions

For variables containing objects or maps (e.g., data, labels), use path expressions to access nested values. For example:

{{data.someNestedValue}}
{{labels.labelKey}}

Example Templates

Here are some example templates using the above variables and helpers:

Example 1: Agent Pool Notification

The agent pool "{{name}}" currently has {{agents}} connected agents. Pool ID: {{id}}.

Example 2: Invoice Notification

An invoice ({{invoiceNumber}}) for the period {{period}} has been created. Total charges: {{charges}}. View it here: {{url}}.

Example 3: Event Notification

Event "{{name}}" occurred with severity {{severity}}. Description: {{description}}. More details: {{url}}.

By leveraging these expressions and variables, you can create highly customized and informative notifications tailored to your organization’s needs.