Featured image of post ChatOps: Automating daily tasks with Slackbot on AWS Lambda

ChatOps: Automating daily tasks with Slackbot on AWS Lambda

author

Moustafa Atef

Streamlining SRE Workflows with a Slack Bot Using ChatOps

In the fast-paced world of Site Reliability Engineering (SRE), efficiency is everything. Every automated process helps reduce manual work, freeing up time for more strategic initiatives. To streamline tasks like managing access requests, creating repositories, and fetching SSH tunnels information, we implemented a ChatOps-powered Slack bot. This bot integrates seamlessly with AWS Lambda and GitHub to automate routine tasks.

The Foundation: AWS Lambda and Slack Application

Our bot uses AWS Lambda, a serverless platform, to execute its logic whenever a command is issued. This lightweight architecture ensures that the bot scales automatically as usage increases. Additionally, the bot processes user input via Slack, utilizing Lambda to make API calls to services like GitHub for repository automation.

What is ChatOps?

ChatOps is an operational model that integrates task automation directly into chat interfaces like Slack. Instead of manually running scripts, logging into different tools, or waiting for approvals, tasks can be executed via commands issued in a chat environment. This not only makes workflows more efficient but also improves team collaboration by keeping actions transparent and documented in a shared space.

Slack Bot Architecture

Below is the architecture of our bot, illustrating how the ChatOps system operates:

Slack Bot Architecture

  1. Slack Application: Receives user input (commands).
  2. AWS Lambda: Processes the input, executes the logic, and makes external API calls.
  3. GitHub Integration: Automates repository creation and other Git workflows.

Key Features of the Slack Bot

1. /after-hours – Requesting Access After Hours

Accessing non-production environments outside regular working hours often requires manual requests and approval processes. With the /after-hours command, this task is simplified:

1
/after-hours

The bot automates the access request process, providing teams with instant approval for non-production environments during off-hours. No need for long email chains—just issue the command and get instant access.

2. /create-repo – Automated Repository Creation

Instead of asking SRE to create repositories in GitHub, developers can simply use:

1
/create-repo

Once triggered, the bot prompts SRE team channel for approval, once approved, the bot communicates with GitHub’s API to automatically create the repository. It then notifies the developers that the repository creation request has been appoved/rejected. This saves time by removing the need for manual GitHub interactions and ensuring consistency across projects.

3. /ssh-info ${environment} – Fetching SSH Tunnel Information

Connecting to environments requires SSH details, which can be tedious to track manually for developers. Our bot retrieves this information on how to connect to each environment using ssh tunnels for every environment:

1
/ssh-info ${environment}

This command provides SSH tunnel details for specific environments like prod, staging, or dev, allowing quick and easy access to the necessary information.

User Journey: Creating a Repository Using the SRE Slack Bot

The process of creating a repository with the SRE bot is seamless, providing an efficient flow from request submission to approval and notification. Here’s how the user journey unfolds:

Step 1: User Request

The user initiates the repository creation process by invoking the following command:

1
/create-repo

This opens a modal where the user inputs details such as:

  • Repository Name: A custom name for the repository.
  • Description: A brief overview of the purpose of the repository.
  • Select Teams: Teams that will have access to the repository.
  • Select Template: Option to choose a repository template.

Once the required details are filled in, the user submits the request, which is then processed by the bot.

Step 2: SRE Approval

The submitted repository creation request is forwarded to the SRE team for approval. The bot sends a message to a dedicated Slack channel containing:

  • Repository details (name, description, teams, and template).
  • The identity of the user who requested the repository.

The SRE team can then approve or reject the request with a single click:

  • Approve: Moves the process forward and creates the repository.
  • Reject: Stops the repository creation process.

Step 3: Notification

Once the request is approved, the bot sends a confirmation message indicating that the repository has been successfully created. This message includes the repository details and the name of the approver.

This ensures that the entire process is not only quick and automated but also fully documented within Slack for transparency.

User Interaction Flow

Conclusion

This user journey showcases the power of ChatOps in simplifying repository management. By integrating the bot with GitHub, the SRE team can streamline repetitive tasks, saving time and reducing manual intervention.

How ChatOps Saves Time for SRE Teams

By integrating automation directly into Slack using ChatOps principles, our bot significantly reduces manual workflows and speeds up critical tasks. Here’s how:

  1. Automated Access: Requesting access to environments outside business hours is as easy as sending a message in Slack. The process is instant and eliminates the need for human intervention.

  2. Repository Management: Automating repository creation removes the friction involved in logging into GitHub and manually configuring a new repository. With just a command, a fully functional repository is created in seconds.

  3. SSH Info on Demand: Instead of searching through documentation or configurations, team members can fetch SSH tunnel details directly within the Slack workspace.

This centralization of actions reduces context switching and helps SRE teams stay focused on higher-priority tasks, while also maintaining a transparent record of all interactions and actions taken.

Future Directions

While the current bot simplifies several workflows, we’re exploring additional features like automated timed access credentials to cloud consoles and bastion machines and automated databases dumps and restores. These future enhancements will further increase the bot’s utility and provide even more automation for the SRE team.

Conclusion

Automation through ChatOps is transforming how modern SRE teams operate. Our Slack bot—powered by AWS Lambda and integrated with GitHub—automates critical workflows, reduces manual tasks, and improves collaboration within the team. By consolidating these actions within Slack, we ensure that routine operations are fast, transparent, and efficient.

With a simple command, the bot empowers SRE teams to focus on innovation and leave the mundane tasks to automation.

comments powered by Disqus