Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chriszarate/slack-events-sns-lambda
Provides a connector between the Slack Events API and AWS SNS, powered by AWS Lambda
https://github.com/chriszarate/slack-events-sns-lambda
aws-lambda aws-sns slack slack-api slack-bot slack-events-api
Last synced: 20 days ago
JSON representation
Provides a connector between the Slack Events API and AWS SNS, powered by AWS Lambda
- Host: GitHub
- URL: https://github.com/chriszarate/slack-events-sns-lambda
- Owner: chriszarate
- Created: 2017-04-22T15:29:10.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-23T20:45:33.000Z (over 7 years ago)
- Last Synced: 2024-10-09T05:07:47.695Z (about 1 month ago)
- Topics: aws-lambda, aws-sns, slack, slack-api, slack-bot, slack-events-api
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Slack Events to SNS via AWS Lambda
This repo provides a [Slack Events API][events-api] endpoint on AWS API Gateway
and Lambda to process Slack events. It handles the endpoint verification and
then publishes the events to SNS.## Configuration
Populate `.env` in the root of the repo:
```
AWS_SNS_TOPIC_ARN_PREFIX=arn:aws:sns:us-east-1:11111111:slack-events-
SLACK_APP_VERIFICATION_TOKEN=token
SLACK_MACHINE_USER_NAME=mybot
```## Creating and updating the endpoint
```
claudia create --name my-slack-endpoint --region us-east-1 --api-module index
```[Claudia][claudia] will print out the endpoint base URL. Append `/messages` to
the end and provide it to Slack in the "Event Subscriptions" section of your app
configuration.Update the endpoint with:
```
claudia update
```## Enabling commands
This endpoint expects to receive messages in a specific format (where `bot-name`
is configured as `SLACK_MACHINE_USER_NAME` in `.env`):```
bot-name verb command
```or
```
@bot-name verb command
```Any messages not matching that format will be ignored.
Add your verb to the `supportedBotVerbs` array in `src/process-message` and
create a corresponding SNS topic. If your `AWS_SNS_TOPIC_ARN_PREFIX` is
`arn:aws:sns:us-east-1:11111111:slack-events-` and your verb is `ping`, then the
ARN of the SNS topic you create should be:```
arn:aws:sns:us-east-1:11111111:slack-events-ping
```Some additional information related to the parsed command will be added to the
event, and the result is published to the SNS topic.## That's it?
That's it. But now you can write any number of Lambda functions or other code
that subscribes to those SNS topics.[events-api]: https://api.slack.com/events-api
[challenge]: https://api.slack.com/events/url_verification
[app-config]: https://api.slack.com/slack-apps
[claudia]: https://claudiajs.com