Skip to content

Commit b6680af

Browse files
authored
Merge pull request #6 from Cooops/coopes/adding_email_automation
Coopes/adding email automation
2 parents 137707a + 08aeb88 commit b6680af

35 files changed

+3402
-1
lines changed

.env.example

+9
Original file line numberDiff line numberDiff line change
@@ -553,3 +553,12 @@ AKASH_MANIFEST_VALIDATION_LEVEL=strict
553553
# Quai Network Ecosystem
554554
QUAI_PRIVATE_KEY=
555555
QUAI_RPC_URL=https://rpc.quai.network
556+
557+
# Email
558+
RESEND_API_KEY= # Your Resend API key
559+
DEFAULT_TO_EMAIL= # Default recipient
560+
DEFAULT_FROM_EMAIL= # Default sender
561+
562+
# Optional Settings
563+
EMAIL_AUTOMATION_ENABLED=false # Enable AI detection. If this is enabled, the plugin will automatically detect email-worthy conversations and handle generation/delivery and only that.
564+
EMAIL_EVALUATION_PROMPT= # Custom detection criteria for shouldEmail

agent/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"@elizaos/plugin-hyperliquid": "workspace:*",
9393
"@elizaos/plugin-akash": "workspace:*",
9494
"@elizaos/plugin-quai": "workspace:*",
95+
"@elizaos/plugin-email-automation": "workspace:*",
9596
"readline": "1.3.0",
9697
"ws": "8.18.0",
9798
"yargs": "17.7.2"

agent/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ import { teeLogPlugin } from "@elizaos/plugin-tee-log";
8585
import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin";
8686
import { tonPlugin } from "@elizaos/plugin-ton";
8787
import { webSearchPlugin } from "@elizaos/plugin-web-search";
88+
import { emailPlugin } from "@elizaos/plugin-email-automation";
8889

8990
import { giphyPlugin } from "@elizaos/plugin-giphy";
9091
import { letzAIPlugin } from "@elizaos/plugin-letzai";
@@ -786,6 +787,7 @@ export async function createAgent(
786787
character,
787788
// character.plugins are handled when clients are added
788789
plugins: [
790+
getSecret(character, "EMAIL_AUTOMATION_ENABLED") ? emailPlugin : null,
789791
bootstrapPlugin,
790792
getSecret(character, "CONFLUX_CORE_PRIVATE_KEY")
791793
? confluxPlugin

docs/static/img/main.png

801 KB
Loading

packages/core/src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,7 @@ export enum ServiceType {
14581458
IRYS = "irys",
14591459
TEE_LOG = "tee_log",
14601460
GOPLUS_SECURITY = "goplus_security",
1461+
EMAIL_AUTOMATION = "email_automation",
14611462
}
14621463

14631464
export enum LoggingLevel {

packages/plugin-depin/src/actions/sentientai.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const sentientAI: Action = {
1313
"NEWS",
1414
"WEATHER"
1515
],
16-
description: "Provde realtime information for Weather, News.",
16+
description: "Provide realtime information for Weather, News.",
1717
examples: [
1818
[
1919
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Required Configuration
2+
RESEND_API_KEY= # Required: Your Resend API key
3+
DEFAULT_TO_EMAIL= # Required: Default recipient email
4+
DEFAULT_FROM_EMAIL= # Required: Email address to send from
5+
6+
# Email Automation Settings
7+
EMAIL_AUTOMATION_ENABLED= # Optional: true/false (default: false)
8+
9+
# Custom Prompts
10+
EMAIL_EVALUATION_PROMPT= # Optional: Custom prompt for deciding when to send emails
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*
2+
3+
!dist/**
4+
!package.json
5+
!readme.md
6+
!tsup.config.ts
7+
8+
src/
9+
tsconfig.json
10+
.eslintrc.js
11+
.prettierrc
+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# @elizaos/plugin-email-automation
2+
3+
AI-powered email automation plugin for Eliza that intelligently detects email-worthy conversations and handles generation/delivery. This is not perfect and is simply a solid starting point, and I would encourage any and all contributions!
4+
5+
## Features
6+
7+
### 1. Intelligent Detection
8+
- Partnership opportunity detection
9+
- Technical discussion recognition
10+
- Business proposal identification
11+
- Follow-up requirement analysis
12+
13+
### 2. AI-Powered Generation
14+
- Structured email formatting
15+
- Context-aware content
16+
- Professional tone maintenance
17+
- Technical detail inclusion
18+
19+
## Configuration
20+
21+
### AI Email Automation Setup
22+
```typescript
23+
# Required
24+
RESEND_API_KEY= # Your Resend API key
25+
DEFAULT_TO_EMAIL= # Default recipient
26+
DEFAULT_FROM_EMAIL= # Default sender
27+
28+
# Optional Settings
29+
EMAIL_AUTOMATION_ENABLED=true # Enable AI detection. If this is enabled, the plugin will automatically detect email-worthy conversations and handle generation/delivery and only that.
30+
EMAIL_EVALUATION_PROMPT= # Custom detection criteria for shouldEmail
31+
```
32+
33+
### Basic Usage
34+
```typescript
35+
import { emailPlugin } from '@elizaos/plugin-email-automation';
36+
37+
// Add to your Eliza configuration
38+
{
39+
plugins: [emailPlugin],
40+
settings: {
41+
EMAIL_AUTOMATION_ENABLED: true,
42+
// ... other settings
43+
}
44+
}
45+
```
46+
47+
### Email Template Example
48+
The plugin uses Handlebars for templating. Here's an example output:
49+
50+
```handlebars
51+
{{!-- email-template.hbs --}}
52+
<div class="email-container">
53+
<h1>{{subject}}</h1>
54+
55+
<div class="background-section">
56+
{{background}}
57+
</div>
58+
59+
<div class="key-points-section">
60+
<h2>Key Points</h2>
61+
<ul>
62+
{{#each keyPoints}}
63+
<li>{{this}}</li>
64+
{{/each}}
65+
</ul>
66+
</div>
67+
68+
{{#if technicalDetails}}
69+
<div class="technical-section">
70+
<h2>Technical Details</h2>
71+
<ul>
72+
{{#each technicalDetails}}
73+
<li>{{this}}</li>
74+
{{/each}}
75+
</ul>
76+
</div>
77+
{{/if}}
78+
79+
<div class="next-steps-section">
80+
<h2>Next Steps</h2>
81+
<ul>
82+
{{#each nextSteps}}
83+
<li>{{this}}</li>
84+
{{/each}}
85+
</ul>
86+
</div>
87+
88+
<div class="footer">
89+
Powered by ElizaOS
90+
</div>
91+
</div>
92+
93+
<style>
94+
.email-container {
95+
max-width: 600px;
96+
margin: 0 auto;
97+
font-family: Arial, sans-serif;
98+
line-height: 1.6;
99+
}
100+
h1, h2 { color: #333; }
101+
ul { padding-left: 20px; }
102+
.footer {
103+
margin-top: 30px;
104+
color: #666;
105+
font-size: 0.9em;
106+
}
107+
</style>
108+
```
109+
110+
This template produces professional emails like the example shown in the image above. You can customize the template by:
111+
1. Creating your own `.hbs` file
112+
2. Registering it with the template manager
113+
3. Specifying your template when sending emails
114+
115+
## Development
116+
117+
```bash
118+
# Installation
119+
pnpm install
120+
121+
# Testing
122+
pnpm test
123+
pnpm test:watch
124+
pnpm test:coverage
125+
126+
# Building
127+
pnpm build
128+
```
129+
130+
## Testing Coverage
131+
- Unit tests for all services
132+
- Integration tests for end-to-end flows
133+
- Throttling and rate limiting tests
134+
- Error handling scenarios
135+
- Mock providers for testing
136+
137+
## Architecture
138+
```mermaid
139+
graph TD
140+
A[Email Trigger] --> B[Automation Service]
141+
B --> C{AI Evaluation}
142+
C -->|Yes| D[Generation Service]
143+
D --> E[Email Service]
144+
E --> F[Resend Provider]
145+
F --> G[Delivery]
146+
```
147+
148+
Architecture Overview:
149+
- Resend Provider support (more to come)
150+
- AI-powered email detection
151+
- Context-aware content generation
152+
- Professional template rendering
153+
154+
## Credits
155+
156+
This plugin integrates with and builds upon:
157+
158+
- [Resend](https://resend.com): Modern email API for developers
159+
- [Handlebars](https://handlebarsjs.com): Templating engine for email formatting
160+
161+
For more information about Resend capabilities:
162+
- [Resend Documentation](https://resend.com/docs)
163+
- [Email API Reference](https://resend.com/docs/api-reference/introduction)
164+
- [Developer Portal](https://resend.com/overview)
165+
166+
## License
167+
This plugin is part of the Eliza project. See the main project repository for license information.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"name": "@elizaos/plugin-email-automation",
3+
"version": "0.1.0",
4+
"description": "AI-powered email automation plugin for Eliza",
5+
"type": "module",
6+
"main": "./dist/index.js",
7+
"module": "./dist/index.js",
8+
"types": "./dist/index.d.ts",
9+
"files": [
10+
"dist"
11+
],
12+
"scripts": {
13+
"build": "tsc --declaration --emitDeclarationOnly false --noEmit false --allowImportingTsExtensions false",
14+
"clean": "rimraf dist",
15+
"dev": "tsc -w",
16+
"lint": "eslint src --ext .ts",
17+
"test": "vitest run",
18+
"test:watch": "vitest",
19+
"test:coverage": "vitest run --coverage"
20+
},
21+
"dependencies": {
22+
"@elizaos/core": "workspace:*",
23+
"handlebars": "^4.7.8",
24+
"resend": "^2.0.0",
25+
"zod": "^3.22.4"
26+
},
27+
"devDependencies": {
28+
"@types/jest": "^29.0.0",
29+
"@types/node": "^20.0.0",
30+
"jest": "^29.0.0",
31+
"rimraf": "^5.0.0",
32+
"ts-jest": "^29.0.0",
33+
"typescript": "^5.0.0",
34+
"vitest": "^2.1.8"
35+
},
36+
"jest": {
37+
"preset": "ts-jest",
38+
"testEnvironment": "node",
39+
"moduleNameMapper": {
40+
"^(\\.{1,2}/.*)\\.js$": "$1",
41+
"^@elizaos/core$": "<rootDir>/../core/dist"
42+
},
43+
"transform": {
44+
"^.+\\.(ts|tsx)$": "ts-jest"
45+
},
46+
"testMatch": [
47+
"**/__tests__/**/*.test.(ts|js)"
48+
],
49+
"moduleFileExtensions": [
50+
"ts",
51+
"tsx",
52+
"js",
53+
"jsx",
54+
"json",
55+
"node"
56+
]
57+
}
58+
}

0 commit comments

Comments
 (0)