home / skills / different-ai / agent-bank / ben-agent-email

ben-agent-email skill

/.opencode/skill/ben-agent-email

This skill manages [email protected] email flows using Resend, enabling inbound parsing, session updates, and reliable outbound replies.

npx playbooks add skill different-ai/agent-bank --skill ben-agent-email

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.3 KB
---
name: ben-agent-email
description: Canonical Resend inbox for [email protected]
license: MIT
compatibility: opencode
metadata:
  service: resend
  category: email
  inbox: [email protected]
---

# Ben-Agent Email (Resend)

Canonical email inbox for 0 Finance operations.

## Purpose

Manage inbound and outbound email for `[email protected]` using Resend and the existing AI email pipeline.

## Canonical Inbox

- `[email protected]`
- Domain defaults to `zerofinance.ai` via `AI_EMAIL_INBOUND_DOMAIN`.

## Inbound Flow (Required)

1. Resend catch-all or routed domain receives inbound email.
2. Resend webhook posts to `POST /api/ai-email`.
3. Webhook signature verified with `RESEND_WEBHOOK_SECRET`.
4. AI email pipeline parses, responds, and updates session state.

## Outbound Flow

- Send via Resend with `from: "Ben Agent <[email protected]>"`.
- Replies and confirmations are sent through `packages/web/src/lib/email-provider/resend-provider.ts`.

## Environment (.env)

Create a collocated `.env` file at:

```
.opencode/skill/ben-agent-email/.env
```

Required values:

```
RESEND_API_KEY=
RESEND_WEBHOOK_SECRET=
EMAIL_PROVIDER=resend
AI_EMAIL_INBOUND_DOMAIN=zerofinance.ai
```

## Credential Missing Behavior

- If `RESEND_API_KEY` or `RESEND_WEBHOOK_SECRET` is missing, ask the user to provide them and stop.
- Do not invent credentials or proceed without explicit access.

## Entities + CRUD Coverage

- Email sessions: create/read/update via AI email pipeline; delete not supported.
- Messages: create (send/reply), read (session history), update (follow-up), delete not supported.
- Attachments: create (persist), read (load), update not used, delete not supported.

## Tools / Interfaces

- `packages/web/src/app/api/ai-email/route.ts` - inbound webhook handler.
- `packages/web/src/lib/email-provider/resend-provider.ts` - Resend send/receive.
- `packages/web/src/lib/ai-email/*` - session state, prompts, attachment handling.

## Completion Signals

- `complete`: inbound message processed and response sent.
- `continue`: awaiting user clarification or confirmation.
- `error`: provider failures or invalid webhook signature.

## Example Prompts

- "Check `[email protected]` for new invoices and summarize."
- "Reply to the latest sender confirming we received their request."
- "Draft a follow-up asking for missing bank details."

Overview

This skill provides a canonical Resend-backed inbox for [email protected] and integrates with the existing AI email pipeline. It centralizes inbound and outbound email handling for 0 Finance operations, exposing CLI-first controls and programmatic hooks. The skill enforces secure webhook verification and a predictable session-driven message model.

How this skill works

Inbound mail for the zerofinance.ai domain is routed to Resend, which posts messages to POST /api/ai-email. The webhook is verified with RESEND_WEBHOOK_SECRET before the AI pipeline parses content, updates session state, and decides whether to respond, continue, or signal an error. Outbound mail is sent through Resend with the from address "Ben Agent <[email protected]>" using the resend-provider implementation.

When to use it

  • Automate handling of operational emails sent to [email protected]
  • Route inbound messages into an AI-managed session workflow for parsing and replies
  • Send confirmations, replies, or follow-ups from the canonical agent address
  • Integrate email events into CLI-first workflows for 0 Finance operations
  • Maintain a single source of truth for message history and attachments

Best practices

  • Store credentials in the collocated .opencode/skill/ben-agent-email/.env file and never hardcode keys
  • Ensure RESEND_WEBHOOK_SECRET is set and rotation procedures are in place to keep webhooks secure
  • Use the AI email session model to track state: complete, continue, or error
  • Prefer session-based operations (create/read/update) rather than ad-hoc state outside the pipeline
  • Validate incoming webhooks and stop processing if credentials are missing

Example use cases

  • Check [email protected] for new invoices and generate a short summary for finance
  • Automatically reply to a customer confirming receipt of their request and next steps
  • Draft a follow-up asking for missing bank details when a payment request is incomplete
  • Persist attachments from inbound messages and surface them in the session history
  • Integrate inbound email events with CLI tools to trigger operational workflows

FAQ

What environment variables are required?

RESEND_API_KEY, RESEND_WEBHOOK_SECRET, EMAIL_PROVIDER=resend, and AI_EMAIL_INBOUND_DOMAIN=zerofinance.ai must be set in .opencode/skill/ben-agent-email/.env.

What happens if credentials are missing?

The skill will prompt for the missing credentials and stop processing. Do not proceed or invent keys without explicit access.