DenchClaw + Gmail: Manage Email from Your CRM
Gmail integration for DenchClaw via the gog skill — read emails, log interactions to contacts, compose from the CRM, and query email history with DuckDB.
DenchClaw + Gmail: Manage Email from Your CRM
Most CRMs treat email as an afterthought — you manually log conversations, paste in email content, and hope someone remembers to update the record. DenchClaw connects to Gmail through the gog (Google Workspace) skill, giving you a two-way bridge: read emails from the CRM, log interactions automatically, and compose new messages with contact context pre-loaded.
Here's how to set it up and use it.
Setting Up the gog Skill for Gmail#
The gog skill is DenchClaw's Google Workspace integration layer. It handles Gmail, Calendar, Drive, Contacts, Sheets, and Docs through a single CLI.
Step 1: Install the gog skill#
npx denchclaw skill install gogStep 2: Authenticate with Google#
gog auth loginThis opens a browser window for OAuth. Grant the requested permissions — at minimum, Gmail read/write access. If you plan to use Calendar integration too, grant Calendar access at the same time.
After auth completes, your credentials are stored locally. No token leaves your machine.
Step 3: Verify the connection#
gog gmail list --limit 5You should see your 5 most recent emails. If you get an auth error, re-run gog auth login.
Step 4: Tell DenchClaw about the skill#
"I've set up the gog skill. Start using Gmail for email lookups."
DenchClaw registers the skill and will use it when you ask email-related questions.
Reading Emails From the CRM#
Once the gog skill is active, you can query email through DenchClaw using natural language:
"Show me all emails from Sarah Chen in the last 2 weeks"
"Do I have any unread emails from Acme Corp?"
"What was the last email I sent to john@globex.com?"
Under the hood, DenchClaw calls gog gmail search with the right parameters and formats the results.
You can also trigger email lookups from DuckDB context:
"Show me the latest email for each contact in my active pipeline"
DenchClaw will:
- Query DuckDB for contacts with
status = 'Active' - For each contact, search Gmail for their email address
- Return the most recent thread with each person
This is the kind of query that would take 20 minutes manually and 10 seconds with DenchClaw.
Direct gog commands for email search#
# Find all emails from a specific address
gog gmail search --from john@acme.com --limit 20
# Find emails with a subject keyword
gog gmail search --subject "proposal" --limit 10
# Find unread emails from the past week
gog gmail search --unread --after 7d --limit 50
# Read a specific email thread
gog gmail thread <thread-id>Logging Email Interactions to Contact Entries#
DenchClaw can automatically log email interactions to contact entries in DuckDB. This creates a chronological history on each contact record.
Manual logging#
"Log my email conversation with Sarah Chen about the Q2 proposal to her contact record"
DenchClaw fetches the thread from Gmail, extracts the key details (date, subject, summary, direction), and creates an interaction log entry in DuckDB.
Viewing email history per contact#
-- See all logged email interactions for a contact
SELECT
i.date,
i.direction,
i.subject,
i.summary
FROM v_interactions i
JOIN v_contacts c ON c.id = i.contact_id
WHERE c.name = 'Sarah Chen'
AND i.type = 'email'
ORDER BY i.date DESC;Querying email coverage across your pipeline#
-- Which leads have we never emailed?
SELECT
c.name,
c.company,
c.email,
c.status
FROM v_contacts c
LEFT JOIN v_interactions i ON i.contact_id = c.id AND i.type = 'email'
WHERE c.status IN ('Lead', 'Prospect')
AND i.id IS NULL
ORDER BY c.created_at DESC;-- Last email date per active contact
SELECT
c.name,
c.company,
MAX(i.date) AS last_email_date,
DATEDIFF('day', MAX(i.date), NOW()) AS days_since_contact
FROM v_contacts c
JOIN v_interactions i ON i.contact_id = c.id AND i.type = 'email'
WHERE c.status = 'Active'
GROUP BY c.name, c.company
ORDER BY days_since_contact DESC;Using Action Fields to Open Gmail Compose#
DenchClaw's Action fields let you trigger context-aware actions directly from contact records. For Gmail, the most useful setup is a "Send Email" action that opens Gmail compose with the contact's email pre-filled.
Setting up the Gmail compose action#
Tell DenchClaw:
"Add an Action field called 'Send Email' to the Contacts object that opens Gmail compose for this contact"
DenchClaw creates a field that generates a Gmail compose URL using the contact's email address:
https://mail.google.com/mail/?view=cm&to={contact.email}
When you click "Send Email" in the web UI, or say "Send email to Sarah Chen," DenchClaw opens Gmail with Sarah's address already in the To field.
You can extend this to pre-fill subject lines too:
"When I open the Send Email action for a deal in the Proposal stage,
pre-fill the subject as 'Following up on your proposal'"
Setting Up Email-Based Triggers#
DenchClaw can watch for specific email patterns and update CRM records automatically.
Trigger: inbound email from a new lead#
"When I receive an email from someone not in my CRM,
create a contact entry for them automatically"
DenchClaw sets up a polling task that checks Gmail every 15 minutes for emails from unknown senders. When it finds one, it creates a contact entry with the sender's name and email, sets status to "Lead", and logs the email as the first interaction.
Trigger: email reply detection#
"When a lead replies to any email I sent them,
update their status from 'Contacted' to 'Responded' in DuckDB"
This keeps your pipeline current without manual updates.
Trigger: keyword-based deal stage updates#
"If a contact emails me with the word 'contract' or 'agreement' in the subject,
move them to the 'Contract' stage in my pipeline"
Checking trigger status#
-- See which contacts had inbound emails today
SELECT
c.name,
c.company,
i.subject,
i.date
FROM v_contacts c
JOIN v_interactions i ON i.contact_id = c.id
WHERE i.type = 'email'
AND i.direction = 'inbound'
AND i.date >= CURRENT_DATE
ORDER BY i.date DESC;Querying Email History With DuckDB#
Once email interactions are logged, DuckDB gives you flexible analysis:
Email response rate by company:
SELECT
c.company,
COUNT(*) FILTER (WHERE i.direction = 'outbound') AS sent,
COUNT(*) FILTER (WHERE i.direction = 'inbound') AS replied,
ROUND(
100.0 * COUNT(*) FILTER (WHERE i.direction = 'inbound') /
NULLIF(COUNT(*) FILTER (WHERE i.direction = 'outbound'), 0), 1
) AS reply_rate_pct
FROM v_contacts c
JOIN v_interactions i ON i.contact_id = c.id AND i.type = 'email'
GROUP BY c.company
HAVING COUNT(*) FILTER (WHERE i.direction = 'outbound') > 0
ORDER BY reply_rate_pct DESC;Contacts with recent inbound activity (hot leads):
SELECT
c.name,
c.company,
c.status,
MAX(i.date) AS last_inbound
FROM v_contacts c
JOIN v_interactions i ON i.contact_id = c.id
WHERE i.type = 'email'
AND i.direction = 'inbound'
AND i.date > NOW() - INTERVAL '7 days'
GROUP BY c.name, c.company, c.status
ORDER BY last_inbound DESC;Email volume by week:
SELECT
DATE_TRUNC('week', i.date) AS week,
COUNT(*) FILTER (WHERE i.direction = 'outbound') AS sent,
COUNT(*) FILTER (WHERE i.direction = 'inbound') AS received
FROM v_interactions i
WHERE i.type = 'email'
AND i.date > NOW() - INTERVAL '12 weeks'
GROUP BY 1
ORDER BY 1;Frequently Asked Questions#
Does DenchClaw read all my Gmail, or just CRM-related emails?
DenchClaw only reads emails you explicitly ask it to, or emails matching patterns you've set up in triggers. It doesn't index your entire mailbox by default. You control what gets logged and stored in DuckDB.
Is my email data stored in the cloud?
No. DenchClaw is local-first. Email content that gets logged to DuckDB lives in your local database file. The gog skill authenticates via OAuth and makes API calls from your machine, but data is stored locally.
Can DenchClaw send emails on my behalf?
Yes, with your confirmation. If you say "Send a follow-up email to Sarah Chen about our last conversation," DenchClaw will draft the email and show you the text before sending. It won't send without your approval unless you've explicitly enabled autonomous sending.
What happens if I revoke gog's Google OAuth access?
Email triggers and lookups will stop working until you re-authenticate. Your existing DuckDB data (logged interactions) is unaffected — it stays in your local database.
Can I use this with Google Workspace accounts (not just personal Gmail)?
Yes. The gog skill works with any Google account, including Google Workspace / G Suite accounts. The OAuth flow works the same way; you'll just log in with your work account during gog auth login.
Ready to try DenchClaw? Install in one command: npx denchclaw. Full setup guide →
