Using Slack as a Reporting Tool with AWS

Using Slack as a Reporting Tool with AWS

With world around us moving at warp speed, we communicate with each other mostly using messenger applications like Slack, Telegram or Whatsapp since it undeniably runs at par in terms of speed with our lives and the information retrieval and transfer is instant.

No alt text provided for this image
  1. The user sends a request using the slack slash command to the API Gateway URL. After an app is created, slash command is added to its interface for additional interaction capabilities. The steps to add a URL to slack slash command to send the request packet to is covered in this article later
  2. API Gateway sends the request packet towards the AWS Lambda Function and triggers it to process it
  3. AWS Lambda function parses the request packet and converts it from its base64 encoded format (that’s the default format slack sends) into textual format. From the request packet text, the function converts it into a dictionary and check for two conditions — Slack Token and Enterprise Name. If both the conditions are fulfilled, Lambda then processes the request to gather a response. Our data for this implementation resides on S3 and a set of steps are triggered to gather relevant data from S3 and process it using Pandas
  4. Based on the Lambda function, S3 returns the data from its bucket and the Lambda function parses it to easy slack message format
  5. Lambda function returns a response which is passed to the API Gateway. The response is preformatted from step 4 based on a needed messaging template. For example, if you want to send out top 15 salesmen and their statistics to the sales manager, the messaging format template should be created in a slack friendly way to show top 15 salesmen, their rank and total sales for a given week
  6. Finally the API Gateway sends the response back to the slack command and the user sees the response under his/her chat window

K. This Step is an additional step which keeps our lambda function alive. The thing about lambda functions is that whenever they are triggered, AWS collects the needed resources to run them, unless of-course they are reserved for them permanently. The time needed to gather resources cause timeout error on slack as slack expects a response within 3 seconds. To counter that we have this additional step. We created another Lambda function called the Lambda warmer which triggers our lambda function every 12 minutes to prevent it from going cold. This keeps the function alive with the needed sources, without me having to pay to reserve resources for it.

L. This is just the representation of all the logging we do from the lambda function to cloudwatch


要查看或添加评论,请登录

?? Saral Saxena ???????的更多文章

社区洞察

其他会员也浏览了