Quick overview
This workflow handles legal client intake via Telegram, uses OpenAI (gpt-4o-mini) to classify the case and send a matching document checklist, logs cases in Google Sheets, schedules a consultation in Google Calendar, sends Telegram confirmations, and posts Slack alerts for workflow or AI classification errors.
How it works
- Triggers when a client sends a Telegram message to your bot and extracts the chat ID, client name, and message text.
- Sends the message to OpenAI (gpt-4o-mini) to classify the issue as property, family, criminal, or other and parses the JSON into case type, confidence, and a one-line summary.
- Routes the intake to the correct pre-written document checklist and sends the checklist back to the client on Telegram.
- Appends the case details to a Google Sheets “Cases” tab with default tracking fields like fee_status and follow_up_sent.
- Creates a next-day consultation event in Google Calendar and sends Telegram notifications with the booking details to both the lawyer and the client.
- Runs daily at 10:00 to find Google Sheets cases with fee_status = Pending, sends Telegram payment reminders, and updates the sheet to prevent duplicate reminders.
- Runs daily at 15:00 to find Google Sheets cases with follow_up_sent = No, sends Telegram follow-up messages, and marks them as sent in Google Sheets.
- Posts an alert to Slack when the workflow fails, and separately posts an alert when the OpenAI classification step errors.
Setup
- Create and connect credentials for Telegram Bot API, OpenAI, Google Sheets (OAuth2), Google Calendar (OAuth2), and Slack (OAuth2).
- Create a Google Sheets spreadsheet with a “Cases” tab and columns matching the fields used by the workflow (for example: name, chat_id, case_type, summary, status, fee_status, follow_up_sent), then replace YOUR_GOOGLE_SHEET_ID in all Google Sheets nodes.
- Update the Google Calendar target calendar in the consultation event step to your firm’s calendar address.
- Set your Slack channel ID (replace YOUR_SLACK_CHANNEL_ID) for error alerts.
- Verify the Telegram chat routing for the lawyer notification (the workflow currently uses the client chat ID for notifications) and adjust it to your lawyer/admin chat ID as needed.
- Activate the Telegram trigger and both schedule triggers (10:00 fee reminders and 15:00 follow-ups).