npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wisegpt/awscdk-slack-event-bus

v1.1.0

Published

Exposes a Slack Events API Request URL that validates and sends all received events to an AWS Event Bus

Downloads

120

Readme

@wisegpt/awscdk-slack-event-bus

This library was created to fulfill the need of integrating Slack as a Event Source for AWS EventBridge.

Architecture

AWSCDK-Slack-Event-Bus-Architecture

  1. Creates an EventBus to send all Slack events to
  2. Creates or uses an already existing AWS HTTP API Gateway for exposing Slack Events API Request URL
  3. Creates an AWS Lambda and adds it to the AWS HTTP API Gateway to be used as Slack Events API Request URL
    1. Lambda validates the Signature of each received event
    2. Lambda responds to url_verification which is received when Slack App is configured with the Request URL
    3. Lambda sends all received events to the created EventBus
  4. Can be used with a single Slack application or with multiple (by default).

API Reference

See API.md for documentation of the SlackEventBus construct.

Example Usage

import { CfnOutput, Stack, StackProps, SecretValue } from "aws-cdk-lib";
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
import { Construct } from "constructs";
import { SlackEventBus } from "@wisegpt/awscdk-slack-event-bus";

export class MyExampleStack extends Stack {
  constructor(scope: Construct, id: string, props: StackProps = {}) {
    super(scope, id, props);

    const appId = "<<your-slack-app-id>>";
    // !IMPORTANT! you should reference `Secret` more securely, e.g. by using `Secret.fromSecretCompleteArn()`
    const secret = new Secret(this, "WiseGPTSecrets", {
      secretObjectValue: {
        [`app/${appId}/signing-secret`]: SecretValue.unsafePlainText("<<your-slack-signing-secret>>"),
      },
    });

    const slackEventBus = new SlackEventBus(this, "SlackEventBus", { secret });
    
    // ... use slackEventBus.eventBus to create rules to listen for events or do something else

    // Copy the output from the CLI or CloudFormation to enable Slack Events API
    new CfnOutput(this, "SlackEventRequestUrl", {
      value: slackEventBus.slackEventsRequestUrl(appId),
      description: "Slack Events Request Url to use in Slack API Dashboard",
    });
  }
}

Event Mapping Detail

Received events are sent to the EventBus without any modification to their format. Some mapping from Slack Event to EventBridge Events is done to be able to put the event to the EventBus. Details are as follows;

  • All events put to the EventBus have source field as com.slack
  • Only event_callback and app_rate_limited type of events are sent to the EventBus.
  • Extra Information on event_callback type of events:
    • The Time of the EventBus Event is set to the event_time of the Slack Event
    • The DetailType of the EventBus Event is set to EventCallback.{event.type} e.g. for app_mention, DetailType is EventCallback.app_mention
    • The Detail of the EventBus Event is set to the whole Event envelope that Slack has sent. E.g. { type: 'event_callback', event: { type: 'app_mention', ... }, ... } the token field you would normally get from the Slack Event is omitted for security measure.
  • Extra Information on app_rate_limited type of events:
    • The Time of the EventBus Event is set to the minute_rate_limited of the Slack Event
    • The DetailType of the EventBus Event is set to fixed AppRateLimited
    • The Detail of the EventBus Event is set to the whole Event envelope that Slack has sent. E.g. { type: 'app_rate_limited', api_app_id: ..., } again, token is omitted for safety measure.