Quick Overview
This workflow runs daily to find inactive users in Supabase, generates personalized re-engagement emails with Anthropic Claude using brand directions stored in an email_guidance table, sends the emails via SMTP, and updates the user record to prevent repeat sends.
How it works
- Runs every day at 9am on a schedule.
- Reads the selected email guidance (three directions and a subject hint) from the Supabase email_guidance table based on the configured mail type.
- Fetches up to 100 users from the Supabase users table who have been inactive longer than the configured number of days and have not been sent a re-engagement email.
- Sends each user’s name and the three guidance directions to Anthropic Claude to generate a JSON response containing an email subject and body.
- Parses Claude’s response, builds an HTML version of the email, and skips any users without an email address.
- Sends the email via SMTP and, on successful delivery, updates the Supabase user record to set reengagement_sent to true and store the reengaged_at timestamp.
Setup
- Add Supabase credentials (host and service_role key) and ensure your database has a users table plus an email_guidance table with fields for mail_type, direction_1, direction_2, direction_3, and subject_hint.
- Add an Anthropic (Claude) API key using HTTP Header Auth with the x-api-key header, and keep the required Anthropic version header as configured.
- Add SMTP credentials for your email provider and set the fromEmail value in the workflow configuration.
- Update the workflow configuration values (inactiveDays, mailType, and model) and confirm your users table includes email, name, last_active_at, reengagement_sent (and optionally reengaged_at) columns.