Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slack plugin for sending messages to webhooks #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Brayden
Copy link
Member

@Brayden Brayden commented Feb 4, 2025

Purpose

Plugin that sends a Slack message based on a defined Slack webhook and supports sending advanced message formatting (https://api.slack.com/messaging/webhooks#advanced_message_formatting). Very simple implementation that helps with communicating changes, issues, and more directly from a Starbase instance.

Tasks

  • Include Slack webhook plugin
  • Add example usage

Verify

const slackPlugin = new SlackPlugin({
    webhookUrl: 'https://hooks.slack.com/services/SCRIBBLESCRIBBLESCRIBBLE',
})
const cdcPlugin = new ChangeDataCapturePlugin({
    stub,
    broadcastAllEvents: true,
    events: [],
})

cdcPlugin.onEvent(({ action, schema, table, data }) => {
    ctx.waitUntil(
        slackPlugin.sendMessage({
            blocks: [
                {
                    type: 'section',
                    text: {
                        type: 'mrkdwn',
                        text: `${action} detected on ${table}`,
                    },
                },
                {
                    type: 'section',
                    text: {
                        type: 'mrkdwn',
                        text: 'The following data was associated with this action:',
                    },
                },
                {
                    type: 'section',
                    block_id: 'section_1',
                    text: {
                        type: 'mrkdwn',
                        text: '```' + `${JSON.stringify(data)}` + '```',
                    },
                },
            ],
        })
    )
})

Before

After

@Brayden Brayden self-assigned this Feb 4, 2025
@Brayden Brayden added the enhancement New feature or request label Feb 4, 2025
Copy link

github-actions bot commented Feb 4, 2025

Coverage Report

Status Category Percentage Covered / Total
🔴 Lines 2.07% (🎯 75%) 21 / 1010
🔴 Statements 1.98% (🎯 75%) 21 / 1057
🔴 Functions 2.99% (🎯 75%) 5 / 167
🔴 Branches 0% (🎯 75%) 0 / 594
File CoverageNo changed files found.
Generated in workflow #57 for commit 53a3f18 by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant