text stringlengths 0 59.1k |
|---|
export const sendGmailSummary = createTool({ |
name: "sendGmailSummary", |
description: "Email a summary to a stakeholder.", |
parameters: z.object({ |
to: z.string().email(), |
subject: z.string(), |
body: z.string(), |
}), |
execute: async ({ to, subject, body }) => { |
return await voltops.actions.gmail.sendEmail({ |
credential: { credentialId: process.env.GMAIL_CREDENTIAL_ID! }, |
to, |
subject, |
textBody: body, |
}); |
}, |
}); |
``` |
Agents can now send follow-ups, reply in an existing thread, or fetch a message body as part of a |
reasoning chain. |
## Testing payloads in the console |
- Open **Volt Console → Actions → Add Action → Gmail** and attach your Gmail credential. |
- Pick the action, enter the payload (recipients, body, attachments), and run a test. Successful runs |
show Gmail’s response plus an SDK snippet you can copy. |
- Set `draft: true` to create a draft without sending—useful while validating payloads. |
## Troubleshooting |
- `invalid_grant` or auth failures usually mean the refresh token is missing/expired or the OAuth |
app lacks offline access; re-authorize and store the new token. |
- Service accounts require domain-wide delegation and a subject email if you are sending on behalf of |
a user. |
- Provide at least one of `htmlBody` or `textBody`; replies also need `threadId` or `inReplyTo`. |
- Attachments must be base64-encoded content (no data URLs); include `contentType` when possible. |
- Inspect **Volt → Actions → Runs** for request/response bodies, retries, and Gmail error messages. |
<|endoftext|> |
# source: VoltAgent__voltagent/website/actions-triggers-docs/actions/postgres.md type: docs |
# Postgres Actions |
VoltOps ships a managed **Execute Postgres Query** action so agents can run parameterized SQL against your databases with observability, retries, and credential management handled for you. |
## Prerequisites |
1. A reachable Postgres database (host, port, database, user, password) with network access from Volt. |
2. A Volt project with API keys (`pk_…`, `sk_…`). |
3. A Postgres credential inside Volt: |
- Go to **Settings → Integrations → Add Credential → Postgres (Actions)**. |
- Enter host, port, user, password, database, and optionally toggle SSL / reject self-signed certs. |
- Save to generate a `cred_xxx` identifier. |
4. (Recommended) Save the credential ID as an environment variable: |
```bash |
POSTGRES_CREDENTIAL_ID=cred_xxx |
``` |
## Run Postgres actions from code |
```ts |
import { VoltOpsClient } from "@voltagent/core"; |
const voltops = new VoltOpsClient({ |
publicKey: process.env.VOLTAGENT_PUBLIC_KEY!, |
secretKey: process.env.VOLTAGENT_SECRET_KEY!, |
}); |
// Parameterized query (recommended) |
const result = await voltops.actions.postgres.executeQuery({ |
credential: { credentialId: process.env.POSTGRES_CREDENTIAL_ID! }, |
query: |
"SELECT id, email, status FROM public.users WHERE status = $1 ORDER BY created_at DESC LIMIT 10;", |
parameters: ["active"], |
applicationName: "VoltAgent", |
statementTimeoutMs: 30_000, |
connectionTimeoutMs: 30_000, |
ssl: { rejectUnauthorized: false }, |
}); |
console.log(result.responsePayload.rows); |
``` |
No stored credential? You can pass inline connection details instead: |
```ts |
await voltops.actions.postgres.executeQuery({ |
credential: { |
host: "db.example.com", |
port: 5432, |
user: "app_user", |
password: process.env.POSTGRES_PASSWORD!, |
database: "app_db", |
ssl: true, |
}, |
query: "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';", |
}); |
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.