Useful Pluginsgmail_plugin
DocsUseful Pluginsgmail_plugin

gmail_plugin

Email approval and CRM sync for Gmail operations

What it does

The gmail_plugin provides two features for Gmail-powered agents:

Email Approval (before_each_tool)

Shows a preview and asks for confirmation before sending any email.

CRM Sync (after_each_tool)

After sending, updates contact's last_contact date in the CRM.

Quick Start

main.py
from connectonion import Agent, Gmail from connectonion.useful_plugins import gmail_plugin gmail = Gmail() # Requires OAuth setup: co auth google agent = Agent("email_assistant", tools=[gmail], plugins=[gmail_plugin]) agent.input("Send an email to john@example.com about the meeting tomorrow")
output
┌─ Email to Send ────────────────────────┐
│ To: john@example.com │
│ Subject: Meeting Tomorrow │
│ │
│ Hi John, │
│ │
│ This is a reminder about our meeting │
│ scheduled for tomorrow... │
└────────────────────────────────────────┘
Send this email?
> Yes, send it
> Auto approve emails to 'john@example.com'
> Auto approve all emails this session
 
[Sending...]
CRM updated: john@example.com

Want to customize? Run co copy gmail_plugin to get an editable copy.

Approval Options

For New Emails

Yes, send it

Send this specific email

Auto approve emails to '{recipient}'

Auto-approve all emails to this recipient for this session

Auto approve all emails this session

Skip approval for all emails (use with caution)

For Replies

When replying to threads, you get similar options plus "Auto approve all replies this session".

CRM Integration

After each successful email send, the plugin automatically updates the contact's CRM data:

main.py
@after_each_tool def sync_crm_after_send(agent): trace = agent.current_session['trace'][-1] # Only after successful email sends if trace['tool_name'] not in ('send', 'reply'): return if trace['status'] != 'success': return to = trace['arguments'].get('to', '') if not to: return # Access Gmail instance via agent.tools.gmail gmail = agent.tools.gmail today = datetime.now().strftime('%Y-%m-%d') # Update last_contact date, clear next_contact_date gmail.update_contact(to, last_contact=today, next_contact_date='')

Events Used

EventHandlerPurpose
before_each_toolcheck_email_approvalPreview and approve emails
after_each_toolsync_crm_after_sendUpdate CRM after send

Related

Source

connectonion/useful_plugins/gmail_plugin.py

main.py
# Bundle both handlers as plugin gmail_plugin = [ check_email_approval, sync_crm_after_send, ]

Star us on GitHub

If ConnectOnion saves you time, a ⭐ goes a long way — and earns you a coffee chat with our founder.