Creating alarms using aws lambda and slack commands

tanmay
AWS Tip
Published in
2 min readJan 16, 2022

--

Background

In previous article ( link below ) , we looked at how aws lambda can be used to trigger slack notifications

In this article , we will look at how slack commands and aws lambda can be used to create alarms ( records in dynamodb table) . Slack commands will be simple to type to the user and it will also help to avoid using aws console and creating records in dynamodb . Just use slack messenger 😄

Slack application changes

Slack application will provide you manifest under which you can add support for slack commands . Manifest offers a section for slash_commands .

command : specifies how the command would be invoked . In slack commands , first letter is a specified as / to differentiate between a regular a chat message and command

url : Url where the slack command is specified . URL points to api gateway end point , which will finally land onto move_alarms lambda.

usage_hint : This one pops up when typing the command on the slack messenger

usage hint — for alarm creation.

Code changes

code changes are not significant . They mostly cater to parse the slack command for reminder

/alarm create alarm due date on 2022–01–15 for paying electricity charges repeat monthly

I have used regular expression for parsing alarm due date , description . Once all the information is available , we can insert into user_alarms table.

Regarding regular expression

Testing regular expression has become simpler using online tools . I have used matching named groups to extract information from the command line .

regular expression — online testing

Code changes

--

--

Interests : software design ,architecture , search, open banking , machine learning ,mobility