diff --git a/examples/agents/marketing-outreach-email-agent/.env.baseai.example b/examples/agents/marketing-outreach-email-agent/.env.baseai.example new file mode 100644 index 00000000..8c643651 --- /dev/null +++ b/examples/agents/marketing-outreach-email-agent/.env.baseai.example @@ -0,0 +1,21 @@ +# !! SERVER SIDE ONLY !! +# Keep all your API keys secret — use only on the server side. + +# TODO: ADD: Both in your production and local env files. +# Langbase API key for your User or Org account. +# How to get this API key https://langbase.com/docs/api-reference/api-keys +LANGBASE_API_KEY= + +# TODO: ADD: LOCAL ONLY. Add only to local env files. +# Following keys are needed for local pipe runs. For providers you are using. +# For Langbase, please add the key to your LLM keysets. +# Read more: Langbase LLM Keysets https://langbase.com/docs/features/keysets +OPENAI_API_KEY= +ANTHROPIC_API_KEY= +COHERE_API_KEY= +FIREWORKS_API_KEY= +GOOGLE_API_KEY= +GROQ_API_KEY= +MISTRAL_API_KEY= +PERPLEXITY_API_KEY= +TOGETHER_API_KEY= diff --git a/examples/agents/marketing-outreach-email-agent/.gitignore b/examples/agents/marketing-outreach-email-agent/.gitignore new file mode 100644 index 00000000..9b5994f6 --- /dev/null +++ b/examples/agents/marketing-outreach-email-agent/.gitignore @@ -0,0 +1,9 @@ +# baseai +**/.baseai/ +node_modules +.env +package-lock.json +pnpm-lock.yaml +# env file +.env + diff --git a/examples/agents/marketing-outreach-email-agent/README.md b/examples/agents/marketing-outreach-email-agent/README.md new file mode 100644 index 00000000..5172319e --- /dev/null +++ b/examples/agents/marketing-outreach-email-agent/README.md @@ -0,0 +1,53 @@ +![Marketing Outreach Email Agent by ⌘ BaseAI][cover] + +![License: MIT][mit] [![Fork on ⌘ Langbase][fork]][pipe] + +## Build a Marketing Outreach Email Agent with BaseAI framework — ⌘ Langbase + +This AI Agent is built using the BaseAI framework. It leverages an agentic pipe that integrates over 30+ LLMs (including OpenAI, Gemini, Mistral, Llama, Gemma, etc.) and can handle any data, with context sizes of up to 10M+ tokens, supported by memory. The framework is compatible with any front-end framework (such as React, Remix, Astro, Next.js), giving you, as a developer, the freedom to tailor your AI application exactly as you envision. + +## Features + +- Marketing Outreach Email Agent — Built with [BaseAI framework and agentic Pipe ⌘ ][qs]. +- Composable Agents — build and compose agents with BaseAI. +- Add and Sync deployed pipe on Langbase locally npx baseai@latest add ([see the Code button][pipe]). + +## Learn more + +1. Check the [Learning path to build an agentic AI pipe with ⌘ BaseAI][learn] +2. Read the [source code on GitHub][gh] for this agent example +3. Go through Documentaion: [Pipe Quick Start][qs] +4. Learn more about [Memory features in ⌘ BaseAI][memory] +5. Learn more about [Tool calls support in ⌘ BaseAI][toolcalls] + + +> NOTE: +> This is a BaseAI project, you can deploy BaseAI pipes, memory and tool calls on Langbase. + +--- + +## Authors + +This project is created by [Langbase][lb] team members, with contributions from: + +- Muhammad-Ali Danish - Software Engineer, [Langbase][lb]
+**_Built by ⌘ [Langbase.com][lb] — Ship hyper-personalized AI assistants with memory!_** + + +[lb]: https://langbase.com +[pipe]: https://langbase.com/examples/marketing-outreach-email-agent +[gh]: https://github.com/LangbaseInc/baseai/tree/main/examples/agents/marketing-outreach-email-agent +[cover]:https://raw.githubusercontent.com/LangbaseInc/docs-images/main/baseai/baseai-cover.png +[download]:https://download-directory.github.io/?url=https://github.com/LangbaseInc/baseai/tree/main/examples/marketing-outreach-email-agent +[learn]:https://baseai.dev/learn +[memory]:https://baseai.dev/docs/memory/quickstart +[toolcalls]:https://baseai.dev/docs/tools/quickstart +[deploy]:https://baseai.dev/docs/deployment/authentication +[signup]: https://langbase.fyi/io +[qs]:https://baseai.dev/docs/pipe/quickstart +[docs]:https://baseai.dev/docs +[xaa]:https://x.com/MrAhmadAwais +[xab]:https://x.com/AhmadBilalDev +[local]:http://localhost:9000 +[mit]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge&color=%23000000 +[fork]: https://img.shields.io/badge/FORK%20ON-%E2%8C%98%20Langbase-000000.svg?style=for-the-badge&logo=%E2%8C%98%20Langbase&logoColor=000000 \ No newline at end of file diff --git a/examples/agents/marketing-outreach-email-agent/baseai/baseai.config.ts b/examples/agents/marketing-outreach-email-agent/baseai/baseai.config.ts new file mode 100644 index 00000000..3c0328bc --- /dev/null +++ b/examples/agents/marketing-outreach-email-agent/baseai/baseai.config.ts @@ -0,0 +1,18 @@ +import type { BaseAIConfig } from 'baseai'; + +export const config: BaseAIConfig = { + log: { + isEnabled: false, + logSensitiveData: false, + pipe: true, + 'pipe.completion': true, + 'pipe.request': true, + 'pipe.response': true, + tool: true, + memory: true + }, + memory: { + useLocalEmbeddings: false + }, + envFilePath: '.env' +}; diff --git a/examples/agents/marketing-outreach-email-agent/baseai/pipes/marketing-outreach-email-agent.ts b/examples/agents/marketing-outreach-email-agent/baseai/pipes/marketing-outreach-email-agent.ts new file mode 100644 index 00000000..ca330032 --- /dev/null +++ b/examples/agents/marketing-outreach-email-agent/baseai/pipes/marketing-outreach-email-agent.ts @@ -0,0 +1,42 @@ +import { PipeI } from '@baseai/core'; + +const pipeMarketingOutreachEmailAgent = (): PipeI => ({ + // Replace with your API key https://langbase.com/docs/api-reference/api-keys + apiKey: process.env.LANGBASE_API_KEY!, + name: `marketing-outreach-email-agent`, + description: ``, + status: `private`, + model: `openai:gpt-4o-mini`, + stream: true, + json: false, + store: true, + moderate: true, + top_p: 1, + max_tokens: 1000, + temperature: 0.7, + presence_penalty: 0, + frequency_penalty: 0, + stop: [], + tool_choice: 'auto', + parallel_tool_calls: true, + messages: [ + { + role: 'system', + content: + 'You are an AI-powered email assistant whose primary task is to help users create personalized outreach emails. You will gather key information from the user in a single step to generate a well-crafted, professional outreach email based on their selected segment.\n\n## Role Definition:\n- You are an expert in writing outreach emails for purposes such as sales, partnerships, recruitment, event invitations, and more.\n- In one step, ask the user to select an email segment and provide all necessary information: Personalization, Value Proposition, Call to Action (CTA), and an optional additional element for further personalization.\n- The email should be concise, engaging, and tailored to the specific recipient.\n- if the user ask for example in a specific segment you present the user with the example according to Guidelines.\n\n\n## Guidelines:\n\n### Single-Step Question:\nAsk the user to select a segment and provide answers to all the required email components in one go. The email will require:\n1. **Personalization**: Information about the recipient (name, company, specific interest).\n2. **Value Proposition**: The unique benefit or solution the product/service offers.\n3. **Call to Action (CTA)**: What action the user wants the recipient to take.\n4. **Optional Element**: Any additional detail for customization, such as referencing a mutual connection, industry trend, or a relevant question to engage the recipient.\n\n**Example Prompt**: \n"Hi there! I\'m here to help you create a personalized outreach email. Please provide the following information in one go:\n1. Select the type of outreach email you want to send: \n 1. Sales and Lead Generation \n 2. Partnerships and Collaborations \n 3. Event Invitations \n 4. Recruitment \n 5. Public Relations (PR) \n 6. Customer Retention and Engagement \n 7. Networking \n 8. Fundraising\n\n2. Personalization: What is the recipient’s name, company, or a specific detail you’d like to mention? \n3. Value Proposition: What unique benefit or value does your product or service provide? \n4. Call to Action (CTA): What action do you want the recipient to take (e.g., schedule a call, book a demo)? \n5. Optional: Would you like to add any extra detail to make the email more engaging (e.g., shared connection, recent industry trend)?"\n\n---\n\n### **Generate the Final Email**:\nOnce the user provides their input, craft the email following this structure:\n- **Subject**: Incorporate the personalization or value proposition.\n- **Body**:\n - **Introduction**: Greet the recipient and reference something personal (name, company, industry).\n - **Value Proposition**: Describe how the product/service provides value or solves their problem.\n - **Call to Action**: Specify the next step you want the recipient to take.\n - **Optional Element**: Include the additional customization provided by the user to make the email more engaging.\n - **Signature**: Include the user’s name, company, and contact details.\n\n**Example Email Structure**: \n---\n**Subject**: {Personalized Greeting} - Here’s how we can help {Recipient’s Company} achieve {specific benefit}\n\nHi {Recipient’s Name},\n\nI’ve been following {Company Name\'s} work in {industry/field} and wanted to reach out with a solution that can help you {specific benefit}. Our {product/service} offers {describe solution or value} that could be a game-changer for your team.\n\nWould you be open to scheduling a quick call next week to discuss how we can help?\n\nBy the way, I noticed {extra detail from the optional element, such as a mutual connection or industry trend}. I’d love to hear your thoughts on that.\n\nBest regards, \n{Your Name} \n{Your Company} \n{Contact Information}\n\n---\n\n### **Final Feedback**:\nOnce the email is generated, ask the user if they would like to make any final adjustments before finalizing.\n\n**Example Prompt**: \n"Here’s your outreach email based on the information you provided. Would you like to make any changes or adjustments before finalizing?"\n' + }, + { name: 'json', role: 'system', content: '' }, + { name: 'safety', role: 'system', content: '' }, + { + name: 'opening', + role: 'system', + content: 'Welcome to Langbase. Prompt away!' + }, + { name: 'rag', role: 'system', content: '' } + ], + variables: [], + tools: [], + memory: [] +}); + +export default pipeMarketingOutreachEmailAgent; diff --git a/examples/agents/marketing-outreach-email-agent/index.ts b/examples/agents/marketing-outreach-email-agent/index.ts new file mode 100644 index 00000000..2c9bdbab --- /dev/null +++ b/examples/agents/marketing-outreach-email-agent/index.ts @@ -0,0 +1,57 @@ +import 'dotenv/config'; +import { Pipe } from '@baseai/core'; +import inquirer from 'inquirer'; +import ora from 'ora'; +import chalk from 'chalk'; +import pipeMarketingOutreachEmailAgent from './baseai/pipes/marketing-outreach-email-agent'; + + +const pipe = new Pipe(pipeMarketingOutreachEmailAgent()); + +async function main() { + + const initialSpinner = ora('Connecting with marketing-outreach-email-agent ...').start(); + try { + const { completion: initialMarketingEmailAgent } = await pipe.run({ + messages: [{ role: 'user', content: 'How can I use your services, give me an example from Fundraising segment?' }], + }); + initialSpinner.stop(); + console.log(chalk.cyan('Agent response...')); + console.log(initialMarketingEmailAgent); + } catch (error) { + initialSpinner.stop(); + console.error(chalk.red('Error processing initial request:'), error); + } + + while (true) { + const { userMsg } = await inquirer.prompt([ + { + type: 'input', + name: 'userMsg', + message: chalk.blue('Enter your query (or type "exit" to quit):'), + }, + ]); + + if (userMsg.toLowerCase() === 'exit') { + console.log(chalk.green('Goodbye!')); + break; + } + + const spinner = ora('Processing your request...').start(); + + try { + const { completion: marketingEmailAgent } = await pipe.run({ + messages: [{ role: 'user', content: userMsg }], + }); + + spinner.stop(); + console.log(chalk.cyan('Agent:')); + console.log(marketingEmailAgent); + } catch (error) { + spinner.stop(); + console.error(chalk.red('Error processing your request:'), error); + } + } +} + +main(); \ No newline at end of file diff --git a/examples/agents/marketing-outreach-email-agent/package.json b/examples/agents/marketing-outreach-email-agent/package.json new file mode 100644 index 00000000..f9fcb926 --- /dev/null +++ b/examples/agents/marketing-outreach-email-agent/package.json @@ -0,0 +1,22 @@ +{ + "name": "marketing-outreach-email-agent", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "baseai": "baseai" + }, + "keywords": [], + "author": "", + "license": "ISC", + "description": "", + "dependencies": { + "@baseai/core": "^0.9.3", + "dotenv": "^16.4.5", + "inquirer": "^12.0.0", + "ora": "^8.1.0" + }, + "devDependencies": { + "baseai": "^0.9.3" + } +}