Skip to content

By leveraging this guide, you could build a serverless wildlife detecting application integrated with Slack

License

Notifications You must be signed in to change notification settings

earunsundar/serverless-slack-application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless Wildlife Finder

By leveraging this guide, you could build a serverless wildlife detecting application integrated with Slack.

The core functionality is based on AWS and utilizes the following services.

  1. Amazon API Gateway
  2. AWS Lambda
  3. Amazon Rekognition
  4. AWS S3
  5. AWS CloudFormation

Architecture

  1. User uploads a message with the image in the Slack channel
  2. Slack sends the message to an Amazon API Gateway API
  3. The API triggers an invocation of the Lambda function
  4. Amazon Rekognition scans the image and returns a list of detected labels
  5. The list of labels is checked for wildlife tags
  6. Response is posted to the chat channel

Architecture diagram

Steps

Create Slack App

  1. Login to Slack and create an app. Refer the Documentation for assistance
  2. Click Basic Information tab under Settings. Write down the Verification Token
  3. Go to OAuth & Permissions tab under Features
    1. Under Permissions Scopes section add the following permission scopes
      • files:read
      • files:write:user
      • chat:write:bot
      • channels:history
    2. Click Save Changes. Then click Install App to Team and then Authorize
    3. Write down the OAuth Access Token

AWS Backend creation

AWS Cloudformation template is provided to facilitate the deployment. The resources are created in us-west-2 (Oregon). Click Launch Stack into Oregon with CloudFormation button to create the services in your account.

  1. PS: Use this template if the above link doesn't work
  2. Give the AWS Cloudformation permission to create IAM resources and create IAM resources with custom names
  3. Then click on Create Change Set
  4. Finally click Execute

Finalize Slack Event Subscription

  1. Go to the Cloudformation stack created to note down the RequestURL under the output section
  2. Return to Slack App settings page
    1. Navigate to Event Subscriptions tab under Features and enable events
    2. Navigate to Request URL field and enter the RequestURL value
    3. Click on Add Team Event and select message.channels. Click Save Changes

Testing the Example

Now go to the Slack app and go to #random channel. Upload an image and you would find your app identifying animals in it.

Drawing

Drawing

Drawing

Drawing

Drawing

Cleaning Up

To remove all resources created by this example, do the following:

  1. Delete the CloudFormation stack.
  2. Delete the CloudWatch log groups associated with each Lambda function created by the CloudFormation stack.

Services

CloudFormation Stack

  • A Stack named WildlifeFinder is first created

AWS Lambda

  1. Function - WildlifeFinder
    • Function to validate slack event messages and check images
  2. Permission - WildlifeFinderFunctionWildlifeFinderAPIPostPermissionTest
    • Allows API Gateway Test stage to call Lambda function
  3. Permission - WildlifeFinderFunctionWildlifeFinderAPIPostPermissionProd
    • Allows API Gateway Prod stage to call Lambda function

AWS IAM

  • LambdaRekognitionRole - IAM Role with policy that allows Lambda function to invoke "rekognition:DetectLabels" API call and write log messages to CloudWatch Logs.

Amazon API Gateway

  1. WildlifeFinderAPI: - API for wildlife finder app
  2. WildlifeFinderAPIProdStage - Implicitly created production stage for API
  3. WildlifeFinderAPIDeploymentXXXXXXXXX - Implicitly created deployment for production stage of API

References

Image Recognition and Processing Serverless reference

About

By leveraging this guide, you could build a serverless wildlife detecting application integrated with Slack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages