text
stringlengths
0
59.1k
<br/>
<br/>
Open [VoltAgent Console](https://console.voltagent.dev/triggers) and go to **Triggers** → **Create Trigger**.
1. Select **Airtable → Record created**
2. Select your base and table
3. Save the trigger
</StepSection>
<StepSection stepNumber={4} title="Expose Your Local Agent with Volt Tunnel">
<video controls loop muted playsInline style={{width: '100%', height: 'auto'}}>
<source src="https://cdn.voltagent.dev/voltagent-recipes-guides/airtable-2.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
<br/>
<br/>
[Volt Tunnel](/deployment-docs/local-tunnel/) exposes your local server to the internet so triggers can reach it.
Run the tunnel command:
```bash
pnpm volt tunnel 3141
```
Copy the tunnel URL (e.g., `https://your-tunnel.tunnel.voltagent.dev`) and set it as the **Endpoint URL** in the trigger configuration.
</StepSection>
<SectionDivider>
The project is set up and the Airtable trigger is configured. The following steps cover wiring the trigger to your agent and adding the update action.
</SectionDivider>
<StepSection stepNumber={5} title="Wire the Airtable Trigger to Your Agent">
<video controls loop muted playsInline style={{width: '100%', height: 'auto'}}>
<source src="https://cdn.voltagent.dev/voltagent-recipes-guides/airtable-3.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
<br/>
<br/>
This code sets up a trigger handler that receives new Airtable rows and generates field suggestions. The write-back tool is added in the next step.
<ExpandableCode title="src/index.ts" previewLines={15}>
```ts
import { openai } from "@ai-sdk/openai";
import { Agent, VoltAgent, createTriggers } from "@voltagent/core";
import { createPinoLogger } from "@voltagent/logger";
import { honoServer } from "@voltagent/server-hono";
import { safeStringify } from "@voltagent/internal";
type AirtableRecordCreatedPayload = {
record?: {
id?: string;
fields?: Record<string, unknown>;
};
baseId?: string;
tableId?: string;
};
const logger = createPinoLogger({ name: "with-airtable", level: "info" });
const airtableAgent = new Agent({
name: "airtable-agent",
instructions: `You process newly created Airtable rows.
Draft a summary, a priority (High/Medium/Low), a status (New/In Progress/Blocked/Done), and next steps as bullet text.
You will get a tool to write back in the next step; for now just return the proposed values clearly.`,
model: openai("gpt-4o-mini"),
});
new VoltAgent({
agents: { airtableAgent },
server: honoServer(),
logger,
triggers: createTriggers((on) => {
on.airtable.recordCreated(async ({ payload, agents }) => {
const { record, baseId, tableId } =
(payload as AirtableRecordCreatedPayload | undefined) ?? {};
if (!record?.id) {
logger.warn("Missing recordId in Airtable payload");
return;
}
await agents.airtableAgent.generateText(`Airtable record created.
Base: ${baseId ?? "unknown-base"}
Table: ${tableId ?? "unknown-table"}
Record ID: ${record.id}
Existing fields (JSON): ${safeStringify(record.fields ?? {})}
Propose updates (no tool calls yet):