# Keep two apps in sync, set up from your AI assistant

Source: https://clickruntime.com/use-cases/sync-data-between-apps

> Describe what should be copied where. Your assistant builds an automation that checks for changed records on a schedule, updates the other app, and remembers where it stopped.

## Can ChatGPT or Claude keep two apps in sync on a schedule?

An assistant can copy records once while you watch. Keeping two apps in sync means checking again and again and remembering what was already copied. With ClickRuntime, the assistant sets up an automation that runs on a schedule, fetches only records changed since its last run (a cursor kept in state), and creates or updates them in the other app.

### Why the assistant can't do this on its own

- Sync is ongoing. It has to run at 3 a.m. and on weekends, not only when you ask.
- Copying only changes needs a cursor: the time of the last sync, kept between runs. A chat starts fresh each time.
- Both apps' keys have to be stored somewhere safe. ClickRuntime keeps them in the ClickRuntime dashboard, not in chat.

## Set it up from your AI assistant

Prompt to copy:

> Create a ClickRuntime automation: every 30 minutes, find records in my Airtable Customers table that changed since the last run, and create or update the HubSpot contact with the same email, copying name, company and plan.

1. **Connect ClickRuntime to your assistant.** Add ClickRuntime as a connector (MCP server) in ChatGPT, Claude, Cursor or another MCP client, using https://clickruntime.com/api/mcp. You sign in with Google or email; there is no API key to copy. This is done once per assistant.
2. **Paste the prompt.** Start a new chat and paste: “Create a ClickRuntime automation: every 30 minutes, find records in my Airtable Customers table that changed since the last run, and create or update the HubSpot contact with the same email, copying name, company and plan.” Change the details (times, channels, addresses) to yours.
3. **Read the draft.** The assistant restates what will happen, asks for anything missing, such as your timezone or which channel to post to, and saves a draft automation. A draft never runs on its own, so nothing happens until you agree.
4. **Connect accounts and save keys.** The assistant asks you to save an Airtable personal access token (read on that base) as AIRTABLE_TOKEN and a HubSpot private app token as HUBSPOT_TOKEN in the ClickRuntime dashboard. It can run a one-time discovery script to read the table's field names.
5. **Test it.** The assistant runs a first sync limited to five records, shows what it created or updated in HubSpot, then runs the full sync and turns the schedule on.
6. **Turn it on.** The assistant tells you what will run, when, and which services it will contact, then asks your permission to turn it on. From then on it runs on ClickRuntime's servers, and you can close the chat.
7. **Check it in the ClickRuntime dashboard.** Each run shows how many records changed and were synced. Runs with no changes are quick and aren't counted toward your monthly runs. State shows the cursor (the last sync time). Clearing state makes the next run resync everything.

Connector setup for each assistant: https://clickruntime.com/assistants

## What the assistant writes

`airtable_to_hubspot.py`

```python
from datetime import datetime, timezone
from clickruntime import on_trigger, report_fetched, credentials, http, state, log

BASE, TABLE = "appXXXXXXXXXXXXXX", "Customers"
HS = "https://api.hubapi.com/crm/v3/objects/contacts"

@on_trigger
def run(event):
    since = state.get("cursor") or "1970-01-01T00:00:00.000Z"
    started = datetime.now(timezone.utc).isoformat()
    at = {"Authorization": "Bearer " + credentials.secret("AIRTABLE_TOKEN")}
    records, offset = [], None
    while True:
        params = {"filterByFormula": f"IS_AFTER(LAST_MODIFIED_TIME(), '{since}')", "pageSize": 100}
        if offset:
            params["offset"] = offset
        page = http.get(f"https://api.airtable.com/v0/{BASE}/{TABLE}", headers=at, params=params).json()
        records += page["records"]
        offset = page.get("offset")
        if not offset:
            break
    report_fetched(len(records))
    if not records:
        return {"summary": "Nothing changed"}

    hs = {"Authorization": "Bearer " + credentials.secret("HUBSPOT_TOKEN")}
    synced = 0
    for rec in records:
        f = rec["fields"]
        email = (f.get("Email") or "").lower()
        if not email:
            continue
        props = {"email": email, "firstname": f.get("First name", ""), "lastname": f.get("Last name", ""),
                 "company": f.get("Company", ""), "plan": f.get("Plan", "")}
        r = http.patch(f"{HS}/{email}", params={"idProperty": "email"}, headers=hs, json={"properties": props})
        if r.status_code == 404:
            r = http.post(HS, headers=hs, json={"properties": props})
        r.raise_for_status()
        synced += 1

    state.set("cursor", started)
    log.info("Synced", {"count": synced})
    return {"synced": synced}
```

- The cursor is saved only after every record succeeded, so a failed run retries the same changes next time.
- HubSpot contacts are updated by email (idProperty=email) and created when they don't exist yet.
- `plan` must exist as a contact property in HubSpot; the assistant checks with a discovery script first.
- The same pattern works for Notion → Google Sheets, Sheets → Airtable or any two apps with APIs.

## Trigger link and schedule

Use a schedule when the source app has no webhooks, or when a short delay is fine. Every 30 minutes is common; every 5 minutes is the shortest.

Use a trigger link when the source can call a webhook on change (Airtable automations, HubSpot workflows): each change syncs within seconds. Many setups use both, with the schedule as a safety net.

## Limits

- Runs have a time limit, so a first sync of many thousands of records is split across runs with the cursor.
- Each app's own API rate limits apply; the http client retries rate-limited GET requests.
- Two-way sync needs a rule for conflicts (which side wins). Tell your assistant which one.

## Troubleshooting

### Some records never sync.

They have no email or a field name differs. Ask your assistant to list skipped records from the last run's log.

### HubSpot returns 400 property doesn't exist.

Create the property in HubSpot or ask the assistant to map it to an existing one.

### I want to resync everything.

Clear the automation's state in the ClickRuntime dashboard. The next run starts from the beginning.

## Related

- [Airtable automations](https://clickruntime.com/apps/airtable)
- [HubSpot automations](https://clickruntime.com/apps/hubspot)
- [Notion automations](https://clickruntime.com/apps/notion)
- [Google Sheets automations](https://clickruntime.com/apps/google-sheets)
- [Salesforce automations](https://clickruntime.com/apps/salesforce)
- [recurring-tasks-in-airtable](https://clickruntime.com/templates/recurring-tasks-in-airtable)
- [stripe-payments-to-sheets](https://clickruntime.com/templates/stripe-payments-to-sheets)
- [Stateful automations](https://clickruntime.com/use-cases/stateful-automations)
- [Cron jobs without a server](https://clickruntime.com/use-cases/cron-jobs-without-a-server)
- [Form leads to your CRM](https://clickruntime.com/use-cases/form-leads-to-crm)
- [Make alternative](https://clickruntime.com/alternatives/make)
- [Zapier alternative](https://clickruntime.com/alternatives/zapier)
- [Activepieces alternative](https://clickruntime.com/alternatives/activepieces)
- [Docs: state](https://clickruntime.com/docs/state)
- [Docs: connections-and-secrets](https://clickruntime.com/docs/connections-and-secrets)

## Extend it: what you can add next

The first version is rarely the last. Because the automation is a Python script with memory, AI and any API available, you grow it by asking your assistant for the change. Each change is a new version, and a failed deploy never replaces the working one.

- **Make it two-way, with the newest change winning** (Multi-step logic)
  Prompt: "Change my Airtable to HubSpot sync so changes in HubSpot also flow back to Airtable, and the most recently modified side wins."
- **Sync within seconds when Airtable calls a trigger link** (Trigger links)
  Prompt: "Add a trigger link to my Airtable to HubSpot sync that syncs one record right away when an Airtable automation calls it, keeping the schedule as a safety net."
- **Fill in industry from the company description with AI** (Built-in AI)
  Prompt: "Change my Airtable to HubSpot sync so it sets the HubSpot industry field from the Airtable company description when it's empty."
- **Email a daily count of records synced and skipped** (Memory between runs)
  Prompt: "Add to my Airtable to HubSpot sync: keep a daily count of synced and skipped records and email me the totals at 18:00."
- **Also copy the records to a Google Sheet for reporting** (Any app or API)
  Prompt: "Add to my Airtable to HubSpot sync: also write each synced record to my Customers report sheet, one row per customer."
- **Validate before syncing and flag bad rows back in Airtable** (Multi-step logic)
  Prompt: "Change my Airtable to HubSpot sync so records with an invalid email are not synced, and their Sync status field in Airtable says why."
- **Post a Slack note when a customer changes plan** (Any app or API)
  Prompt: "Add to my Airtable to HubSpot sync: when a record's Plan changes, post the customer and old and new plan to #customers in Slack."

## Questions

### Can ChatGPT sync Airtable and HubSpot?

With ClickRuntime connected, yes. ChatGPT sets up a scheduled automation that copies changed records between them, keeping a cursor so only changes are copied.

### How often can it sync?

Every 5 minutes at the shortest. For changes within seconds, add a trigger link the source app calls.

### Does each record cost a run?

No. One run handles every changed record it finds. Runs with no changes that finish quickly aren't counted.

### Which apps can it sync?

Any two apps with APIs, such as Notion, Google Sheets, Airtable, HubSpot, Salesforce or your own database's HTTPS API.

### What if a run fails halfway?

The cursor only moves after a successful run, so the next run picks up the same changes. Updates by email are safe to repeat.
