Notification actions

Notify17 lets you execute actions from notifications.

General notes

For actions which accept templates, the following variables are additionally available to use:

Variable nameDescription
__n17TitleThe generated notification title
__n17ContentThe generated notification content (avaliable if not empty)

General settings

Here is the list of settings common to all actions types:

Action label

Note: this field can contain templates

The Action label field is a friendly text for you to recall what the action is about, and it becomes the name of the action in the generated notification details screen.

Action type

At the moment, we support only the HTTP request type of action.

Show condition

You can choose a specific condition, which will be evaluated at the notification creation time, to understand if the action should be shown in the notification.

To do so, you need to type an if-template (an expression that you would place inside a if block) to check this condition.

Some examples:

  • Let’s assume you want to deploy a new version of a software, by using an action, and you need to check that the build status was successful. You can use the if-template:

    eq .status "success"
    
  • You want to always show this action:

    true
    

Auto execute

If you enable the Auto execute switch, Notify17 automatically executes the action once, whenever a notification is generated.

Note: notification actions pricing applies to this case too.

Silent when

When you enable one of the Silent when conditions, you will not receive the corresponding notification.

E.g. if you have enabled the Success option, and the action execution succeeds, you will not be notified about it.

Suggestion: this plays well together with the Auto execute option.

HTTP request

The HTTP request action lets you execute a standard HTTP request.

Here is a list of settings specific to the HTTP request action type:

URL

Note: this field can contain templates

The URL field contains the address you want to send the HTTP request to, e.g. https://util.notify17.net/dump.

This field must contain a valid URL, which means a value in the form of ([] is an optional field): SCHEME://SERVER_NAME[:PORT][/PATH][?QUERY]

The following rules apply:

  • SCHEME can only be http or https.
  • SERVER_NAME cannot resolve to a local IP address, including:
    • 10.*.*.*
    • 172.16.*.*
    • 192.168.*.*
    • *::1

Do not follow redirects

When enabled, if the HTTP request returns a Location header, the redirect will not be followed.

This means the result of your action can contain e.g. a 301 status code and a Location header.

Method

The Method field defines the desired HTTP method, and can be set to:

  • GET
  • POST
  • HEAD
  • PUT
  • PATCH
  • DELETE

Headers

Note: this field can contain templates

The Headers field lets you define all HTTP request headers, in the format of a YAML map.

E.g.

# Simple value
Content-Type: application/json
# Multiple values
Accept: 
  - text/plain
  - text/html

Will be converted to:

Content-Type: application/json
Accept: text/plain, text/html

Query parameters

Note: this field can contain templates

The Query parameters field lets you define any query parameters to append to the HTTP request’s URL.

E.g. a request where the URL field is https://util.notify17.net/dump?q=hello, and the Query parameters field is

q: Mr. Anderson
options:
  - say
  - my
  - name

will be executed with the URL:

https://util.notify17.net/dump?options=say&options=my&options=name&q=hello&q=Mr.+Anderson

Body

Note: this field can contain templates

The Body field lets you define the HTTP request’s body.

Convert body from YAML to JSON

When enabled, the Body field will be treated as YAML code, and will be automatically converted to JSON when the action is executed.

Using this format is especially useful when dealing with templates, because of the natural friendliness of the YAML language.

E.g. consider the YAML code (entries is ["hello", "Mr.", "Anderson"])

entries:
{{ range $entry := .entries -}}
- {{ $entry }}
{{ end }}

and its JSON equivalent:

{
  "entries": [
    {{ range $index, $entry := .entries -}}
    {{ if $index }},{{ end }}
    {{ $entry | quote -}}
    {{ end }}
  ]
}

Both of them will be compiled to:

{
  "entries": [
    "hello",
    "Mr.",
    "Anderson"
  ]
}

Note: if you enable the Convert body from YAML to JSON field, remember to add the header Content-Type: 'application/json', or some services will NOT accept the payload, and will treat is as plain text.

Success condition

You can choose a specific condition, which will be evaluated to understand if the HTTP request has been executed successfully.

To do so, you need to type an if-template (an expression that you would place inside a if block) to check this condition.

E.g. to check that the HTTP response status code is between 200 (inclusive) and 299 (inclusive), you can use the expression:

and (ge .statusCode 200) (le .statusCode 299)

The list of fields you can access are:

Field nameTypeDescription
statusCodeintHTTP request status, e.g. 200 for a successful request
contentTypestringWhat kind of content has been returned, e.g. application/json
contentLengthintThe size of the response body in bytes, e.g. 22485
executionTimeMsintHow long it took for the request to be executed, in milliseconds, e.g. 2501
responseBodyBase64stringThe response body, base64-encoded, e.g. SGVsbG8=
headersmapThe headers map, where all keys are lowercase and values are strings (check the examples below for more info)

Note: the responseBodyBase64 will only be available if the response body size (equivalent to contentLength) is <= 64KiB.

Examples

  • The header X-My-Header must equal the value Hello:

    eq "Hello" (get .headers "x-my-header")
    

    The reason why this works is:

    • headers is a map, and get .headers "x-my-header" fetches the value of the x-my-header header, which is a text value (e.g. "Hello").
    • eq "Hello" ... checks that the previously fetched value equals the Hello value.

    Note how we are using the lowercase x-my-header, instead of the original header name. All header names are normalized to lower case in this success condition template.

  • Response status code is between 200 and 399 (inclusive):

    and (ge .statusCode 200) (le .statusCode 399)
    
  • Response status code is exactly 429:

    eq 429 .statusCodes
    
  • Response body equals Ok:

    eq (b64dec .responseBodyBase64) "Ok"
    
  • Response body is a JSON object, and its healthy key has true value:

    eq (parseJson (b64dec .responseBodyBase64)).healthy true
    

Notes

  • The execution timeout for an HTTP request is 30 seconds.
  • The max stored response size is limited to 256KiB. If the response exceeds this size, it will be truncated.
  • Check out the current HTTP request pricing.
  • HTTP requests will be sent from:
    • 35.241.218.165