{
  "$meta": {
    "package": "@walkeros/server-destination-slack",
    "version": "4.3.1",
    "type": "destination",
    "platform": [
      "server"
    ],
    "docs": "https://www.walkeros.io/docs/destinations/server/slack",
    "source": "https://github.com/elbwalker/walkerOS/tree/main/packages/server/destinations/slack/src"
  },
  "schemas": {
    "mapping": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "channel": {
          "type": "string",
          "description": "Override the destination channel for this rule. Web API mode only -- ignored in webhook mode."
        },
        "text": {
          "type": "string",
          "description": "Override the text template for this rule. Supports `${data.field}` interpolation."
        },
        "blocks": {
          "type": "array",
          "items": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          },
          "description": "Override Block Kit blocks for this rule."
        },
        "threadTs": {
          "type": "string",
          "description": "thread_ts for posting as a reply in a thread."
        },
        "replyBroadcast": {
          "type": "boolean",
          "description": "Also broadcast the threaded reply back to the channel."
        },
        "ephemeral": {
          "type": "boolean",
          "description": "Send via chat.postEphemeral. Requires `user`."
        },
        "user": {
          "type": "string",
          "description": "Slack user ID for ephemeral or DM delivery."
        },
        "dm": {
          "type": "boolean",
          "description": "Send as DM via conversations.open + chat.postMessage. Requires `user`."
        }
      },
      "additionalProperties": false
    },
    "settings": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "token": {
          "type": "string",
          "pattern": "^xoxb-.*",
          "description": "Slack Bot token (xoxb-...). Enables Web API mode. Mutually exclusive with webhookUrl."
        },
        "webhookUrl": {
          "type": "string",
          "format": "uri",
          "description": "Incoming Webhook URL. Enables webhook mode. Mutually exclusive with token."
        },
        "channel": {
          "type": "string",
          "description": "Default Slack channel ID or name (e.g. \"#alerts\" or \"C024BE91L\"). Required for Web API mode unless every rule supplies one. Ignored in webhook mode."
        },
        "text": {
          "type": "string",
          "description": "Default text template. Supports `${data.field}` interpolation against the walkerOS event."
        },
        "blocks": {
          "type": "array",
          "items": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          },
          "description": "Default Block Kit blocks applied when no mapping override is set."
        },
        "includeHeader": {
          "type": "boolean",
          "description": "Auto-add an event-name header block when generating default blocks. Default: true."
        },
        "unfurlLinks": {
          "type": "boolean",
          "description": "Enable link unfurling. Default: false (cleaner for automated alerts)."
        },
        "unfurlMedia": {
          "type": "boolean",
          "description": "Enable media unfurling. Default: false."
        },
        "mrkdwn": {
          "type": "boolean",
          "description": "Use mrkdwn formatting in text. Default: true."
        },
        "threadTs": {
          "type": "string",
          "description": "Static thread_ts for replies (rarely set at destination level)."
        },
        "retryConfig": {
          "type": "string",
          "enum": [
            "default",
            "fiveRetriesInFiveMinutes",
            "none"
          ],
          "description": "Retry policy passed to WebClient. Default: \"default\"."
        }
      },
      "additionalProperties": false
    }
  },
  "examples": {
    "env": {
      "push": {
        "slackClient": {
          "chat": {
            "postMessage": {
              "$code": "()=>Promise.resolve(m)"
            },
            "postEphemeral": {
              "$code": "()=>Promise.resolve(u)"
            }
          },
          "conversations": {
            "open": {
              "$code": "()=>Promise.resolve(h)"
            }
          }
        },
        "sendServer": {
          "$code": "()=>Promise.resolve({ok:!0})"
        }
      },
      "simulation": [
        "call:slackClient.chat.postMessage",
        "call:slackClient.chat.postEphemeral",
        "call:slackClient.conversations.open",
        "call:sendServer"
      ]
    },
    "step": {
      "defaultBlocks": {
        "title": "Default blocks",
        "description": "With no custom text the destination auto-generates a Block Kit message from event data and source.",
        "in": {
          "name": "lead submit",
          "data": {
            "name": "Acme",
            "email": "sales@acme.test"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "8a8e71bd7fa52637",
          "trigger": "test",
          "entity": "lead",
          "action": "submit",
          "timestamp": 1700000600,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "crm",
            "platform": "server"
          }
        },
        "mapping": {
          "settings": {
            "channel": "#growth"
          }
        },
        "out": [
          [
            "slackClient.chat.postMessage",
            {
              "channel": "#growth",
              "text": "lead submit",
              "blocks": [
                {
                  "type": "header",
                  "text": {
                    "type": "plain_text",
                    "text": "lead submit"
                  }
                },
                {
                  "type": "section",
                  "fields": [
                    {
                      "type": "mrkdwn",
                      "text": "*name:*\nAcme"
                    },
                    {
                      "type": "mrkdwn",
                      "text": "*email:*\nsales@acme.test"
                    }
                  ]
                },
                {
                  "type": "context",
                  "elements": [
                    {
                      "type": "mrkdwn",
                      "text": "Source: crm"
                    }
                  ]
                }
              ],
              "unfurl_links": false,
              "unfurl_media": false,
              "mrkdwn": true
            }
          ]
        ]
      },
      "deployNotification": {
        "title": "Webhook deploy",
        "description": "Without a token the destination posts to an incoming Slack webhook URL with the rendered message body.",
        "in": {
          "name": "deploy complete",
          "data": {
            "version": "1.4.2",
            "environment": "prod"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "6494359b88a7cc0d",
          "trigger": "test",
          "entity": "deploy",
          "action": "complete",
          "timestamp": 1700000700,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "settings": {
          "webhookUrl": "https://hooks.slack.com/services/T00/B00/xxx"
        },
        "mapping": {
          "settings": {
            "text": ":rocket: Deployment complete: ${data.version} to ${data.environment}"
          }
        },
        "out": [
          [
            "sendServer",
            "https://hooks.slack.com/services/T00/B00/xxx",
            "{\"text\":\":rocket: Deployment complete: 1.4.2 to prod\",\"unfurl_links\":false,\"unfurl_media\":false,\"mrkdwn\":true}"
          ]
        ]
      },
      "ephemeralMessage": {
        "title": "Ephemeral message",
        "description": "A quota warning posts an ephemeral Slack message visible only to a target admin user.",
        "in": {
          "name": "quota warning",
          "data": {
            "remaining": 5
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "5b457a3ef875592e",
          "trigger": "test",
          "entity": "quota",
          "action": "warning",
          "timestamp": 1700000500,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "settings": {
            "channel": "#admin",
            "ephemeral": true,
            "user": "U-ADMIN-1",
            "text": "Heads up: ${data.remaining} requests remaining"
          }
        },
        "out": [
          [
            "slackClient.chat.postEphemeral",
            {
              "channel": "#admin",
              "text": "Heads up: 5 requests remaining",
              "unfurl_links": false,
              "unfurl_media": false,
              "mrkdwn": true,
              "user": "U-ADMIN-1"
            }
          ]
        ]
      },
      "errorAlert": {
        "title": "Error alert",
        "description": "An error event posts a critical alert to an engineering channel using a mapping-level channel override.",
        "in": {
          "name": "error occur",
          "data": {
            "message": "Payment gateway timeout",
            "code": "PGW_TIMEOUT",
            "severity": "critical"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "5c14645ac42e4b66",
          "trigger": "test",
          "entity": "error",
          "action": "occur",
          "timestamp": 1700000200,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "settings": {
            "channel": "#engineering-alerts",
            "text": ":rotating_light: Error: ${data.message}"
          }
        },
        "out": [
          [
            "slackClient.chat.postMessage",
            {
              "channel": "#engineering-alerts",
              "text": ":rotating_light: Error: Payment gateway timeout",
              "unfurl_links": false,
              "unfurl_media": false,
              "mrkdwn": true
            }
          ]
        ]
      },
      "purchaseAlert": {
        "title": "Purchase alert",
        "description": "A completed order posts a templated message to a sales channel via the Slack Web API.",
        "in": {
          "name": "order complete",
          "data": {
            "id": "ORD-500",
            "total": 299.99,
            "currency": "EUR",
            "product": "Pro Plan"
          },
          "context": {
            "shopping": [
              "complete",
              0
            ]
          },
          "globals": {
            "pagegroup": "shop"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "buyer-42"
          },
          "nested": [
            {
              "entity": "product",
              "data": {
                "id": "ers",
                "name": "Everyday Ruck Snack",
                "color": "black",
                "size": "l",
                "price": 420
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "product",
              "data": {
                "id": "cc",
                "name": "Cool Cap",
                "size": "one size",
                "price": 42
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "gift",
              "data": {
                "name": "Surprise"
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "5656c1790c5f2e46",
          "trigger": "load",
          "entity": "order",
          "action": "complete",
          "timestamp": 1700000100,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "settings": {
            "channel": "#sales",
            "text": ":moneybag: New order: ${data.id} - ${data.total} ${data.currency}"
          }
        },
        "out": [
          [
            "slackClient.chat.postMessage",
            {
              "channel": "#sales",
              "text": ":moneybag: New order: ORD-500 - 299.99 EUR",
              "unfurl_links": false,
              "unfurl_media": false,
              "mrkdwn": true
            }
          ]
        ]
      },
      "threadedCheckoutStep": {
        "title": "Threaded reply",
        "description": "A checkout step posts as a threaded reply in Slack via thread_ts with broadcast to the channel.",
        "in": {
          "name": "checkout step",
          "data": {
            "step": "payment",
            "sessionTs": "1700000000.000050"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "48b11098b08c66f4",
          "trigger": "test",
          "entity": "checkout",
          "action": "step",
          "timestamp": 1700000400,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "settings": {
            "channel": "#sales",
            "text": "Checkout step: ${data.step}",
            "threadTs": "1700000000.000050",
            "replyBroadcast": true
          }
        },
        "out": [
          [
            "slackClient.chat.postMessage",
            {
              "channel": "#sales",
              "text": "Checkout step: payment",
              "unfurl_links": false,
              "unfurl_media": false,
              "mrkdwn": true,
              "thread_ts": "1700000000.000050",
              "reply_broadcast": true
            }
          ]
        ]
      },
      "welcomeDM": {
        "title": "Welcome DM",
        "description": "A user signup opens a Slack DM channel and posts a welcome message with the selected plan.",
        "in": {
          "name": "user signup",
          "data": {
            "plan": "enterprise"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "U-NEW-USER"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "e5b73e96787c2a05",
          "trigger": "test",
          "entity": "user",
          "action": "signup",
          "timestamp": 1700000300,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "collector",
            "schema": "4"
          }
        },
        "mapping": {
          "settings": {
            "dm": true,
            "user": "U-NEW-USER",
            "text": ":wave: Welcome aboard! You signed up for the ${data.plan} plan."
          }
        },
        "out": [
          [
            "slackClient.conversations.open",
            {
              "users": "U-NEW-USER"
            }
          ],
          [
            "slackClient.chat.postMessage",
            {
              "channel": "D-MOCK-DM",
              "text": ":wave: Welcome aboard! You signed up for the enterprise plan.",
              "unfurl_links": false,
              "unfurl_media": false,
              "mrkdwn": true
            }
          ]
        ]
      }
    }
  }
}