Slack

Let’s say that you want to trigger a Slack notification whenever a Notify17 notification is generated (e.g. having Notify17 act as a notification relay service).

First of all, you need to create an incoming webhook  in your Slack workspace, or use an existing one.

Note: Slack API info can be found at https://api.slack.com/messaging/webhooks#posting_with_webhooks 

You can then import an action definition like the following one (replace the REPLACE_HOOK_URL with the one you just obtained in the previous step):

Example
label: Slack
action: httpRequest
args:
  
  # This body is written as a YAML text, and is converted automatically
  # to JSON because of the `bodyIsYAMLToJSON` option.
  body: |-
    username: Notify17
    icon_emoji: ":ghost:"
    text: |
      # __n17Title and __n17Content contain the generated title/content 
      # of the notification, which we can send to Slack.
      {{ .__n17Title }}
      {{ if .__n17Content }}{{ .__n17Content | nindent 2 }}{{ end }} 

    # If desired, we can add more formatted content.
    # In this case, the "title" of the notification has bold formatting.
    blocks:
    - type: section
      text:
        type: mrkdwn

        # __n17Title and __n17Content contain the generated title/content 
        # of the notification, which we can send to Slack.
        text: |
          *{{ .__n17Title }}*
          {{ if .__n17Content -}}
          {{ .__n17Content }}
          {{ end }}
          {{ if .__n17Content -}}{{ .__n17Content | nindent 6 }}{{ end }}    

  # Converts the `body` block to proper JSON
  bodyIsYAMLToJSON: true

  # Let Slack know we're sending JSON content
  headers: "Content-Type: application/json"

  method: POST

  # NOTE: here you need to put the correct hook url!
  url: REPLACE_HOOK_URL
  
  # The request is successful as long as the status code is between 200 and 299
  successCondition: and (ge .statusCode 200) (le .statusCode 299)

# If the Slack message is sent successfully, we don't need to get notified about it
silentConditions:
  - success

# We can safely generate a Slack message whenever this template is triggered.
autoRuns: 1