RStudio Connect scheduled reports with trigger



Hi, I was looking if there was a way that a scheduled RStudio Connect report would be sent out only if specific trigger would happen.
We would want to use this for a simple system monitoring report in which a SQL query is ran against couple of databases. In case some pre-defined errors would be found we would like to send those out to recipients.


Great request! There is not a direct way to conditionally send email today. However, there is a workaround:

  1. Setup Connect to run the report on a schedule but NOT distribute results to anyone.
  2. If the condition for sending a report is met, throw an R error using stop
  3. When a scheduled report throws an R error, Connect will email the collaborator automatically.


Thanks we will try this out!


We solved this a bit differently. As the report generates markdown document, we had problems to incorporate stop into this.
Instead we used if (dim(Issues)[1] == 0){q()} which generates error in case trigger is not met. In this case the report will not be sent out. In case the trigger happens (dim(Issues)[1] > 0) the report will be sent out normally.