Use a custom action to log data from AI agent conversations to a Google Sheet. Good for tracking shipping issues, refund requests, product complaints, or anything else you want to collect.
What you'll set up
-
📝 A Google Sheet to receive the data
-
⚡ A Google Apps Script that accepts requests
-
🤖 A custom action that tells the AI agent when and what to log
-
đź“‹ A guidance rule to ensure it triggers reliably
Step 1: Create the Google Sheet
Create a new Google Sheet. The first row can have headers matching your parameters (e.g., "Timestamp", "Customer Name", "Order Number", "Issue Type", "Summary"), but it's optional—data will append to whatever row is next.
Step 2: Create the Apps Script
-
In your Google Sheet, go to Extensions → Apps Script
-
Replace the default code with:
function doGet(e) {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const data = e.parameter;
const row = [new Date(), ...Object.values(data)];
sheet.appendRow(row);
return ContentService
.createTextOutput(JSON.stringify({ success: true }))
.setMimeType(ContentService.MimeType.JSON);
}
- Click Save (Ctrl+S)
Step 3: Deploy the script
-
Click Deploy → New deployment
-
Click the gear icon, select Web app
-
Set Execute as: Me
-
Set Who has access: Anyone
-
Click Deploy
-
Authorize the app when prompted
-
Copy the Web app URL
⚠️ Google Workspace accounts: If you're using a company Google account and "Anyone" isn't available, you may need to use a personal Gmail account instead, or ask your Workspace admin to allow external sharing for Apps Script.
Step 4: Create the custom action in Commslayer
-
Go to Tools → AI agent → Actions
-
Click the Custom actions tab
-
Click + Custom action
-
Configure:
-
Action name: Shipping issues log
-
When to use: "When a customer reports a shipping problem like a delayed, lost, or damaged package, log the details"
-
Method: GET
-
URL: Paste your Apps Script Web app URL
-
-
Add parameters for each piece of data you want to capture:
-
customer_name(String) — Customer's name -
customer_email(String) — Customer's email -
order_number(String) — The order number if mentioned -
issue_type(String) — Type of shipping issue (delayed, lost, damaged, wrong address, etc.) -
summary(String) — Brief summary of the problem
-
-
Click Save
Step 5: Create a guidance rule to trigger it
You need a guidance rule that tells the AI agent when to use the custom action. Without this, the action may not trigger consistently.
-
Go to Tools → AI agent → Guidance
-
Create a new guidance rule:
-
Title: Shipping issues
-
Trigger: "Customer reports a shipping problem like delayed, lost, or damaged package"
-
-
In the Agent instructions, tell the AI to use the action:
[Your instructions for handling shipping issues go here]
After replying, use "Shipping issues log" to log the issue details.
This is just an example—replace the first part with your actual guidance for how the AI should handle shipping issues (e.g., what to check, what to offer, when to escalate). The key part is the last line that tells the AI to use your custom action.
Step 6: Test it
Click the Test button in your custom action to verify the Google Sheet connection works.
Then test the full flow in the AI Playground—send a message about a shipping problem and confirm the AI triggers the action and logs it to your sheet.
Troubleshooting errors:
-
401 Unauthorized — Redeploy with "Anyone" access
-
404 Not Found — Create a new deployment and update the URL
-
405 Method Not Allowed — Make sure you're using GET, not POST
How it works
When a customer mentions a shipping problem, the guidance rule fires and tells the AI agent to handle the conversation and log the details. The AI sends a GET request to your Apps Script with the parameters as query strings. The script appends them to your sheet with a timestamp.
The AI agent decides what values to populate based on the conversation. Write clear parameter descriptions so it knows what to extract.