Modules@robinpath/notification
notification

@robinpath/notification

0.1.2Node.jsPublic

Unified notifications: Slack, Discord, Telegram, and MS Teams via webhooks

Notification

Unified notifications to Slack, Discord, Telegram, and Microsoft Teams via webhooks

Package: @robinpath/notification | Category: Messaging | Type: Integration

Authentication

No authentication required. All functions are available immediately.

Use Cases

Use the notification module when you need to:

  • Send a message to Slack via webhook -- Use notification.slack to perform this operation
  • Send a rich Slack message with blocks (title, fields, images) -- Use notification.slackRich to perform this operation
  • Send a message to Discord via webhook -- Use notification.discord to perform this operation
  • Send a rich Discord embed message -- Use notification.discordEmbed to perform this operation
  • Send a message via Telegram Bot API -- Use notification.telegram to perform this operation

Quick Reference

FunctionDescriptionReturns
slackSend a message to Slack via webhook{ok, status}
slackRichSend a rich Slack message with blocks (title, fields, images){ok, status}
discordSend a message to Discord via webhook{ok, status}
discordEmbedSend a rich Discord embed message{ok, status}
telegramSend a message via Telegram Bot API{ok, messageId}
teamsSend a message to Microsoft Teams via webhook{ok, status}
teamsCardSend a rich MessageCard to Microsoft Teams{ok, status}
sendAllSend a message to multiple channels at onceArray of {channel, ok, error?}

Functions

slack

Send a message to Slack via webhook

Module: notification | Returns: object -- {ok, status}

notification.slack $webhookUrl "Deploy complete!"
ParameterTypeRequiredDescription
webhookUrlstringYesSlack incoming webhook URL
messageanyYesString or Slack message object

slackRich

Send a rich Slack message with blocks (title, fields, images)

Module: notification | Returns: object -- {ok, status}

notification.slackRich $url {"title": "Deploy", "text": "v1.2.3 deployed"}
ParameterTypeRequiredDescription
webhookUrlstringYesSlack webhook URL
optionsobjectYes{title, text, fields, imageUrl, channel, username, iconEmoji}

discord

Send a message to Discord via webhook

Module: notification | Returns: object -- {ok, status}

notification.discord $webhookUrl "Build passed!"
ParameterTypeRequiredDescription
webhookUrlstringYesDiscord webhook URL
messageanyYesString or Discord message object

discordEmbed

Send a rich Discord embed message

Module: notification | Returns: object -- {ok, status}

notification.discordEmbed $url {"title": "Alert", "description": "CPU > 90%", "color": "#FF0000"}
ParameterTypeRequiredDescription
webhookUrlstringYesDiscord webhook URL
optionsobjectYes{title, description, color, fields, thumbnail, image, footer, timestamp}

telegram

Send a message via Telegram Bot API

Module: notification | Returns: object -- {ok, messageId}

notification.telegram $token $chatId "<b>Alert:</b> Server down"
ParameterTypeRequiredDescription
botTokenstringYesTelegram bot token
chatIdstringYesChat/group ID
messagestringYesMessage text (HTML or Markdown)
optionsobjectNo{parseMode, disablePreview, silent}

teams

Send a message to Microsoft Teams via webhook

Module: notification | Returns: object -- {ok, status}

notification.teams $webhookUrl "Task completed"
ParameterTypeRequiredDescription
webhookUrlstringYesTeams webhook URL
messageanyYesString or Teams message object

teamsCard

Send a rich MessageCard to Microsoft Teams

Module: notification | Returns: object -- {ok, status}

notification.teamsCard $url {"title": "Release", "text": "v2.0 deployed", "color": "00FF00"}
ParameterTypeRequiredDescription
webhookUrlstringYesTeams webhook URL
optionsobjectYes{title, text, color, sections, actions}

sendAll

Send a message to multiple channels at once

Module: notification | Returns: array -- Array of {channel, ok, error?}

notification.sendAll $channels "System alert: disk 90%"
ParameterTypeRequiredDescription
channelsarrayYesArray of {type, url/token, chatId}
messagestringYesMessage text

Error Handling

All functions throw on failure. Common errors:

ErrorCause
Slack webhook URL is requiredCheck the error message for details
Discord webhook URL is requiredCheck the error message for details
Bot token and chat ID are requiredCheck the error message for details
Teams webhook URL is requiredCheck the error message for details
@desc "Slack and validate result"
do
  set $result as notification.slack $webhookUrl "Deploy complete!"
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. Create a new item with sendAll

Create a new resource and capture the result.

set $result as notification.sendAll $channels "System alert: disk 90%"
print "Created: " + $result

2. Multi-step Notification workflow

Chain multiple notification operations together.

@desc "Slack, slack rich, and more"
do
  set $r_slack as notification.slack $webhookUrl "Deploy complete!"
  set $r_slackRich as notification.slackRich $url {"title": "Deploy", "text": "v1.2.3 deployed"}
  set $r_discord as notification.discord $webhookUrl "Build passed!"
  print "All operations complete"
enddo

3. Safe slack with validation

Check results before proceeding.

@desc "Slack and validate result"
do
  set $result as notification.slack $webhookUrl "Deploy complete!"
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • slack -- Slack module for complementary functionality
  • discord -- Discord module for complementary functionality
  • teams -- Teams module for complementary functionality
  • telegram -- Telegram module for complementary functionality
  • whatsapp -- WhatsApp module for complementary functionality

Versions (1)

VersionTagPublished
0.1.2latest1 months ago
Install
$ robinpath add @robinpath/notification

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.2
LicenseMIT
Unpacked Size5.5 KB
Versions1
Weekly Downloads26
Total Downloads26
Stars0
Last Publish1 months ago
Created1 months ago