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.
- User uploads a message with the image in the Slack channel
- Slack sends the message to an Amazon API Gateway API
- The API triggers an invocation of the Lambda function
- Amazon Rekognition scans the image and returns a list of detected labels
- The list of labels is checked for wildlife tags
- Response is posted to the chat channel
- Login to Slack and create an app. Refer the Documentation for assistance
- Click
Basic Information
tab underSettings
. Write down theVerification Token
- Go to
OAuth & Permissions
tab underFeatures
- Under
Permissions Scopes
section add the following permission scopes- files:read
- files:write:user
- chat:write:bot
- channels:history
- Click
Save Changes
. Then clickInstall App to Team
and thenAuthorize
- Write down the
OAuth Access Token
- Under
AWS Cloudformation template is provided to facilitate the deployment. The resources are created in us-west-2 (Oregon). Click button to create the services in your account.
- PS: Use this template if the above link doesn't work
- Give the AWS Cloudformation permission to
create IAM resources
andcreate IAM resources with custom names
- Then click on
Create Change Set
- Finally click
Execute
- Go to the Cloudformation stack created to note down the
RequestURL
under theoutput
section - Return to Slack App settings page
- Navigate to
Event Subscriptions
tab underFeatures
and enable events - Navigate to
Request URL
field and enter theRequestURL
value - Click on
Add Team Event
and selectmessage.channels
. ClickSave Changes
- Navigate to
Now go to the Slack app and go to #random
channel. Upload an image and you would find your app identifying animals in it.
To remove all resources created by this example, do the following:
- Delete the CloudFormation stack.
- Delete the CloudWatch log groups associated with each Lambda function created by the CloudFormation stack.
- A Stack named WildlifeFinder is first created
- Function - WildlifeFinder
- Function to validate slack event messages and check images
- Permission - WildlifeFinderFunctionWildlifeFinderAPIPostPermissionTest
- Allows API Gateway Test stage to call Lambda function
- Permission - WildlifeFinderFunctionWildlifeFinderAPIPostPermissionProd
- Allows API Gateway Prod stage to call Lambda function
- LambdaRekognitionRole - IAM Role with policy that allows Lambda function to invoke "rekognition:DetectLabels" API call and write log messages to CloudWatch Logs.
- WildlifeFinderAPI: - API for wildlife finder app
- WildlifeFinderAPIProdStage - Implicitly created production stage for API
- WildlifeFinderAPIDeploymentXXXXXXXXX - Implicitly created deployment for production stage of API