DEV Community

AndySqlman
AndySqlman

Posted on

Automatically execute report tasks and send results to the sender upon receiving a Slack message

Reposted from https://www.sqlmessenger.com/docreader.html?id=594

1. Overview

SQLMessenger has provided the ability to receive Slack messages starting from version 2.3.0001. You can use SQLMessenger to receive Slack messages and process them automatically.

This document demonstrates, through a practical example, how to receive Slack messages, query data based on the message content, and return the query results (as an Excel file) to the sender.

2. Case Background

Alex works as a data administrator at a company. His colleagues frequently send him Excel files through Slack. Each file contains some product codes. Alex needs to look up the prices and other related information of these products in the database, and then reply to his colleagues with the results.

The Excel file Alex received from a colleague


The Excel file Alex received from a colleague

After receiving a file, Alex must import the data into the database, run SQL queries to retrieve information for each product, and export the query results into an Excel spreadsheet.

Alex imports the Excel spreadsheet into the database and queries the product data


Alex imports the Excel spreadsheet into the database and queries the product data

3. Automation with SQLMessenger

Alex has now automated this entire workflow using SQLMessenger. His configuration includes the following steps:

Step 1: Configure a report task in SQLMessenger that imports the Excel file into the database, queries product data, converts the results into an Excel file, and sends the result back to the original sender.

*As Alex was just getting started with SQLMessenger, he was unfamiliar with configuring tasks. After a detailed discussion of his requirements, the SQLMessenger team set up a reporting task for him to handle incoming Excel files and query product data.

The report task the SQLMessenger team configured for Alex


The report task the SQLMessenger team configured for Alex

Step 2: Configure two Slack bots in SQLMessenger—one for receiving Slack messages from colleagues, and another for sending the query results back through Slack.

Configure two Slack bots in SQLMessenger


Configure two Slack bots in SQLMessenger

4. Testing the Workflow

After completing the configuration, we sent a file from Slack to test the system.

Send a file from Slack to the Slack App configured in SQLMessenger


Send a file from Slack to the Slack App configured in SQLMessenger

SQLMessenger automatically processes the file, performs the query, and replies to the sender with the results.

SQLMessenger automatically converts the query results into an Excel file


SQLMessenger automatically converts the query results into an Excel file

SQLMessenger sends the file to the sender


SQLMessenger sends the file to the sender

In addition to this scenario, SQLMessenger can execute different tasks based on the sender’s account and the content of the message, providing highly flexible message-driven automation.

Top comments (0)