Webhook to Slack
Forwards any webhook event to Slack with formatted messages.
http
Source
/**
* Forwards webhook events to a Slack channel with formatting.
*/
secret slack_config {
vars: [SLACK_WEBHOOK_URL]
}
webhook incoming_event {
label: "Incoming Event"
schema: @json {
{
"type": "object",
"required": ["event_type", "data"],
"properties": {
"event_type": { "type": "string" },
"data": { "type": "object" }
}
}
}
}
workflow forward_to_slack {
label: "Forward to Slack"
root {
type: code
label: "Parse event"
code: @ts { return context.nodes.root.input }
outputSchema: @json {
{
"type": "object",
"properties": {
"event_type": { "type": "string" },
"data": { "type": "object" }
}
}
}
}
node format_message {
type: code
label: "Format Slack message"
code: @ts {
const event = context.nodes.root.output
return {
text: "*Event:* " + event.event_type + "\n" + JSON.stringify(event.data, null, 2)
}
}
}
node send_slack {
type: http
label: "Post to Slack"
method: "POST"
url: @ts { return context.secrets.slack_config.SLACK_WEBHOOK_URL }
headers: @ts { return { "Content-Type": "application/json" } }
body: @ts {
return JSON.stringify(context.nodes.format_message.output)
}
secrets: {
slack_config: [SLACK_WEBHOOK_URL]
}
}
flow {
root -> format_message
format_message -> send_slack
}
}
trigger on_event {
webhook:incoming_event -> forward_to_slack
enabled: true
}
Flow
Trigger to workflow
incoming_eventwebhook
forward_to_slack
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.
Workflow nodes
CODE
Code Node
Parse event
CODE
Code Node
Format Slack message
HTTP
HTTP Node
Post to Slack
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.