Quick overview
This workflow turns Telegram voice notes and text messages into a support agent by transcribing audio with Groq Whisper, classifying intent/sentiment/security risk with Groq LLMs, escalating risky cases to a human via Telegram, and logging interactions and errors to Google Sheets with Slack error alerts.
How it works
- Triggers when a new Telegram message is received.
- If the message is a voice note, it downloads the audio from Telegram and transcribes it using Groq Whisper; if it is text, it uses the message text as the transcript, otherwise it replies that the message type is unsupported.
- Sends the transcript to Groq Chat Completions to classify intent, sentiment, and security risk and parses the JSON result.
- Checks Google Sheets for a recent escalation lock for the same chat ID and sends a brief holding reply in Telegram if the conversation was escalated in the last 30 minutes.
- If sentiment is frustrated/angry or a security risk is detected, it records/updates the escalation lock in Google Sheets, notifies a human agent in Telegram, and sends the user a Groq TTS voice acknowledgement.
- If not escalated, it routes by intent and generates a tailored Groq LLM response, sends the reply back to the user in Telegram, and appends the interaction details to Google Sheets.
- On any Groq or Telegram file-processing error, it posts an alert to Slack, logs the failure to a Google Sheets Errors tab, and sends a fallback message to the user in Telegram.
Setup
- Create and connect Telegram bot credentials for the customer-facing bot (receiving messages and replying) and a second Telegram bot/credential for sending internal escalation notifications.
- Add a Groq API credential for the HTTP requests used for Whisper transcription, chat completions, and text-to-speech.
- Connect Google Sheets OAuth2 and create a spreadsheet with sheets/tabs for Interactions, Errors, and Escalations (including columns like chatId and escalatedAt).
- Connect Slack OAuth2 and select the channel that should receive error alerts.