For the complete site index, see llms.txt. Docs index: llms-docs.txt. Marketing corpus: llms-full.txt. Docs corpus: llms-full-docs.txt. Prefer markdown URLs where available (append .md).. Product skill: skill.md. Pricing: pricing.md. Docs MCP: /docs/mcp. Site MCP: /mcp.

AI & Automation/

Vercel AI SDK + Reloop: Send Smart Notifications from Your AI App

6 MINUTES READ

Summary

Combine the Vercel AI SDK's tool calling with Reloop to trigger intelligent, context-aware email notifications from any AI-powered Next.js application.

Why combine Vercel AI SDK with Reloop

The Vercel AI SDK makes it trivially easy to add tool calling to any Next.js app. Reloop gives you reliable, observable email delivery. Together, they let your AI decide when to send an email and what to say, while Reloop handles the infrastructure.

Setting up the tool

Define a notifyUser tool using the AI SDK's tool() helper and the Zod schema it expects:

typescript
1import { tool } from "ai";
2import { z } from "zod";
3import { Reloop } from "reloop-email";
4
5const reloop = new Reloop(process.env.RELOOP_API_KEY!);
6
7export const notifyUser = tool({
8 description: "Send an email notification to the user about a task or event.",
9 parameters: z.object({
10 email: z.string().email(),
11 subject: z.string(),
12 message: z.string(),
13 }),
14 execute: async ({ email, subject, message }) => {
15 await reloop.emails.send({
16 from: "notifications@yourdomain.com",
17 to: email,
18 subject,
19 html: `<p>${message}</p>`,
20 });
21 return { delivered: true };
22 },
23});

Wiring it into a Server Action

typescript
1import { streamText } from "ai";
2import { openai } from "@ai-sdk/openai";
3
4export async function runAgent(prompt: string, userEmail: string) {
5 return streamText({
6 model: openai("gpt-4o"),
7 prompt,
8 tools: { notifyUser },
9 });
10}

Example: a task completion agent

When a long-running background task finishes, the model can decide to notify the user by email rather than just returning a response. This keeps the user in the loop without polling.

Observability

Every email triggered by the AI agent appears in Reloop's logs with full metadata: subject, recipient, timestamp, delivery status. You can see exactly what your agent sent and when.

W: 320.0px180R20∠45.0°

Ship your first email with Reloop
in minutes.

Open-source, deliverability-focused, and yours to self-host or run on Reloop Cloud. No lock-in, no rewrite later.

Reloop