Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Apify actor for sending Slack notifications via webhooks

License

Notifications You must be signed in to change notification settings

tlinhart/actor-slack-notification-webhook

Repository files navigation

Slack notification actor

This actor is supposed to be run via webhooks to send Slack notifications about other actor/task's events.

Slack setup

This actor uses Incoming Webhooks for sending the messages. Refer to this article for the setup process.

Using the actor

To start getting notifications for an actor (or task) create a new webhook for that actor (or task). As a webhook URL, use:

https://api.apify.com/v2/acts/tlinhart~slack-notification-webhook/runs?token=<APIFY_TOKEN>

where APIFY_TOKEN is your Apify API token. You can find the token on the Integrations page in the Apify console. You can also add other parameters supported by the Run actor endpoint to the URL, such as timeout and memory. Select events for which you would like to receive notifications. Update the default webhook payload template with slackWebhookUrl and optionally slackWebhookArguments to override the defaults (see default-webhook-args.json):

{
    "slackWebhookUrl": "https://hooks.slack.com/services/TXXXXX/BXXXXX/XXXXX",
    "slackWebhookArguments": { ... },
    "userId": {{userId}},
    "createdAt": {{createdAt}},
    "eventType": {{eventType}},
    "eventData": {{eventData}},
    "resource": {{resource}}
}

The slackWebhookArguments parameter supports most of the arguments supported by the Node Slack SDK, namely:

  • channel
  • username
  • iconEmoji
  • iconUrl
  • text
  • blocks
  • attachments
  • linkNames
  • unfurlLinks
  • unfurlMedia

To make the message format more flexible and customizable, all the string values support JavaScript-like string interpolation. The variables that are available for interpolation are those provided by the Apify platform in the default payload template and also variables provided by this actor:

  • actor – object returned by the Get actor endpoint
  • task – object returned by the Get task endpoint
  • runLog – actor run log returned by the Get log endpoint

By default, the message contains information about the actor (and the task if available) and its run together with the last 15 lines of the run log.

Default message format

About

Apify actor for sending Slack notifications via webhooks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published