Google Sheets Content Approval to Oktopost Draft Setup Guide
This guide covers the end-to-end process of creating an automation in Google Sheets and using an Oktopost Custom Agent to fetch, process, and draft social media posts.
Part 1: In Oktopost
Create Agent
Go to Settings > AI Management > Custom Agents > New Agent.
Add Trigger
Click the + button and select the Webhook node.
Configure Vendor
Click the node and select Generic from the Vendor dropdown. Click Save.
Copy URL
Click the Copy icon next to the Webhook URL. You will need this for the next part.
Part 2: In Google Sheets
Open Extensions
In your Google Sheets workspace where you will enter content, click Extensions > Apps Script. A new browser tab opens with the script editor. Keep both your spreadsheet and Apps Script open in separate tabs.
Copy and Paste the Script
In Apps Script, delete any existing content in the editor and paste the script below.
// Adds a custom menu item to your Google Sheet toolbar
function onOpen() {
const ui = SpreadsheetApp.getUi();
ui.createMenu('Oktopost')
.addItem('Send Active Row', 'sendActiveRow')
.addToUi();
}
function sendActiveRow() {
const sheet = SpreadsheetApp.getActiveSheet();
const activeCell = sheet.getActiveCell();
const rowNumber = activeCell.getRow();
// Prevent sending Row 1 (Headers)
if (rowNumber <= 1) {
SpreadsheetApp.getUi().alert('Please select a data row (Row 2 or lower).');
return;
}
// =========================================================================
// 1. CONFIGURATION (REQUIRED)
// Replace the placeholder strings below with your custom Oktopost details.
// =========================================================================
const webhookUrl = 'YOUR_OKTOPOST_WEBHOOK_URL_HERE';
const secretKey = 'YOUR_OKTOPOST_SECRET_KEY_HERE';
// =========================================================================
// Guard check: Warn the user if they try to run the script without adding their keys
if (webhookUrl === 'YOUR_OKTOPOST_WEBHOOK_URL_HERE' || secretKey === 'YOUR_OKTOPOST_SECRET_KEY_HERE') {
SpreadsheetApp.getUi().alert('Configuration Error: Please update lines 21-22 in the Apps Script editor with your actual Oktopost Webhook URL and Secret Key.');
return;
}
const lastCol = sheet.getLastColumn();
const headers = sheet.getRange(1, 1, 1, lastCol).getValues()[0];
const rowData = sheet.getRange(rowNumber, 1, 1, lastCol).getValues()[0];
// Pair headers with cell values
const payload = {};
headers.forEach((header, index) => {
payload[header] = rowData[index];
});
const options = {
method: 'post',
contentType: 'application/json',
headers: {
'x-webhook-secret': secretKey,
'Authorization': secretKey
},
payload: JSON.stringify(payload)
};
try {
UrlFetchApp.fetch(webhookUrl, options);
SpreadsheetApp.getUi().alert(`Success! Sent Row ${rowNumber} to Oktopost.`);
} catch (err) {
SpreadsheetApp.getUi().alert(`Error sending row: ${err.toString()}`);
}
}
It will look similar to this:
Replace Placeholders
Replace every instance of YOUR_OKTOPOST_WEBHOOK_URL_HERE and YOUR_OKTOPOST_SECRET_KEY_HERE with the Webhook URL and Secret Key from your Oktopost Webhook node.
Save the Script
After you enter your webhook details, click the Save icon in the Apps Script toolbar.
Send a Sample JSON Payload
Run a sample of the script so Oktopost can map your spreadsheet columns. Name your columns in row 1 and add at least one test row. The test data does not need to be real.
Run Send Active Row
In Apps Script, select onOpen > sendActiveRow from the function dropdown and run it.
Copy the Execution Log
Open the execution log and copy the payload output. It will look similar to this:
Part 3: In Oktopost
Now that Oktopost receives signals from Google Sheets, configure the agent to process incoming rows and create draft posts.
Configure the Webhook Sample Payload
Open your Webhook node, paste the payload you copied from the Apps Script execution log into the Sample Payload box, and click Save.
Add the AI Action
Click the + button in the agent builder and add an AI Action node.
Connect the AI Action to the Webhook
Drag the connector dot on the Webhook or AI Action node to link the two nodes.
Add Instructions to the AI Action
Enter instructions that tell the agent how to use the Google Sheets data. Use the template below as a starting point. Replace every nodes.[REDACTED] reference with the variable links from the three-dot menu in the instructions editor.
Instructions:
1. Check Approval Status: ONLY create a draft post IF Approval Status is exactly "yes". If no, stop execution.
2. Create a draft post under Publishing for Juliana Test's LinkedIn profile, assigning it to Campaign: {{nodes.[REDACTED]-events_1784740409758.output.Campaigns}}.
3. Media & Link Attachment Logic (Execute strictly in this order):
- IF Image URL is provided: Upload the file using create_media and attach the resulting media ID to the post {{nodes.[REDACTED]-events_1784740409758.output.Image URL}}
- ELSE IF Post Copy contains a website URL:
* Extract the website URL from Post Copy.
* Run fetch_webpage to scrape the article's title and excerpt.
* Call create_message passing:
- linkUrl: <extracted website URL>
- linkTitle: <scraped title from fetch_webpage>
- description: <scraped excerpt from fetch_webpage>
4. Do NOT modify, translate, or paraphrase the post copy. Use the text from Post Copy exactly as provided.
5. Preserve all original formatting, line breaks, emojis, and hashtags.
Save Your Progress
Close the AI Action node and click Save in the top-right corner of the agent builder. Your agent will look similar to this:
Part 4: Testing
Activate the Agent
Set your agent to Active in Oktopost when you are ready to test.
Send an Approved Post to Oktopost
In Google Sheets, select a cell in the row you want to send. Click Oktopost > Send Active Row from the menu bar. Within a few seconds, the row data is sent to Oktopost.
Considerations
- To send images through Google Sheets, provide an HTML image link. You can use a service such as imgbb.com to convert an image into a link
- The system does not allow the same row to be sent twice. If you try, an error message appears
- Your spreadsheet must include an Approval column so the agent can identify approved content