The Open Framework for Building Agents
feat(docs): add the marketing team template (#1589)
Ben Sabic5e3119b309cb
diff --git a/apps/docs/app/[lang]/templates/integration-icons.tsx b/apps/docs/app/[lang]/templates/integration-icons.tsxindex 034448267..3434c3abd 100644--- a/apps/docs/app/[lang]/templates/integration-icons.tsx+++ b/apps/docs/app/[lang]/templates/integration-icons.tsx@@ -1,6 +1,14 @@import { BracesIcon } from "lucide-react";import type { ComponentType, SVGProps } from "react";-import { linearLogo, notionLogo, sentryLogo, slackLogo, webLogo } from "@/lib/integrations/logos";+import {+ linearLogo,+ notionLogo,+ resendLogo,+ sentryLogo,+ slackLogo,+ typefullyLogo,+ webLogo,+} from "@/lib/integrations/logos";import type { TemplateIntegration } from "@/lib/templates/data";type IconComponent = ComponentType<SVGProps<SVGSVGElement>>;@@ -9,7 +17,9 @@ export const integrationIcons: Record<TemplateIntegration, IconComponent> = {"HTTP API": BracesIcon,Linear: linearLogo,Notion: notionLogo,+ Resend: resendLogo,Sentry: sentryLogo,Slack: slackLogo,+ Typefully: typefullyLogo,"Web chat": webLogo,};diff --git a/apps/docs/lib/integrations/logos.tsx b/apps/docs/lib/integrations/logos.tsxindex cb51cdb55..185ea9743 100644--- a/apps/docs/lib/integrations/logos.tsx+++ b/apps/docs/lib/integrations/logos.tsx@@ -465,6 +465,21 @@ export const beeperLogo = (props: LogoProps) => (export const resendLogo = (props: LogoProps) => <SiResend {...props} />;+export const typefullyLogo = (props: LogoProps) => (+ <svg fill="none" viewBox="47 47 130 130" xmlns="http://www.w3.org/2000/svg" {...props}>+ <path+ d="M0 0 C0.74507813 0.00451172 1.49015625 0.00902344 2.2578125 0.01367188 C4.0885764 0.02540754 5.91929873 0.0433415 7.75 0.0625 C7.14395591 4.14584626 4.84730736 7.0612421 2.5625 10.375 C-2.19352263 17.53440191 -5.32057264 24.9903426 -8.25 33.0625 C-17.16154975 57.46763889 -17.16154975 57.46763889 -26.984375 63.03515625 C-34.07971612 66.25252645 -41.54415248 67.43087315 -49.25 68.0625 C-49.25 68.3925 -49.25 68.7225 -49.25 69.0625 C-40.52369392 69.15994014 -31.91996704 69.22961095 -23.25 68.0625 C-23.41531336 74.50972095 -26.91529318 78.6325249 -31.25 83.0625 C-38.42086001 88.95740627 -46.28954743 90.49598731 -55.25 92.0625 C-61.3099593 93.33277308 -61.3099593 93.33277308 -67.25 95.0625 C-68.2992872 96.78705409 -68.2992872 96.78705409 -69.25 99.0625 C-78.68670886 116.85047468 -78.68670886 116.85047468 -85.25 122.0625 C-86.57 122.0625 -87.89 122.0625 -89.25 122.0625 C-88.66875831 117.39360339 -87.36989252 113.68082637 -85.3984375 109.41796875 C-85.10769852 108.78353851 -84.81695953 108.14910828 -84.51741028 107.49545288 C-83.56009428 105.41041702 -82.59274339 103.33021408 -81.625 101.25 C-80.94894978 99.78473548 -80.27358667 98.31915375 -79.59887695 96.85327148 C-78.54863388 94.57166096 -77.49785805 92.29031377 -76.4443512 90.01020813 C-74.01583684 84.74952764 -71.63026619 79.47109428 -69.26953125 74.1796875 C-52.12436128 35.80891207 -52.12436128 35.80891207 -40.25 21.0625 C-39.61578125 20.26457031 -38.9815625 19.46664062 -38.328125 18.64453125 C-28.35248511 6.73361722 -15.57355722 -0.17884827 0 0 Z "+ fill="currentColor"+ transform="translate(153.25,50.9375)"+ />+ <path+ d="M0 0 C2.70461031 1.95547181 4.45314814 4.04691917 6 7 C6.60726036 10.91345565 6.3659283 13.10550859 4.875 16.75 C1.65652764 20.61216684 -1.58840395 21.79834342 -6.5 22.5 C-11.20343225 21.82808111 -12.70404748 20.37442758 -16 17 C-17.23829052 13.28512845 -17.5503822 9.86021488 -17 6 C-12.86869485 -0.78714418 -7.42056477 -2.39662454 0 0 Z "+ fill="currentColor"+ transform="translate(149,151)"+ />+ </svg>+);+export const googlechatLogo = (props: LogoProps) => <SiGooglechat color="default" {...props} />;export const whatsappLogo = (props: LogoProps) => <SiWhatsapp color="default" {...props} />;diff --git a/apps/docs/lib/templates/data.ts b/apps/docs/lib/templates/data.tsindex e6161bfec..791eff8d3 100644--- a/apps/docs/lib/templates/data.ts+++ b/apps/docs/lib/templates/data.ts@@ -1,12 +1,14 @@-export type TemplateCategory = "Chat" | "Collaboration" | "Example";+export type TemplateCategory = "Chat" | "Collaboration" | "Example" | "Marketing";import { templateSourceFiles } from "./sources";export type TemplateIntegration =| "HTTP API"| "Linear"| "Notion"+ | "Resend"| "Sentry"| "Slack"+ | "Typefully"| "Web chat";export type TemplateSource = "GitHub" | "Vercel Templates";@@ -76,6 +78,21 @@ export const templateEntries: TemplateEntry[] = [source: "Vercel Templates",files: templateSourceFiles["eve-slack-agent"],},+ {+ slug: "marketing-team-eve-template",+ title: "Marketing team",+ setupPrompt:+ "I want to build a team of marketing agents with the eve framework, using the marketing team template. Read the setup instructions at https://agent-resources.dev/marketing-team-eve-template.md and follow them. They will cover deploying the template, building with eve, how everything works overall, and more.",+ description:+ "A team of marketing agents: a lead routes work to specialists for positioning, long-form content, social, SEO, and email, publishing through Notion, Typefully, and Resend.",+ sourceHref: "https://github.com/vercel-labs/marketing-team-eve-template/tree/main",+ sourceRevision: "9a881661bd5b0652469467f00eadbd41e9f2c786",+ category: "Marketing",+ model: "anthropic/claude-opus-5",+ integrations: ["Web chat", "Slack", "Notion", "Resend", "Typefully"],+ source: "Vercel Templates",+ files: templateSourceFiles["marketing-team-eve-template"],+ },{slug: "weather-agent-fixture",title: "Weather",diff --git a/apps/docs/lib/templates/sources.ts b/apps/docs/lib/templates/sources.tsindex 85018d1e5..1f9e30cae 100644--- a/apps/docs/lib/templates/sources.ts+++ b/apps/docs/lib/templates/sources.ts@@ -458,6 +458,426 @@ export default defineTool({return { city, condition: "Sunny", temperatureF: 72 };},});+`,+ ),+ ],+ "marketing-team-eve-template": [+ file(+ "agent/agent.ts",+ "typescript",+ `import { defineAgent } from "eve";++export default defineAgent({+ compaction: { thresholdPercent: 0.9 },+ model: "anthropic/claude-opus-5",+});+`,+ ),+ file(+ "agent/channels/slack.ts",+ "typescript",+ `import { connectSlackCredentials } from "@vercel/connect/eve";+import {+ type SlackContext,+ type SlackEvent,+ type SlackInboundEventContext,+ type SlackMessage,+ slackChannel,+} from "eve/channels/slack";++const slackCredentials = connectSlackCredentials(+ process.env.SLACK_CONNECTOR ?? "slack/marketing-team"+);++function slackSessionAuth(message: SlackMessage, onBehalfOfUserId?: string) {+ const rawUser = message.raw.user;+ const userId =+ message.author?.userId ??+ (typeof rawUser === "string" ? rawUser : undefined) ??+ onBehalfOfUserId;+ return {+ attributes: {+ channel_id: message.channelId,+ // Equal to the message's own ts for top-level (non-thread) messages.+ thread_ts: message.threadTs || message.ts,+ ...(userId+ ? { user_id: userId }+ : {}),+ ...(message.author?.userName+ ? { user_name: message.author.userName }+ : {}),+ ...(message.teamId+ ? { team_id: message.teamId }+ : {}),+ },+ authenticator: "slack-webhook",+ issuer: message.teamId ? \`slack:\${message.teamId}\` : "slack",+ principalId: userId ? \`slack:\${userId}\` : "slack:unknown",+ principalType:+ message.author?.isBot && !onBehalfOfUserId ? "service" : "user",+ };+}++let cachedBotUserId: string | undefined;++async function resolveBotUserId(+ ctx: SlackContext+): Promise<string | undefined> {+ if (cachedBotUserId) {+ return cachedBotUserId;+ }+ try {+ const res = (await ctx.slack.request("auth.test", {})) as {+ ok?: boolean;+ user_id?: string;+ };+ if (res.ok && res.user_id) {+ cachedBotUserId = res.user_id;+ }+ } catch {+ // Leave uncached; the caller treats this as "cannot attribute".+ }+ return cachedBotUserId;+}++function firstHumanMention(+ text: string,+ botUserId: string+): string | undefined {+ for (const match of text.matchAll(/<@([UW][A-Z0-9]+)(?:\\|[^>]*)?>/g)) {+ if (match[1] !== botUserId) {+ return match[1];+ }+ }+}++async function resolveOnBehalfOfUserId(+ ctx: SlackContext,+ message: SlackMessage+): Promise<string | undefined> {+ if (message.author && !message.author.isBot) {+ return;+ }+ const botUserId = await resolveBotUserId(ctx);+ // Without the bot's own ID we can't tell its mention apart from a+ // human's, so attribute nothing rather than risk the wrong principal.+ if (!botUserId) {+ return;+ }+ return firstHumanMention(message.text, botUserId);+}++async function handleInbound(ctx: SlackContext, message: SlackMessage) {+ try {+ await ctx.thread.startTyping("Thinking...");+ } catch {+ // Typing indicator is a nicety, never a reason to drop the message.+ }+ return {+ auth: slackSessionAuth(+ message,+ await resolveOnBehalfOfUserId(ctx, message)+ ),+ };+}++async function isSoleThreadParticipant(+ ctx: SlackContext,+ message: SlackMessage+): Promise<boolean> {+ const authorId = message.author?.userId;+ if (!authorId) {+ return false;+ }+ const participants = await ctx.thread.listParticipants();+ return participants.length === 1 && participants[0] === authorId;+}++interface SuggestedPrompt {+ message: string;+ title: string;+}++const SUGGESTED_PROMPTS_TITLE = "What the team can do";++const SUGGESTED_PROMPTS: SuggestedPrompt[] = [+ {+ message:+ "Help me sharpen our positioning: what the product is, who it's for, and why anyone would pick it. Pull the brand context and my user preferences, then interview me about anything you're missing.",+ title: "Sharpen our positioning",+ },+ {+ message:+ "Help me plan and write our next blog post. Pull the brand context and my user preferences, then ask me for details about the post.",+ title: "Write a blog post",+ },+ {+ message:+ "Help me draft social posts for X and LinkedIn. Pull the brand context and my user preferences, then ask me what we're promoting.",+ title: "Draft social posts",+ },+ {+ message:+ "Help me review one of our pages for SEO and work out what to fix. Pull the brand context and my user preferences, then ask me for the URL.",+ title: "Review a page's SEO",+ },+];++interface SuggestedPromptsTarget {+ channelId: string;+ threadTs?: string;+}++function suggestedPromptsTarget(+ event: SlackEvent+): SuggestedPromptsTarget | undefined {+ if (event.type === "assistant_thread_started") {+ const thread = event.assistant_thread as+ | { channel_id?: unknown; thread_ts?: unknown }+ | undefined;+ const channelId = thread?.channel_id;+ if (typeof channelId !== "string" || channelId.length === 0) {+ return;+ }+ const threadTs = thread?.thread_ts;+ return {+ channelId,+ ...(typeof threadTs === "string" && threadTs.length > 0+ ? { threadTs }+ : {}),+ };+ }+ if (event.type === "app_home_opened" && event.tab === "messages") {+ const channelId = event.channel;+ return typeof channelId === "string" && channelId.length > 0+ ? { channelId }+ : undefined;+ }+}++async function setSuggestedPrompts(+ ctx: SlackInboundEventContext,+ event: SlackEvent+): Promise<void> {+ const target = suggestedPromptsTarget(event);+ if (!target) {+ return;+ }+ try {+ const response = await ctx.slack.request(+ "assistant.threads.setSuggestedPrompts",+ {+ channel_id: target.channelId,+ prompts: SUGGESTED_PROMPTS,+ title: SUGGESTED_PROMPTS_TITLE,+ ...(target.threadTs+ ? { thread_ts: target.threadTs }+ : {}),+ }+ );+ if (response.ok !== true) {+ console.warn("assistant.threads.setSuggestedPrompts returned not-ok", {+ channelId: target.channelId,+ error: response.error,+ });+ }+ } catch (error) {+ console.warn("assistant.threads.setSuggestedPrompts threw", {+ channelId: target.channelId,+ error,+ });+ }+}++export default slackChannel({+ credentials: slackCredentials,+ onAppMention: handleInbound,+ onDirectMessage: handleInbound,+ onEvent: setSuggestedPrompts,+ async onMessage(ctx, message) {+ if (message.author?.isBot) {+ return null;+ }+ if (!(await ctx.isSubscribed())) {+ return null;+ }+ if (!(await isSoleThreadParticipant(ctx, message))) {+ return null;+ }+ return handleInbound(ctx, message);+ },+ threadContext: { since: "thread-root" },+});+`,+ ),+ file(+ "agent/connections/notion.ts",+ "typescript",+ `import { connect } from "@vercel/connect/eve";+import { defineMcpClientConnection } from "eve/connections";++const notionConnector = process.env.NOTION_CONNECTOR ?? "notion/marketing-team";++const APPROVAL_REQUIRED_TOOLS = [+ "notion-move-pages",+ "notion-update-data-source",+ "notion-update-view",+];++export default defineMcpClientConnection({+ approval: ({ toolName }) =>+ APPROVAL_REQUIRED_TOOLS.some((tool) => toolName.includes(tool))+ ? "user-approval"+ : "not-applicable",+ auth: connect(notionConnector),+ description: "Notion workspace: search, read, and edit pages and databases.",+ url: "https://mcp.notion.com/mcp",+});+`,+ ),+ file(+ "agent/instructions.md",+ "markdown",+ `# Identity++You lead a marketing team. People bring you the work: a launch to plan, a post to write, a competitor to size up, a page that isn't converting. You hold the shared picture of the product and route the work to the specialist who does it, then hand back what they produced.++You are not the specialist. Your job is to understand the request, give the right subagent everything it needs, and keep the conversation coherent across several of them.++# How you write++Write like a person: plain, specific, warm, and short. Prefer a comma, a colon, or a new sentence where an em dash would go. Cut anything that reads machine-made, padded, or hyped, and don't bold words for emphasis.++Write links as plain markdown, \`[label](url)\`. Don't paste a bare URL, and don't wrap a link in bold or backticks: the markers end up inside the URL and the link stops working.++# How you work++## 1. Know the product before you delegate++The brand context is the team's shared picture of the product, and every specialist reads it, so keep it good.++- When it comes back empty, the team hasn't set it up yet, and working out what goes in it is a specialist job rather than yours. Delegate that first and let the specialist interview the user, then route the original request once there's a document to work from. Say why you're doing this, because the user asked for something else and deserves to know the detour is short.+- When a user tells you something durable about the product, positioning, or audience, you can keep it with \`save_brand_context\` directly. A correction or an addition doesn't need a delegation; reworking the positioning does.+- Task-specific detail doesn't belong in it. A campaign brief goes in the delegation.++## 2. Know how this person likes to work++\`get_user_preferences\` holds standing notes about the person rather than the product: a default set of platforms, a length they always want, a review step they expect. Load it alongside the brand context.++- When a user states a durable preference ("always draft for X and LinkedIn", "keep threads under 8 posts"), keep it with \`save_user_preferences\`. Use \`clear_user_preferences\` only when they ask to reset them.+- Where a preference conflicts with brand context, brand context wins on voice and claims; the preference wins on workflow.++## 3. Route the work, in order when it has one++Two questions before you pick, and the order matters:++1. What has to be settled before this can be made well? A piece written to be found needs its target query and its competition settled first. A piece making claims needs the claims settled first. Often the answer is nothing, and it's one call.+2. Which specialist's description covers each part?++Ask them the other way round and you'll match the deliverable to a specialist and stop reading, which is how a request that names two jobs turns into one call.++When there is an order, run it: call the first, wait, and put what it produced into the second's brief, including any artifact id. Don't brief both in parallel and hope they agree. Say what you're doing, since the user asked for one thing and is getting two steps.++A subagent starts in a fresh session and works from its \`message\` alone, so pack that message with everything it needs:++- what you want produced, and what it's for+- the relevant brand context, quoted rather than referenced+- the standing preferences that bear on this task, stated as constraints rather than as "the user prefers"+- the user's actual words where the wording matters+- constraints: platform, audience, length, deadline, tone, anything out of bounds+- where the deliverable should end up, when you know it. Some specialists write into Notion rather than handing back text, and naming the destination up front saves them asking.++When you don't have enough to write that brief, ask the user first. Guessing at a brief wastes a full delegation.++## 4. Hand back the work, don't rewrite it++Specialists produce the deliverable. Pass it back largely as they wrote it: you're the routing layer, not a second editor. If what comes back is wrong or thin, say so and send it again with clearer direction rather than patching it yourself.++When a specialist hands back a link rather than text, pass the link through with its one-line description. Don't fetch the page and paste its contents into the conversation; the link is the deliverable.++Specialists hand back artifact ids the same way, for long output meant for another agent rather than for reading in a thread. Relay the id and the summary that came with it, and put the id in the next specialist's brief when the work continues: "the audit is artifact \`<id>\`, read it before you rewrite the page." Keeping the document out of this conversation is the point, so don't open an artifact to show the user what's in it. Read it with \`read_artifact\` only when they ask for its contents, and then answer their question rather than pasting the whole thing.++Surface the caveats a specialist flags. When it reports an unverified claim, a gap it couldn't fill, or a hedged number, carry that to the user instead of smoothing it over. Keep your own messages short; let the work speak.++# Notes++- Don't fabricate links, quotes, statistics, or handles. If you don't have something, say so and ask.+- Don't promise work no specialist on the team can do. When a request needs a tool or an integration that isn't wired up, say that plainly instead of producing a plausible-looking substitute.+`,+ ),+ file(+ "agent/subagents/content-marketer/agent.ts",+ "typescript",+ `import { defineAgent } from "eve";++// Subagent: Content Marketer++export default defineAgent({+ compaction: { thresholdPercent: 0.9 },+ description:+ "Write and edit long-form marketing content: blog posts, landing page copy, case studies, newsletters, and documentation. Plans what to write by mapping topics to buyer stages and grouping them into pillars and clusters, then drafts and edits against a structured editing rubric. Use for anything longer than a social post. When the piece is written to be found in search, the target query and the competing pages should be settled before drafting. Delivers the finished piece as a Notion page and hands back the link rather than the full text, since long-form doesn't read in a chat thread. The caller passes the brief, the audience, the format, any source material or brand context, and the Notion destination when it knows one, in the message. Does not publish, schedule, or touch social accounts.",+ model: "anthropic/claude-opus-5",+});+`,+ ),+ file(+ "agent/subagents/email/agent.ts",+ "typescript",+ `import { defineAgent } from "eve";++// Subagent: Email++export default defineAgent({+ compaction: { thresholdPercent: 0.9 },+ description:+ "Own email as a channel: take copy that already exists and make it work as email, then build and run it in Resend. Reviews a draft for email fit (subject and preview text, one call to action, scannable structure, a plain text version, link and image hygiene), then builds the template or broadcast, picks the verified sending address, targets the segment, and reports on what was delivered and opened. Sending a broadcast or an email pauses for approval. Checks the sending domain's own records and says which deliverability questions it cannot answer. Route long-form prose to the content marketer first and pass what came back to this agent. The caller passes the copy or its artifact id, the audience or segment, and any send timing in the message.",+ model: "anthropic/claude-opus-5",+});+`,+ ),+ file(+ "agent/subagents/product-marketer/agent.ts",+ "typescript",+ `import { defineAgent } from "eve";++// Subagent: Product Marketer++export default defineAgent({+ compaction: { thresholdPercent: 0.9 },+ description:+ "Work out and write down what the product is, who it's for, and why anyone would pick it: positioning, the competitive alternatives, the ideal customer, the message hierarchy, value propositions per audience, objection handling, and the proof behind each claim. Owns the team's shared brand context document, so use it to set that up on a fresh install, to revise positioning, or when other specialists keep guessing at the same missing detail. Interviews the user and researches the competitive set rather than inventing an answer, and writes claims that can be checked. Does not draft posts, pages, or campaigns.",+ model: "anthropic/claude-opus-5",+});+`,+ ),+ file(+ "agent/subagents/seo/agent.ts",+ "typescript",+ `import { defineAgent } from "eve";++// Subagent: SEO++export default defineAgent({+ compaction: { thresholdPercent: 0.9 },+ description:+ "Plan and review organic search work: keyword and topic strategy, on-page review of a URL, site architecture and internal linking, URL structure, JSON-LD schema markup, and programmatic page templates at scale. Use when someone asks why a page isn't ranking, what pages they should build, for a review of a page's SEO, or for the schema markup on a page. Also use before a piece is written for search, so the query and the competing pages are settled before someone drafts against them. Reads pages it is given with web_fetch and researches competitors on the open web, so it reports what a fetched page shows and says plainly what needs crawler or Search Console access it doesn't have. Recommends title tags, meta descriptions, and URL slugs; hand body copy to the content marketer. The caller passes the URLs, the target keywords, the audience, and any brand context in the message.",+ model: "anthropic/claude-opus-5",+});+`,+ ),+ file(+ "agent/subagents/social-media-coordinator/agent.ts",+ "typescript",+ `import { defineAgent } from "eve";++// Subagent: Social Media Coordinator++export default defineAgent({+ compaction: { thresholdPercent: 0.9 },+ description:+ "Run social media work end to end for X, LinkedIn, Threads, Bluesky, and Mastodon: draft posts and threads in each platform's voice, adapt one piece across platforms, and manage the Typefully queue (read, create, and edit drafts, schedule on request, pull post and follower analytics). Researches facts and reviews its own drafts before handing them back. The caller passes the brief or source material, the target platforms, and any angle, audience, or timing constraints in the message.",+ model: "anthropic/claude-opus-5",+});`,),],