How easily can you build an Email Sentiment Classifier with Claude Code
What we’re building
This workflow we will be building will enable us to periodically poll our Gmail, classify the sentiment of any of the new emails, and persist the results to a Google Sheets. It covers the foundations of authorizing services, scheduling tasks, and integrating LLMs. Pieces that will allow us to build practical systems in the real world.
What you need to start
- Trigger.dev account: The platform to run our workflow.
- Composio account: owns the Gmail + Sheets OAuth.
- Claude Subscription: This walkthrough will be using Claude Code to build, and Claude API to analyze sentiment.
- Google Sheets: The destination for each matched row.
Notably, there is no frontend, web server, or database anywhere in this project. All task logic lives inside Trigger.dev itself.
Steps to Create the Workflow
Step 1: Set up the repo
The email-sentiment-classifier repo contains all the code for this walkthrough. Ask claude code to set it up:
Please clone https://github.com/kadimula/email-sentiment-classifier.git and install its dependencies
Step 2: Create your resources
- Trigger.dev account: Create an account at https://trigger.dev/, and you will be prompted to create your first Project. Name it whatever you want.
- Composio account: Create an account at https://composio.dev. Composio handles all third-party OAuth logic (securely storing access tokens, refreshing them etc.), so we don’t need to write any of that plumbing or manage token storage ourselves.
- Claude API key: Grab one from https://platform.claude.com/
- Google Sheet: Create the target sheet by hand, and record the URL of the sheet.
Step 3: Fill out your .env file
Add the secrets from all the above steps:
# Trigger.dev
TRIGGER_PROJECT_REF=proj_... # dashboard > Project settings
TRIGGER_SECRET_KEY_DEV=tr_dev_... # dashboard > API keys, the dev key
# Composio
COMPOSIO_API_KEY=... # app.composio.dev > Settings > API Keys
# LLM for the sentiment
ANTHROPIC_API_KEY=... # from console.anthropic.com
ANTHROPIC_MODEL=... # optional, defaults to claude-opus-4-8
# Google Sheet
TARGET_SHEET_ID=... # the 44-char id in the sheet URL
# The sender's email you want to analyze sentiments of
WATCH_SENDER=no-reply@example.com # if you keep it blank, all senders will be processed
Step 4: Start the dev server
Run it on your local machine:
npm run dev
Step 5: Connect to Gmail and Sheets through Composio
Open your coding agent in a second terminal and ask it:
Please provide me the auth urls for both gmail and sheets, for the client example@test.com
The agent calls Composio via the provided scripts, and hands back two consent URLs for the email you provided. Open each one and perform auth.
Step 6: Onboard the client
This starts the actually scheduled workflow, and starts the polling every 2 hours. Ask your agent:
Please onboard the client example@test.com
You’ll likely want the polling to happen at a much quicker cadence to test, so just tell the agent:
Please onboard the client example@test.com, polling every 2 minutes
Step 7: Watch it run
Open the Trigger.dev dashboard and you will see a poll-inbox run fire on the schedule:
it checks the client’s Gmail connection is still active, fetches their 10 most recent emails, keeps the ones from WATCH_SENDER,
classifies each match’s sentiment, and appends one row per match to your sheet. Every run, every retry, and every log line is visible in the dashboard
Final thoughts
The foundational pieces layed out in this post can be used for numerous other business functions:
- Service Authorization: Composio is a terrific platform, which manages OAuth for most business software. So connecting a new service is just having it hand you a new consent URL, vs hand-rolling auth.
- Task Scheduling: : Trigger.dev does heavy lifting for any long-running tasks, and handles scheduling, retries, checkpointing etc.
- LLM Analysis: The workflow of reading data from Service A, analyzing with LLM, and responding in Service B loop can handle all sorts of routine, unstructured work, Ex. cleaning messy data, intelligently routing inquiries, and more.
