Schedule icon
Request icon
Return icon
Switch icon
Log icon
SlackIncomingWebhook icon

Rocket.Chat Livechat Queue Backlog Sentinel

Monitor Rocket.Chat livechat queue backlog and alert Slack when waiting chats cross a warning or critical threshold.

Categories
Infrastructure

An agent going offline or a department getting overwhelmed does not show up anywhere until a customer complains that nobody answered. This blueprint polls Rocket.Chat's own Omnichannel queue endpoint on a schedule, sums the waiting chats across every agent/department pairing, and pages Slack the moment that backlog crosses a warning or critical threshold, or the workspace cannot be reached at all.

How it works

  1. login_to_rocketchat (io.kestra.plugin.core.http.Request) authenticates against POST /api/v1/login with an admin username and password, returning data.authToken and data.userId. allowFailure: true lets the flow continue into classification instead of aborting on a bad login.
  2. list_livechat_queue (io.kestra.plugin.core.http.Request) calls GET /api/v1/livechat/queue?includeOfflineAgents=true with the X-Auth-Token and X-User-Id headers pulled from the login response via jq, returning a queue array where each entry carries a chats count for one agent/department pairing.
  3. classify_queue_backlog (io.kestra.plugin.core.debug.Return) checks whether outputs.list_livechat_queue.body is defined; if not, UNREACHABLE. Otherwise it sums .queue[].chats with jq and compares that total against critical_threshold then warning_threshold, returning CRITICAL, AT_RISK, or HEALTHY.
  4. route_by_backlog (io.kestra.plugin.core.flow.Switch) branches on that string: HEALTHY logs a quiet confirmation, AT_RISK and CRITICAL each page Slack with the threshold crossed, UNREACHABLE pages Slack separately, and defaults logs the raw outcome.
  5. log_audit_status records a status line on every run regardless of branch, so the execution history is a continuous backlog trend.
  6. The errors block pages Slack separately if the flow itself fails outright.
  7. The queue_backlog_schedule trigger polls every 5 minutes with explicit input overrides, shipped disabled: true until you point it at a real Rocket.Chat workspace.

What you get

  • A scheduled, workspace-wide livechat backlog check with zero custom bot or webhook code.
  • A four-way status output (HEALTHY / AT_RISK / CRITICAL / UNREACHABLE) you can chart or gate other flows on.
  • Two independently tunable thresholds so a small team and a large support org can use the same flow.
  • A separate failure channel for the sentinel flow itself, plus a standing audit log line per run.

Who it's for

  • Support and customer success teams running Rocket.Chat Omnichannel who need to know about a growing queue before a customer does.
  • Platform teams operating self-hosted Rocket.Chat who want backlog monitoring without standing up a separate dashboard.

Why orchestrate this with Kestra

A cron job hitting the same endpoint tells you nothing once the script exits. This flow keeps every login, every queue snapshot, and every threshold comparison in the execution history, turns the backlog check into a typed output other flows can depend on, and gives you a Switch branch to grow into real remediation (paging a specific department's lead, opening a ticket, auto-adding an on-call agent) without rewriting the check itself.

Prerequisites

  • A Rocket.Chat workspace reachable at rocketchat_url, with Omnichannel/Livechat enabled, at least one department, and at least one agent configured. The free, self-hosted Community Edition (rocket.chat/docs/installation/docker-containers/) supports this out of the box, so the flow can be fully tested against a local Docker container.
  • An admin (or a user with the view-livechat-queue permission) username and password for authentication.
  • A Slack incoming webhook for the warning, critical, and unreachable alerts.

Secrets

  • ROCKETCHAT_ADMIN_USER: Rocket.Chat username (or email) used to authenticate against /api/v1/login.
  • ROCKETCHAT_ADMIN_PASSWORD: password for that user.
  • SLACK_WEBHOOK_URL: Slack incoming webhook used for the warning alert, the critical alert, the unreachable alert, and the flow-failure alert.
  • OSS note: if your Kestra instance reads secrets from environment variables instead of a secrets backend, set SECRET_ROCKETCHAT_ADMIN_USER, SECRET_ROCKETCHAT_ADMIN_PASSWORD, and SECRET_SLACK_WEBHOOK_URL as base64, for example echo -n "<your-value>" | base64.

Quick start

  1. Add the ROCKETCHAT_ADMIN_USER, ROCKETCHAT_ADMIN_PASSWORD, and SLACK_WEBHOOK_URL secrets.
  2. Set rocketchat_url to your workspace and tune warning_threshold/critical_threshold to the size of your support team.
  3. Open a few test Omnichannel chats so the queue is non-empty, run the flow once, and confirm status reads a sensible value.
  4. Enable queue_backlog_schedule.

How to extend

  • Classify per department instead of a single workspace-wide total, by iterating queue with a Loop task and alerting on the specific department that breached its threshold.
  • Add a follow-up task that calls POST /api/v1/livechat/room.forward to automatically reassign the oldest waiting chat when CRITICAL is reached.
  • Store each snapshot's total in a KV store to build a longer backlog trend than the execution history alone provides.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.