Let’s say that you want to send a Slack message whenever a Notify17 notification is generated
(e.g. having Notify17 act as a notification relay service).
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:Slackaction:httpRequestargs:# 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 JSONbodyIsYAMLToJSON:true# Let Slack know we're sending JSON contentheaders:"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 299successCondition:and (ge .statusCode 200) (le .statusCode 299)# If the Slack message is sent successfully, we don't need to get notified about itsilentConditions:- success# We can safely generate a Slack message whenever this template is triggered.autoRuns:1