Triggering slack notifications from a retool app

Hi there

I have created a retool app contains a SQL query that is designed to flag any significant changes in our daily website traffic to the previous day. I'm happy with the query - now looking for best approach to trigger a notification to a slack channel when new rows are added to a retool app each day.

Any advice on this is massively appreciated!

Hi @George_Taylor, welcome to the community!

I think you've got 2 options here:

  1. If you already have a workflow that is adding rows to the DB, and you want a Slack notification each time data is added, just add a Slack resource to your account and post the update to your channel whenever you add rows to the DB.
  1. If you want it done only once/day, you could set up a second workflow, and have it run at a scheduled time each day - just query your database for notification that were created in the last 24 hours, or add a field to your DB to flag rows that have been reported - a bool or timestamp, then your query can just grab rows where reported = false, or null each day (and don't forget to then set the flag)

thanks for the response @MikeCB - is there a way to send daily slack notifications - when new data comes in each day - from within the retool app itself or is this best managed using workflows?

Hi @George_Taylor,

Does the data come in from the app? As in, are you using the app to create the data? If so, then you could probably add an email resource (or Retool email) and trigger it whenever you trigger adding data to the DB.
If the data is coming in from something else, then Workflows would be the solution because they are the actions that can be triggered via webhook or scheduled. The app itself doesn't have a scheduling mechanism, it's the UI.

Thanks again for your help @MikeCB.

Data coming from our data warehouse which is set up as Resource in Retool. The app contains a query that also includes a number input variable.

I can replicate the query in a workflow (without the number input variable) and I've connected our Company's Slack as another Resource.

at this stage I wanted to rule out whether this was possible to do through a Retool App but it sounds like Workflows is build for this.

I probably need to spend more time to understand Workflows better - could you recommend any good articles for sending daily slack notifications based on the output of a SQL query?

Hi @George_Taylor,

You're welcome. I'm not sure of any articles for that type of integration, but it should be pretty straightforward if you've already got the components set up. I'd suggest a flow like this:

  1. Start Trigger = Cron Job or Schedule
  2. Resource Query Block. Get the data from your SQL database with your query.
    2.1 The data will be available as blockName.data
  3. Build your payload for the Slack push notification. I'm not sure how you want the data to get pushed, one message per line? A summary? If it's one message / line, you could just connect your blockName.data to a loop block that triggers a Slack action.
    3.1 If you want to summarize it, then I'd use a code block to clean up the data however you need and then a single Slack call to send your message.
1 Like