Skip to content

Every 10 minutes

Turn enquiry emails into Salesforce leads

Emails you label Leads in Gmail become Salesforce leads with the contact details filled in, and are moved out of the way.

Runs
Every 10 minutes
Apps
Gmail, Salesforce
AI
Yes, uses the built-in AI allowance
Access
gmail.modify; api

Send this to your assistant

Create a ClickRuntime automation: every 10 minutes, read new emails labelled Leads, pull out the sender's name, company, phone and what they need, create a Salesforce lead if there isn't one, and move the email to Leads/Done.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

A lot of business still starts with an email: a forwarded introduction, a reply to a newsletter, a question sent to the sales inbox. Each one has to be read, the details copied into Salesforce, and the email filed. On a busy week, half of them don't make it into the CRM.

With this automation you only label the email. Every ten minutes it reads new labelled messages, pulls out the contact details and what the person needs, creates a Salesforce lead if they're new, and files the email under Leads/Done.

What you get out of it

  • One label instead of ten fields

    Labelling an email, by hand or with a Gmail filter, is all it takes to get the lead into Salesforce.

  • Details pulled from the text

    Name, company and phone are read from the email and its signature, which saves typing.

  • No duplicate leads

    If a lead with that email exists, nothing new is created.

  • A tidy inbox

    Processed emails move to Leads/Done, so the Leads label only ever shows what's waiting.

How it works

What happens, step by step

  1. Every 10 minutes the automation checks Gmail for emails with the Leads label.

  2. AI reads each email and pulls out the sender's name, email, company, phone and what they need.

  3. It checks Salesforce for an existing lead with that email and creates one only if there isn't.

  4. The email is moved from Leads to Leads/Done so it's never processed twice.

Before it runs live

  • Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail
  • Connect Salesforce

What you get

RunsEvery 10 minutes
Turn enquiry emails into Salesforce leadstoday, 9:00Succeeded
Salesforce · LeadsNew lead: Jordan Lee, Northwind Logistics, +44 20 7946 0123 Need: quote for route planning across 12 depots.

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Act only on the items that match your own rules, and skip the rest
  • Change what the AI looks for, or how it writes the result
  • Add another app, for example also send it to Slack
  • Combine it with other Gmail and Salesforce steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
lead_emails_into_salesforce.pyexample
import base64
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, report_fetched, credentials, http, ai

API = "https://yourcompany.my.salesforce.com/services/data/v61.0"
SCHEMA = {"type": "object", "properties": {k: {"type": "string"} for k in
          ["first_name", "last_name", "email", "company", "phone", "need"]}, "required": ["last_name", "email", "company"]}

@on_trigger
def run(event):
    gmail = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).users()
    labels = {l["name"]: l["id"] for l in gmail.labels().list(userId="me").execute()["labels"]}
    msgs = gmail.messages().list(userId="me", labelIds=[labels["Leads"]], maxResults=20).execute().get("messages", [])
    report_fetched(len(msgs))
    if not msgs:
        return {"summary": "No new lead emails"}
    headers, created = {"Authorization": f"Bearer {credentials.connection('salesforce', 'work')}"}, 0
    for m in msgs:
        full = gmail.messages().get(userId="me", id=m["id"], format="full").execute()
        body = next((base64.urlsafe_b64decode(p["body"]["data"]).decode(errors="ignore") for p in full["payload"].get("parts") or [full["payload"]]
                     if p.get("mimeType") == "text/plain" and p["body"].get("data")), full["snippet"])
        d = ai.generate("Pull the sender's contact details and what they need from this enquiry email:\n" + body[:3000], json_schema=SCHEMA, max_output_tokens=200).json
        email = d["email"].replace("'", "")
        if not http.get(f"{API}/query", headers=headers, params={"q": f"SELECT Id FROM Lead WHERE Email = '{email}' LIMIT 1"}).json()["records"]:
            http.post(f"{API}/sobjects/Lead", headers=headers, json={"FirstName": d.get("first_name"), "LastName": d["last_name"], "Email": email,
                      "Company": d["company"] or "Unknown", "Phone": d.get("phone"), "LeadSource": "Email", "Description": d.get("need")}).raise_for_status()
            created += 1
        gmail.messages().modify(userId="me", id=m["id"], body={"removeLabelIds": [labels["Leads"]], "addLabelIds": [labels["Leads/Done"]]}).execute()
    return {"emails": len(msgs), "created": created}

FAQ

Common questions

Do I need to create the labels?
Yes, two labels in Gmail: Leads and a nested label Leads/Done. Create them once before turning the automation on.
Can emails be labelled automatically?
Yes. Set up a Gmail filter, for example on emails sent to your sales address, to apply the Leads label.
What if the email doesn't include a company?
The lead is created with the company set to Unknown, which Salesforce requires, and you can fill it in later.
What permissions does it need?
gmail.modify; api. Nothing else in your accounts is used.
Does it need AI?
Yes. It uses ClickRuntime's built-in AI, so you don't need an OpenAI or Anthropic key. Every plan includes a monthly AI allowance.
How many runs does it use?
One run each time it checks. Checks that find nothing new and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Turn enquiry emails into Salesforce leads” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.