# Sending Lead Data to Zoho CRM

#### ✅ Prerequisites

Make sure you have:

1. A **Zoho CRM account** with API access enabled.
2. A valid **OAuth 2.0 access token** from Zoho (guide below).
3. An **Agent Supply account** with access to build **Chains** (Agent workflows).

***

#### 🧩 Step-by-Step: Send Lead Data to Zoho CRM via Agent Supply

***

**Step 1: Generate Your Zoho CRM API Access Token**

Zoho uses OAuth 2.0. Here’s how to get the token:

1. Go to Zoho API Console.
2. Create a **new client** (select **Server-based Applications**).
3. Set a **redirect URI** (it can be dummy if using the "Self Client").
4. Generate a code using the **"Self Client"** tab.
5. Exchange the code for an access token using this command:

```bash
bashCopiarEditarcurl --request POST \
  --url https://accounts.zoho.com/oauth/v2/token \
  --data 'grant_type=authorization_code&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&redirect_uri=YOUR_REDIRECT_URI&code=YOUR_CODE'
```

Save the `access_token` and `refresh_token` securely.

***

**Step 2: Capture Lead Data in Agent Supply**

1. Go to the **Chain Builder** in Agent Supply.
2. Add steps to collect user data:
   * Name
   * Email
   * Company
   * Phone
3. Store each piece of data in variables (e.g., `{{first_name}}`, `{{email}}`, etc.).

***

**Step 3: Add HTTP Request Node to Your Chain**

1. Insert an **HTTP request** node after capturing lead data.
2. Configure it with the following:

**🌍 URL**

```
rubyCopiarEditarhttps://www.zohoapis.com/crm/v2/Leads
```

**🔧 Method**

```
nginxCopiarEditarPOST
```

**🔐 Headers**

```json
jsonCopiarEditar{
  "Authorization": "Zoho-oauthtoken YOUR_ACCESS_TOKEN",
  "Content-Type": "application/json"
}
```

**🧾 Body (JSON)**

Fill in Zoho CRM fields using your stored variables:

```json
jsonCopiarEditar{
  "data": [
    {
      "Company": "{{company}}",
      "Last_Name": "{{last_name}}",
      "First_Name": "{{first_name}}",
      "Email": "{{email}}",
      "Phone": "{{phone}}",
      "Lead_Source": "Agent Supply"
    }
  ]
}
```

> Replace variable names with whatever you're using in your Chain.

***

**Step 4: Test Your Chain**

* Run a test session through your Chain.
* Submit lead data.
* Go to **Zoho CRM > Leads** to confirm the lead was created.

***

**Step 5: Handle Token Expiry (Optional)**

Access tokens expire (usually after 1 hour). To handle this:

* Use your `refresh_token` to generate new tokens on demand.
* You can set up a separate Agent Supply Chain to refresh the token:

```bash
bashCopiarEditarcurl --request POST \
  --url https://accounts.zoho.com/oauth/v2/token \
  --data 'refresh_token=YOUR_REFRESH_TOKEN&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=refresh_token'
```

Store and reuse the new access token in your Agent Supply Chain.

***

#### ✅ Summary

| Step | Description                                    |
| ---- | ---------------------------------------------- |
| 1    | Get Zoho OAuth access token                    |
| 2    | Collect lead data in Agent Supply Chain        |
| 3    | Use HTTP request node to send data to Zoho CRM |
| 4    | Test and confirm leads appear in Zoho          |
| 5    | (Optional) Automate token refresh              |

#### &#x20; <a href="#tutorial-from-zoho" id="tutorial-from-zoho"></a>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.agentsupply.ai/ai-features/leads-legacy/sending-lead-data-to-zoho-crm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
