← Back to BlogTutorial

How to Connect OpenClaw to Your CRM (HubSpot, Salesforce, Twenty)

H.··7 min read

Your CRM is only as good as the data in it. And the data is only as good as the humans entering it.

That's the fundamental problem with every CRM ever built. The tool works fine. The humans forget to update it. Deals move forward in real life but sit stale in the pipeline. Follow-ups happen over email but never get logged. Contacts get added to one system but not the other.

An AI agent solves this by watching the actual communication channels where deals happen (email, Slack, calendar) and keeping the CRM updated automatically.

Here's how to wire it up.

What Your Agent Will Do

Once connected to your CRM, the agent handles:

None of this requires you to open the CRM. The CRM stays updated because the agent is always watching.

Option 1: HubSpot

HubSpot is the most common CRM we connect agents to. Their API is well-documented and their free tier is generous enough for most small businesses.

Authentication

HubSpot uses OAuth 2.0. You'll need:

  1. A HubSpot developer account (free)
  2. A private app created in Settings > Integrations > Private Apps
  3. The following scopes: crm.objects.contacts.read, crm.objects.contacts.write, crm.objects.deals.read, crm.objects.deals.write, crm.objects.companies.read

Create the private app, copy the access token, and add it to your OpenClaw config:

openclaw configure --section hubspot

Mapping Email to Contacts

The agent matches incoming emails to CRM contacts by email address. When it processes an email from john@client.com, it searches HubSpot for a contact with that email.

If found: log the interaction, check if there's an associated deal, update the timeline.

If not found: create a new contact with the name and email extracted from the email headers. Flag it in Slack as a new contact so you can enrich it later.

Pipeline Automation

Configure which email patterns trigger pipeline updates:

hubspot:
  pipeline:
    triggers:
      - pattern: "signed agreement"
        action: move_deal_to_stage("Contract Signed")
      - pattern: "let's schedule a call"
        action: move_deal_to_stage("Meeting Scheduled")
      - pattern: "not interested"
        action: move_deal_to_stage("Closed Lost")
        notify: true
      - pattern: "invoice"
        action: move_deal_to_stage("Closed Won")

Be conservative with these triggers. Start with only the most obvious patterns and expand as you verify accuracy. A false "Closed Won" is worse than a manual update.

Option 2: Salesforce

Salesforce is more powerful and more complex. The integration takes longer but handles enterprise-scale needs better.

Authentication

Salesforce uses OAuth 2.0 with a connected app:

  1. Go to Setup > App Manager > New Connected App
  2. Enable OAuth settings
  3. Add callback URL (your agent's OAuth endpoint)
  4. Select scopes: api, refresh_token, offline_access

Salesforce's OAuth flow is more complex than HubSpot's. You'll need to handle the initial authorization code exchange and store both the access token and refresh token.

openclaw configure --section salesforce

The agent handles token refresh automatically, but Salesforce tokens expire more aggressively than most APIs. Expect to debug token issues in the first week.

Working with Salesforce Objects

Salesforce data is structured differently than HubSpot. Instead of simple contacts and deals, you're working with:

Your agent needs to understand this hierarchy. When it logs an email, it needs to decide: is this a Lead or a Contact? If it's a Contact, which Account? If there's an Opportunity, which stage?

Configure the mapping:

salesforce:
  mapping:
    new_email_contact: create_as_lead
    convert_to_contact_when: opportunity_created
    log_emails_as: task
    log_meetings_as: event

SOQL Queries

For complex CRM lookups, the agent can run SOQL (Salesforce Object Query Language) queries:

SELECT Name, StageName, Amount, CloseDate 
FROM Opportunity 
WHERE AccountId = '{account_id}' 
AND StageName != 'Closed Won'
AND StageName != 'Closed Lost'
ORDER BY CloseDate ASC

This lets the agent pull deal context for meeting prep or follow-up prioritization.

Option 3: Twenty CRM

Twenty is the open-source CRM we use internally. If you value data ownership (same reason you're self-hosting your AI agent), Twenty is the natural CRM choice.

Authentication

Twenty uses API keys. Straightforward:

  1. Go to Settings > API Keys in your Twenty instance
  2. Generate a new key with full CRM access
  3. Add it to OpenClaw:
openclaw configure --section twenty

The Advantage of Self-Hosted CRM + Self-Hosted Agent

When both your CRM and your AI agent run on your infrastructure, the data never leaves your network. Email comes in, agent processes it locally, CRM gets updated locally. Zero external API calls for the CRM portion.

This is the setup we recommend for companies with strong privacy requirements. The only external calls are to the LLM provider, and even those can be eliminated with local models.

Twenty's GraphQL API

Twenty uses GraphQL, which gives the agent more flexibility in querying:

query {
  people(filter: { email: { eq: "john@client.com" } }) {
    edges {
      node {
        name { firstName lastName }
        company { name }
        opportunities {
          name
          stage
          amount
        }
      }
    }
  }
}

One query returns the contact, their company, and all associated deals. Clean and efficient.

Best Practices for CRM Automation

Start with logging, not updating. Let the agent log emails and interactions for two weeks before enabling pipeline automation. Verify that it's matching the right contacts and logging accurately.

Don't trust sentiment analysis blindly. An email saying "I'm not sure about the pricing" could mean "convince me" or "I'm leaving." Let the agent flag ambiguous emails for human review instead of auto-updating the pipeline.

Deduplicate contacts aggressively. The agent will encounter the same person emailing from different addresses (personal, work, alias). Build matching rules that check name + domain, not just exact email matches.

Keep a human in the loop for deal stages. Auto-move deals for clear signals (signed contract, explicit rejection). Keep human approval for ambiguous stages (qualified, proposal sent). The cost of a wrong pipeline update is higher than the cost of a manual click.

Log everything. Every CRM action the agent takes should be logged with a timestamp and the reasoning. When your sales manager asks "why did this deal move to Closed Lost?" you need to point at the specific email that triggered it.

The Result

A properly connected CRM agent does two things:

  1. Your CRM data is always current. Not "mostly current" or "current when someone remembers to update it." Actually current. Every email logged. Every stage reflected. Every follow-up tracked.

  2. Your sales team sells instead of typing. The average salesperson spends 28% of their time on CRM data entry. That's more than a full day per week. An AI agent gives that time back.

If you want your CRM connected to an AI agent without the configuration marathon, book a call. We integrate with HubSpot, Salesforce, Twenty, and most other CRMs. $999, one-time, including custom pipeline rules for your sales process.

Related Reading

Get Your AI Agent Running

We handle the entire setup — deploy, configure, and secure OpenClaw so you don't have to.

  • Fully deployed in 48 hours
  • All channels — Slack, Telegram, WhatsApp
  • Security hardened from day one
  • 14-day hypercare included

One-time setup

$999

Complete setup, no recurring fees