> ## Documentation Index
> Fetch the complete documentation index at: https://api.scalysis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send calls to Google Sheets

> Add a row to a Google Sheet after every call.

Paste a small script into your Google Sheet, then paste its link into your agent's webhook. After every finished call, a new row shows up with the agent, customer, phone, outcome, summary and transcript.

## The script

```js Apps Script theme={null}
function doPost(e) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
  var data = JSON.parse(e.postData.contents);

  if (sheet.getLastRow() === 0) {
    sheet.appendRow([
      "Time",
      "Agent",
      "Customer",
      "Phone",
      "Duration (sec)",
      "Outcome",
      "Summary",
      "Transcript",
      "Order",
      "Answered",
      "Direction"
    ]);
  }

  sheet.appendRow([
    data.started_at || data.occurred_at || "",
    data.agent_name || "",
    data.customer_name || "",
    data.customer_phone || "",
    data.duration_sec || "",
    data.call_outcome || "",
    data.summary || "",
    data.transcript || "",
    data.order_number || "",
    data.answered ? "yes" : "no",
    data.direction || ""
  ]);

  return ContentService
    .createTextOutput(JSON.stringify({ ok: true }))
    .setMimeType(ContentService.MimeType.JSON);
}
```

## Set it up

**1. Open Apps Script**

Open a Google Sheet. In the menu, click **Extensions**, then **Apps Script**. A code editor opens in a new tab.

**2. Paste the script**

Delete the sample code. Paste the script above. Click the disk icon to **Save**.

**3. Deploy it as a web app**

Top right, click **Deploy**, then **New deployment**. Pick type **Web app**. Set **Execute as** to **Me** and **Who has access** to **Anyone**. Click **Deploy** and allow access. Copy the web app URL (it ends in `/exec`).

**4. Paste the URL on your agent**

In the dashboard, open **Voice Agents**, click your agent, then **Settings & post-call** and **Post-call rules**. In the **Webhook** card, paste the URL and click **Save**.

**5. Send a test**

Click **Send test**. A sample row appears in your sheet.

> [!NOTE]
>
> Rows go to the first tab of the sheet. The header row is added on the first call.

> [!TIP]
>
> If you edit the script later, deploy again with **Manage deployments** and pick **New version**. Otherwise the old script keeps running.

Want more columns? Every field you can add is listed on [Agent webhook](https://api.scalysis.com/webhooks/agent-webhook.md#fields).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.