Skip to main content

Google Sheets

Lantfly can write to a Google Sheets spreadsheet automatically:

Kind (kind)What it writesWhen
runThe items of the run's default dataset (hidden #fields left out). Optional filter on an actor or a task.After every matching run that succeeded.
listeningNew visible mentions of a listening project, one row per mention, updated in place by id.Every minute.
listening with include_kpisOne row of yesterday's KPIs (in the project's time zone) to a second tab: date, project, new_mentions, views, likes, comments, shares, engagement, positive, neutral, negative, updated in place by date.Once a day.

Lantfly writes with its own Google service account. You share the spreadsheet with it; Lantfly never asks for your Google credentials.

Set up an export​

  1. In the Console, open Integrations → New Google Sheets export. The page shows Lantfly's service account email.
  2. In Google Sheets, click Share and add that email as Editor.
  3. Back in Lantfly, paste the spreadsheet link (or its ID), pick a tab name, and choose what to export:
    • Run results: optionally only one actor or one task.
    • Listening: the project, and whether to add the daily KPI row. Turn on Include existing to also export the mentions found before today (default: only new ones).
  4. Prove the spreadsheet is yours. The export shows a tab name like lantfly-ab12cd. Add a tab with exactly that name to the spreadsheet. You can delete it after the next step.
  5. Click Check access. Lantfly opens the spreadsheet, finds the verification tab, creates your export tab if it is missing and writes the header row. Google's error (not shared, not found) is shown with a hint when something is wrong.
  6. Click Export now to send the first rows, or wait for the next run or mention.
Why the verification tab

Every customer shares spreadsheets with the same service account. The verification tab proves that the person creating the export can edit the spreadsheet. Nothing is written until the export is verified; mentions found in the meantime are exported once it is. Changing the spreadsheet of an export asks for verification again. A spreadsheet can be connected to one Lantfly account only.

Columns and updates​

  • Columns (fields) are item paths; a.b reads a nested value. Empty: for runs, the keys of the items; for listening, the default mention columns (id, platform, kind, published_at, the author, text, url, the counts, sentiment, hashtags, first_seen_at, is_ad…).
  • Lantfly follows the header row in the sheet: you can reorder columns or add your own. Missing fields are added at the end of the header, and your own columns are never overwritten.
  • Upsert key (upsert_key): a row whose cell in this column matches is updated instead of appended. Listening exports use id. Empty: rows are only appended.
  • Row cap (max_rows): rows one export may write at a time. Extra rows are skipped and reported on the export.
  • Values are written as plain values, never as formulas: scraped text like =IMPORTXML(...) stays text. Cells longer than 49,000 characters are cut.
  • A run is exported once per export. Export now can send it again.

Delivery and errors​

  • Rate limits, Google server errors and lost connections are retried after 1, 5, 25, 125 and 625 seconds.
  • 403 (not shared), 404 (wrong ID) and 400 fail at once.
  • The last error shows on the export list and its page, and you get an integration.failing notification (at most once a day per export).

API​

EndpointUse
GET /api/v3/integrations/google-sheets/service-account{ configured, email }: the email to share with.
GET /api/v3/integrations/google-sheetsYour exports, each with its last delivery.
POST /api/v3/integrations/google-sheetsCreate an export.
GET /api/v3/integrations/google-sheets/{integration}One export with its last 50 deliveries.
PATCH /api/v3/integrations/google-sheets/{integration}Update it (kind cannot change).
DELETE /api/v3/integrations/google-sheets/{integration}Delete it.
POST /api/v3/integrations/google-sheets/{integration}/testCheck access: verification tab, export tab, header row.
POST /api/v3/integrations/google-sheets/{integration}/syncExport now: the latest matching succeeded run, or the new mentions (and the KPI row when due).
Create a run-results export
curl -X POST "https://lantfly.com/api/v3/integrations/google-sheets" \
-H "Authorization: Bearer $LANTFLY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Web scraper results",
"kind": "run",
"spreadsheet": "https://docs.google.com/spreadsheets/d/<spreadsheetId>/edit",
"sheet_name": "Results",
"condition": { "actor_id": "<actorId>" },
"fields": ["url", "title", "loadedAt"],
"upsert_key": "url"
}'

The answer has verification_tab. Add that tab to the spreadsheet, then:

Check access and verify
curl -X POST "https://lantfly.com/api/v3/integrations/google-sheets/<integrationId>/test" \
-H "Authorization: Bearer $LANTFLY_TOKEN"
FieldMeaning
nameName of the export.
kindrun or listening.
spreadsheetSpreadsheet URL or ID (on create and update).
sheet_nameThe tab; created when missing. No [ ] * ? / \ :.
conditionrun only: actor_id and/or task_id.
project_idlistening only, required.
fieldsColumns.
upsert_keyColumn to update rows by.
max_rowsRows one delivery may write.
include_kpis, kpi_sheet_namelistening: the daily KPI row and its tab (default <sheet_name> KPI).
include_existinglistening, on create: also export existing mentions.
is_enabledTurn the export off without deleting it.

Creating and changing exports needs the permission to manage automations in an organization, and access to the project for listening exports.