{"id":29127122,"url":"https://github.com/danieladdisonorg/email-marketing-ai-agent","last_synced_at":"2025-06-30T00:09:04.594Z","repository":{"id":300844134,"uuid":"1006534534","full_name":"danieladdisonorg/email-marketing-ai-agent","owner":"danieladdisonorg","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-23T21:52:24.000Z","size":17,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-23T22:41:01.462Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danieladdisonorg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-22T13:42:10.000Z","updated_at":"2025-06-23T22:11:49.000Z","dependencies_parsed_at":"2025-06-23T22:41:05.248Z","dependency_job_id":"66ca001a-e8e8-41d2-9d33-5002c6c7cda0","html_url":"https://github.com/danieladdisonorg/email-marketing-ai-agent","commit_stats":null,"previous_names":["danieladdisonorg/email-marketing-ai-agent"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danieladdisonorg/email-marketing-ai-agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieladdisonorg%2Femail-marketing-ai-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieladdisonorg%2Femail-marketing-ai-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieladdisonorg%2Femail-marketing-ai-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieladdisonorg%2Femail-marketing-ai-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danieladdisonorg","download_url":"https://codeload.github.com/danieladdisonorg/email-marketing-ai-agent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danieladdisonorg%2Femail-marketing-ai-agent/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262685699,"owners_count":23348452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-30T00:09:03.841Z","updated_at":"2025-06-30T00:09:04.571Z","avatar_url":"https://github.com/danieladdisonorg.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Email Marketing AI Agent\r\n\r\n## System Architecture Diagram\r\n\r\n```\r\n┌─────────────────────────────────────────────────────────────────────────────────────┐\r\n│                           EMAIL MARKETING AI AGENT WORKFLOW                         │\r\n└─────────────────────────────────────────────────────────────────────────────────────┘\r\n\r\n┌──────────────────┐    ┌──────────────────┐    ┌──────────────────┐\r\n│   Data Sources   │    │   AI Processing  │    │   Output Systems │\r\n└──────────────────┘    └──────────────────┘    └──────────────────┘\r\n\r\n┌─────────────────────────────────────────────────────────────────────────────────────┐\r\n│                                STEP 1: DATA COLLECTION                              │\r\n└─────────────────────────────────────────────────────────────────────────────────────┘\r\n\r\n    ┌─────────────┐         ┌─────────────┐         ┌─────────────┐\r\n    │   Zoho CRM  │ ──────▶│ get_emails  │────────▶│ zoho_emails │\r\n    │ (Existing   │         │    .py      │         │   .csv      │\r\n    │ Customers)  │         │             │         │             │\r\n    └─────────────┘         └─────────────┘         └─────────────┘\r\n                                   │\r\n    ┌─────────────┐                │                 ┌─────────────┐\r\n    │ prospects   │                │                 │ Google      │\r\n    │   .csv      │────────────────┼───────────────▶│ Sheets      │\r\n    │ (New Leads) │                │                 │ (Email DB)  │\r\n    └─────────────┘                │                 └─────────────┘\r\n                                   ▼\r\n                            ┌─────────────┐\r\n                            │   Domain    │\r\n                            │ Comparison  │\r\n                            │  Analysis   │\r\n                            └─────────────┘\r\n\r\n┌─────────────────────────────────────────────────────────────────────────────────────┐\r\n│                           STEP 2: AI EMAIL GENERATION                               │\r\n└─────────────────────────────────────────────────────────────────────────────────────┘\r\n\r\n    ┌─────────────┐         ┌─────────────┐         ┌─────────────┐\r\n    │   Domain    │   YES   │ Personalized│         │   OpenAI    │\r\n    │   Match?    │────────▶│   Email     │───────▶│   GPT-4     │\r\n    │             │         │ Generation  │         │             │\r\n    └─────────────┘         └─────────────┘         └─────────────┘\r\n           │                                               │\r\n           │ NO                                            │\r\n           ▼                                               ▼\r\n    ┌─────────────┐         ┌─────────────┐         ┌─────────────┐\r\n    │  Generic    │         │   Email     │         │ Generated   │\r\n    │   Email     │────────▶│ Templates   │───────▶│ Email with  │\r\n    │ Generation  │         │             │         │ Tracking    │\r\n    └─────────────┘         └─────────────┘         └─────────────┘\r\n\r\n┌─────────────────────────────────────────────────────────────────────────────────────┐\r\n│                         STEP 3: EMAIL SENDING \u0026 TRACKING                            │\r\n└─────────────────────────────────────────────────────────────────────────────────────┘\r\n\r\n    ┌─────────────┐         ┌─────────────┐         ┌─────────────┐\r\n    │ Google      │         │ Google Apps │         │   Email     │\r\n    │ Sheets      │────────▶│   Script    │───────▶│ Recipients  │\r\n    │ (Email DB)  │         │ (Sender)    │         │             │\r\n    └─────────────┘         └─────────────┘         └─────────────┘\r\n                                   │                        │\r\n                                   │                        │\r\n                                   ▼                        ▼\r\n                            ┌─────────────┐         ┌─────────────┐\r\n                            │  Tracking   │◀───────│   Email     │\r\n                            │   Pixel     │         │   Opens     │\r\n                            │  (Web App)  │         │             │\r\n                            └─────────────┘         └─────────────┘\r\n                                   │\r\n                                   ▼\r\n                            ┌─────────────┐\r\n                            │ Update Open │\r\n                            │ Count in    │\r\n                            │ Sheets      │\r\n                            └─────────────┘\r\n\r\n┌─────────────────────────────────────────────────────────────────────────────────────┐\r\n│                      STEP 4: ENGAGEMENT ANALYSIS \u0026 FOLLOW-UP                        │\r\n└─────────────────────────────────────────────────────────────────────────────────────┘\r\n\r\n    ┌─────────────┐         ┌─────────────┐         ┌─────────────┐\r\n    │ Email Opens │         │   Opens     │   YES   │ AI Call     │\r\n    │ Monitoring  │───────▶│   \u003e 5?      │────────▶│ Script      │\r\n    │             │         │             │         │ Generation  │\r\n    └─────────────┘         └─────────────┘         └─────────────┘\r\n                                   │                        │\r\n                                   │ NO                     │\r\n                                   ▼                        ▼\r\n                            ┌─────────────┐         ┌─────────────┐\r\n                            │ Continue    │         │ Upload to   │\r\n                            │ Monitoring  │         │ Call Script │\r\n                            │             │         │   Sheet     │\r\n                            └─────────────┘         └─────────────┘\r\n                                                           │\r\n                                                           ▼\r\n                                                    ┌─────────────┐\r\n                                                    │ Upload to   │\r\n                                                    │ Zoho CRM    │\r\n                                                    │ (Lead Data) │\r\n                                                    └─────────────┘\r\n\r\n┌─────────────────────────────────────────────────────────────────────────────────────┐\r\n│                              SYSTEM COMPONENTS                                      │\r\n└─────────────────────────────────────────────────────────────────────────────────────┘\r\n\r\n┌─────────────┐  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐\r\n│ Python      │  │ Google Apps │  │ Google      │  │ OpenAI      │  │ Zoho CRM    │\r\n│ Scripts     │  │ Script      │  │ Sheets API  │  │ GPT-4 API   │  │ API         │\r\n│             │  │             │  │             │  │             │  │             │\r\n│• get_emails │  │• Email      │  │• Data       │  │• Email      │  │• Customer   │\r\n│• clean_and_ │  │  Sending    │  │  Storage    │  │  Generation │  │  Data       │\r\n│  gen_call_  │  │• Tracking   │  │• Open       │  │• Call       │  │• Lead       │\r\n│  script     │  │  Pixel      │  │  Logging    │  │  Scripts    │  │  Management │\r\n└─────────────┘  └─────────────┘  └─────────────┘  └─────────────┘  └─────────────┘\r\n\r\n┌─────────────────────────────────────────────────────────────────────────────────────┐\r\n│                                 KEY FEATURES                                        │\r\n└─────────────────────────────────────────────────────────────────────────────────────┘\r\n\r\n✅ Multi-alias email sending\r\n✅ Real-time open tracking with hidden pixels\r\n✅ AI-powered personalized email generation\r\n✅ Automatic call script creation for high-engagement leads\r\n✅ Integration with Zoho CRM and Google Workspace\r\n✅ Domain-based customer relationship detection\r\n✅ Automated lead scoring and follow-up prioritization\r\n```\r\n\r\nThis diagram shows the complete workflow of your email marketing AI agent, from data collection through AI-powered email generation, tracking, and automated follow-up. The system intelligently personalizes emails based on existing customer relationships and automatically generates call scripts for highly engaged prospects.\r\n\r\n\r\n## Demo Video For Email Tracking\r\nhttps://github.com/user-attachments/assets/74bcf609-1499-41e9-b3cb-a3f01ba4bc1a\r\n\r\n## Repository Structure\r\n```text\r\napp_script_email_automation/\r\n├── README.md\r\n├── requirements.txt\r\n└── src/\r\n    ├── app_script.js                 (Main Apps Script code)\r\n    ├── credentials.json              (Credentials for external services)\r\n    ├── get_emails.py                 (Fetches and uploads email data to Sheets)\r\n    ├── clean_and_gen_call_script.py  (Cleans data \u0026 triggers call script creation)\r\n    └── functions/\r\n        ├── agent.py                 (AI-related logic)\r\n        ├── config.py                (Configuration \u0026 constants)\r\n        ├── create_call_script.py    (Generates call scripts)\r\n        ├── create_email.py          (Builds email content)\r\n        └── utlis.py                 (Utility functions)\r\n```\r\n\r\n## Features\r\n- Send emails from multiple aliases.\r\n- Track opens with a web app and hidden pixel.\r\n- Log open counts and timestamps in Google Sheets.\r\n- Dynamically generate call scripts for emails exceeding five opens.\r\n- Append generated scripts to a separate Sheet for follow-up actions.\r\n\r\n## Getting Started\r\n1. **Set Up Google Sheets**: Create or update source/destination Sheets for email list and lead data.  \r\n2. **Deploy Web App**: Host the code in Google Apps Script and enable the web endpoint for open tracking.  \r\n3. **Configure Credentials**: Store any required credentials for third-party services (e.g., OpenAI API).  \r\n4. **Run \u0026 Track**: Send emails, check open stats, and watch new call scripts appear in the leads Sheet.\r\n\r\n## Project Setup\r\n1. **Clone the Repository**  \r\n``` bash\r\n      git clone https://github.com/danieladdisonorg/email-marketing-ai-agent.git\r\n```\r\n``` bash\r\n      cd email-marketing-ai-agent\r\n```\r\n2. **Create Environment File (.env)**  \r\n   - Add your OpenAI API key and other credentials.  \r\n   - Copy and paste the following into your `.env` file, replacing the placeholder values with your actual keys:\r\n\r\n   ```env\r\n   OPENAI_API_KEY=your_key_here\r\n   SHEET_API_KEY=your_sheet_key_here\r\n   ```\r\n\r\n3. **Install Dependencies**  \r\n   - In local Python projects, run:  \r\n     pip install -r requirements.txt  \r\n\r\n4. **Create or Update config.py**  \r\n   Place this file under `src/helpers/` and store your credentials, Sheet IDs, and any other constants.  \r\n   For example:\r\n\r\n   ```python\r\n   email_google_sheet = \"YOUR_EMAIL_SHEET_ID\"\r\n   call_script_google_sheet = \"YOUR_CALL_SCRIPT_SHEET_ID\"\r\n   CLIENT_ID = \"YOUR_ZOHO_CLIENT_ID\"\r\n   CLIENT_SECRET = \"YOUR_ZOHO_CLIENT_SECRET\"\r\n   REFRESH_TOKEN = \"YOUR_ZOHO_REFRESH_TOKEN\"\r\n   ZOHO_API_BASE_URL = \"https://www.zohoapis.com/crm/v2\"\r\n   TOKEN_URL = \"https://accounts.zoho.com/oauth/v2/token\"\r\n   ```\r\n\r\n5. **Configure Google Apps Script**  \r\n   - Paste the `.gs` / `app_script.js` code into your Google Apps Script Editor.  \r\n   - Set up triggers or web app deployments as required.\r\n\r\n6. **Deploy Production**  \r\n   - Push your local changes to GitHub or your chosen repo host.  \r\n   - In Google Apps Script, deploy with appropriate permissions for the tracking pixel.\r\n\r\n## Setup and Usage\r\n- Configure your [Google Apps Script](https://developers.google.com/apps-script) project with the provided code.\r\n- Enable the web endpoint for handling the tracking pixel.\r\n- Create or update your [Google Sheets](https://www.google.com/sheets/about/) for storing email data, tracking opens, and logging call scripts.\r\n- Set necessary environment variables (e.g., API keys) in your script or use a .env file locally.\r\n- Deploy as a web app; then run the main script to send emails and track opens.\r\n\r\n## Additional Steps to Run\r\n1. Activate your virtual environment (.venv) if needed, then run `get_emails.py` to gather and upload emails to a Google Sheet.\r\n2. Open the Google Apps Script editor and run `app_script.js` via the web interface to handle sending and tracking.\r\n\r\n## Workflow Overview (Step-by-Step)\r\n1. **Data Import and Comparison**  \r\n   - Import existing customers from Zoho CRM.  \r\n   - Import new customer data from a CSV file.  \r\n   - Compare the domains of existing and new customers.\r\n\r\n2. **AI-Powered Email Generation**  \r\n   - If a domain match is found, generate a personalized email using AI.  \r\n   - Otherwise, generate a generic marketing email.\r\n\r\n3. **Email Upload and Sending**  \r\n   - Upload generated emails to a Google Sheet.  \r\n   - Send all emails from the Sheet using Google Apps Script.\r\n\r\n4. **Email Tracking**  \r\n   - Track email activity via Google Apps Script.  \r\n   - Update the Sheet with open status whenever an email is opened.\r\n\r\n5. **Engagement Analysis and Call Script Generation**  \r\n   - If an email’s open rate exceeds the threshold:  \r\n     - Generate a personalized call script via AI.  \r\n     - Save this call script to another Google Sheet for follow-up.\r\n\r\n## Resources\r\n- [Google Apps Script Overview](https://developers.google.com/apps-script)\r\n- [Google Sheets](https://www.google.com/sheets/about/)\r\n- [OpenAI GPT-4.0](https://openai.com/product/gpt-4)\r\n\r\n\r\n## License\r\nThis project is licensed under the [MIT License](https://opensource.org/licenses/MIT).\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanieladdisonorg%2Femail-marketing-ai-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanieladdisonorg%2Femail-marketing-ai-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanieladdisonorg%2Femail-marketing-ai-agent/lists"}