Quick Overview
This workflow uses Google Sheets, OpenAI, Telegram, and Slack to send post-therapy check-in messages, analyze patient replies for sentiment and risk, alert therapists to at-risk responses, and log non-urgent replies for ongoing wellness tracking.
How it works
- Runs every hour on a schedule trigger.
- Reads session records from Google Sheets and keeps only sessions that have a session date and have not been marked as check-in sent.
- Uses OpenAI (gpt-4o-mini) to generate a personalized, non-clinical Telegram check-in message from the patient’s session details.
- Sends the check-in to the patient via Telegram and updates the Google Sheets session row to store the message and mark the check-in as sent.
- Triggers on incoming Telegram messages, looks up the patient in a Google Sheets master list by Telegram ID, and selects the most relevant recent session to provide context.
- Sends the patient reply and session context to OpenAI for JSON-formatted sentiment classification and parses the result into structured fields.
- If the sentiment is classified as at-risk, posts an urgent alert to a Slack channel; otherwise, appends the reply and sentiment details to a Google Sheets wellness log.
Setup
- Connect Google Sheets OAuth credentials and update the spreadsheet document ID and sheet names for Sessions, Patients_Master, and Wellness_Log.
- Create and connect a Telegram bot credential, set up the Telegram trigger webhook, and ensure patient Telegram chat IDs are stored in Google Sheets.
- Add an OpenAI API key credential and confirm the selected model (gpt-4o-mini) meets your requirements.
- Connect Slack OAuth credentials and replace the placeholder Slack channel ID used for therapist alerts, and confirm the error-alert channel is set correctly.
- Verify your Google Sheets columns match the workflow’s expected fields (for example session_id, checkin_sent, checkin_message_sent, therapist_slack_id) before activating.