Documentation

    Documentation

    Documentation

    Ring Platform Logo

    Завантаження документації...

    Підготовка контенту платформи Ring

    Ring Platform Logo

    Завантаження документації...

    Підготовка контенту платформи Ring

    Ring Platform Logo

    Завантаження документації...

    Підготовка контенту платформи Ring

    1. /
    2. /Email AI-CRM developer guide

    Updated Jun 10, 20262 min listen

    1. /
    2. /Email AI-CRM developer guide

    Updated Jun 10, 20262 min listen

    1. /
    2. /Email AI-CRM developer guide

    Updated Jun 10, 20262 min listen

    Concepts, value, and typical clone scenarios — less code.

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Architecture
    Data Model
    Real Time
    Discovery Mutation Sync
    Security
    Backend Services
    k8s-postgres-fcm Mode
    Firebase Integration
    Features
    Authentication
    Email AI-CRM
    Entities
    Opportunities
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Tunnel Protocol
    Wallet & Credit System
    Multi-Vendor Store
    Referral Codes (Refcodes)
    Affiliate & Referral Enablement
    Payments Overview
    PaymentConductor
    SubscriptionConductor
    VideoConductor
    News Module - Digital Newspaper Experience
    Member Blogs
    Public Profile Pages
    Username Reservation System
    Scientific Editor
    Locale System
    Security & Compliance
    NFT Marketplace
    Token Staking System
    Performance Optimization Patterns
    Mobile Experience
    Wallet
    Wallet Security Tips
    API
    Authentication
    Email AI-CRM API
    Entities
    Opportunities
    Messaging API
    Notifications API
    Wallet API
    Store API
    Admin API
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Branding
    Themes
    Web3
    Token launch jurisdictions
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Development
    Local Setup
    Code Structure
    Documentation components
    Community tooling
    Ring MCP Server
    Generative Images (ImageConductor)
    Autonomous Newsroom (Grok)
    OSS vs enterprise
    Whitelabel Navigation
    Best Practices
    Workflow
    Code Style
    Performance
    Testing
    Deployment
    Debugging
    Contributing
    MCP
    ring-image-create
    ring-video-create
    Examples
    Quick Start
    White Label
    Real World
    Integrations
    Ethereum wallets (Wagmi v3)

    Quick entry (CTOs · auditors · agents)

    Welcome — mission & audiences
    Quick Reference
    Getting started
    Architecture & Auth.js
    Backend modes & databases (DB_BACKEND_MODE)
    Self-hosted
    Ring MCP Tools
    Ring MCP Server
    Token economics
    Token launch jurisdictions
    Deploy (Docker · k8s)
    Security & compliance reads
    ringdom.org — LegioX homebase
    Source — MIT license (GitHub)

    Concepts, value, and typical clone scenarios — less code.

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Architecture
    Data Model
    Real Time
    Discovery Mutation Sync
    Security
    Backend Services
    k8s-postgres-fcm Mode
    Firebase Integration
    Features
    Authentication
    Email AI-CRM
    Entities
    Opportunities
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Tunnel Protocol
    Wallet & Credit System
    Multi-Vendor Store
    Referral Codes (Refcodes)
    Affiliate & Referral Enablement
    Payments Overview
    PaymentConductor
    SubscriptionConductor
    VideoConductor
    News Module - Digital Newspaper Experience
    Member Blogs
    Public Profile Pages
    Username Reservation System
    Scientific Editor
    Locale System
    Security & Compliance
    NFT Marketplace
    Token Staking System
    Performance Optimization Patterns
    Mobile Experience
    Wallet
    Wallet Security Tips
    API
    Authentication
    Email AI-CRM API
    Entities
    Opportunities
    Messaging API
    Notifications API
    Wallet API
    Store API
    Admin API
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Branding
    Themes
    Web3
    Token launch jurisdictions
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Development
    Local Setup
    Code Structure
    Documentation components
    Community tooling
    Ring MCP Server
    Generative Images (ImageConductor)
    Autonomous Newsroom (Grok)
    OSS vs enterprise
    Whitelabel Navigation
    Best Practices
    Workflow
    Code Style
    Performance
    Testing
    Deployment
    Debugging
    Contributing
    MCP
    ring-image-create
    ring-video-create
    Examples
    Quick Start
    White Label
    Real World
    Integrations
    Ethereum wallets (Wagmi v3)

    Quick entry (CTOs · auditors · agents)

    Welcome — mission & audiences
    Quick Reference
    Getting started
    Architecture & Auth.js
    Backend modes & databases (DB_BACKEND_MODE)
    Self-hosted
    Ring MCP Tools
    Ring MCP Server
    Token economics
    Token launch jurisdictions
    Deploy (Docker · k8s)
    Security & compliance reads
    ringdom.org — LegioX homebase
    Source — MIT license (GitHub)

    Concepts, value, and typical clone scenarios — less code.

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Architecture
    Data Model
    Real Time
    Discovery Mutation Sync
    Security
    Backend Services
    k8s-postgres-fcm Mode
    Firebase Integration
    Features
    Authentication
    Email AI-CRM
    Entities
    Opportunities
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Tunnel Protocol
    Wallet & Credit System
    Multi-Vendor Store
    Referral Codes (Refcodes)
    Affiliate & Referral Enablement
    Payments Overview
    PaymentConductor
    SubscriptionConductor
    VideoConductor
    News Module - Digital Newspaper Experience
    Member Blogs
    Public Profile Pages
    Username Reservation System
    Scientific Editor
    Locale System
    Security & Compliance
    NFT Marketplace
    Token Staking System
    Performance Optimization Patterns
    Mobile Experience
    Wallet
    Wallet Security Tips
    API
    Authentication
    Email AI-CRM API
    Entities
    Opportunities
    Messaging API
    Notifications API
    Wallet API
    Store API
    Admin API
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Branding
    Themes
    Web3
    Token launch jurisdictions
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Development
    Local Setup
    Code Structure
    Documentation components
    Community tooling
    Ring MCP Server
    Generative Images (ImageConductor)
    Autonomous Newsroom (Grok)
    OSS vs enterprise
    Whitelabel Navigation
    Best Practices
    Workflow
    Code Style
    Performance
    Testing
    Deployment
    Debugging
    Contributing
    MCP
    ring-image-create
    ring-video-create
    Examples
    Quick Start
    White Label
    Real World
    Integrations
    Ethereum wallets (Wagmi v3)

    Quick entry (CTOs · auditors · agents)

    Welcome — mission & audiences
    Quick Reference
    Getting started
    Architecture & Auth.js
    Backend modes & databases (DB_BACKEND_MODE)
    Self-hosted
    Ring MCP Tools
    Ring MCP Server
    Token economics
    Token launch jurisdictions
    Deploy (Docker · k8s)
    Security & compliance reads
    ringdom.org — LegioX homebase
    Source — MIT license (GitHub)
    Docs
    Examples
    Docs
    Examples
    Docs
    Examples

    Email AI-CRM developer guide

    Set up the Email AI-CRM module on a local or self-hosted Ring clone: configure .env.local, apply JSONB migrations when using Postgres, then verify ingest and draft send from the admin UI.

    1. Local environment

    Copy the EMAIL CRM block from env.local.template into .env.local:

    bash
    
    # .env.local
    IMAP_HOST=mail.example.com
    IMAP_PORT=993
    IMAP_TLS=true
    IMAP_USER=info@example.com
    IMAP_PASSWORD=
    
    SMTP_HOST=mail.example.com
    SMTP_PORT=587
    SMTP_SECURE=false
    SMTP_USER=info@example.com
    SMTP_PASSWORD=
    
    ANTHROPIC_API_KEY=
    
    CRON_SECRET=generate-a-long-random-string
    EMAIL_AUTO_SEND_ENABLED=false
    WEBHOOK_EMAIL_SECRET=              # optional: webhook ingest instead of IMAP
    EMAIL_CRM_PERSISTENCE=memory       # quick start without DB tables
    Postgres-backed dev

    Remove EMAIL_CRM_PERSISTENCE=memory and apply migrations below so threads and drafts persist across restarts.

    2. Database migrations

    When DATABASE_URL points at your dev Postgres:

    bash
    
    psql "$DATABASE_URL" -f data/migrations/009_email_crm_jsonb.sql
    psql "$DATABASE_URL" -f data/migrations/010_email_crm_tasks_jsonb.sql
    psql "$DATABASE_URL" -c "\dt email_*"
    Do not use 001_email_crm_schema.sql

    001_email_crm_schema.sql is deprecated (column-model CRM). Always apply 009 + 010 only. If old column tables exist with data, migrate rows into JSONB data documents before 009 (which drops empty legacy tables only). ring-ringdom-org keeps the file under data/migrations/_deprecated/ for archaeology.

    3. Trigger ingest (local)

    Option A — cron poll (matches production):

    bash
    
    curl -sS -X POST "http://localhost:3000/api/cron/email-processor" \
      -H "Authorization: Bearer $CRON_SECRET" \
      -H "Content-Type: application/json" \
      -d '{"action":"poll"}'

    Option B — webhook (no IMAP required for the test):

    bash
    
    BODY='{"messageId":"<test@local>","from":"you@example.com","to":"info@example.com","subject":"Hi","bodyText":"Hello"}'
    SIG=$(echo -n "$BODY" | openssl dgst -sha256 -hmac "$WEBHOOK_EMAIL_SECRET" | awk '{print $2}')
    
    curl -X POST "http://localhost:3000/api/webhooks/email/inbound" \
      -H "Content-Type: application/json" \
      -H "X-Email-Webhook-Signature: $SIG" \
      -d "$BODY"

    4. SMTP smoke test

    1. Send a test message to your configured inbox (IMAP_USER).
    2. Run cron poll (or use the webhook example above).
    3. Open Admin → Email Inbox — thread should appear.
    4. Open Email Drafts — approve a draft, click send.
    5. Confirm reply in the sender mailbox and an outbound row in email_messages.

    Only then set EMAIL_AUTO_SEND_ENABLED=true.

    5. Admin UI checklist

    PageURLExpect
    Inbox/{locale}/admin/email-inboxLive threads from API
    Thread/{locale}/admin/email-inbox/<threadId>Message timeline
    Drafts/{locale}/admin/email-draftsApprove / reject / send
    Contacts/{locale}/admin/email-contactsCRM from processor
    Analytics/{locale}/admin/email-analyticsCost from email_api_usage
    Tasks/{locale}/admin/email-tasksAuto-created follow-ups

    6. Production cron

    Schedule the same poll endpoint on your deployed BASE_URL every 1–5 minutes:

    Optional analytics snapshot: GET $BASE_URL/api/cron/email-analytics with the same Bearer token.

    Troubleshooting

    SymptomCheck
    Empty inboxMigrations applied (or EMAIL_CRM_PERSISTENCE=memory)? Cron poll returning processed > 0?
    No AI draftANTHROPIC_API_KEY set? Security pipeline blocked? Check server logs.
    Duplicate processingShould not occur — email_messages Message-ID dedup
    Draft send failsSMTP_* credentials, port 587 STARTTLS, firewall to SMTP_HOST
    Auto-send silentEMAIL_AUTO_SEND_ENABLED=true and confidence rules met
    401 on cronCRON_SECRET matches Authorization: Bearer header

    Related

    • Email AI-CRM feature
    • Email AI-CRM API
    • Migrations
    • Environment

    Email AI-CRM developer guide

    Set up the Email AI-CRM module on a local or self-hosted Ring clone: configure .env.local, apply JSONB migrations when using Postgres, then verify ingest and draft send from the admin UI.

    1. Local environment

    Copy the EMAIL CRM block from env.local.template into .env.local:

    bash
    
    # .env.local
    IMAP_HOST=mail.example.com
    IMAP_PORT=993
    IMAP_TLS=true
    IMAP_USER=info@example.com
    IMAP_PASSWORD=
    
    SMTP_HOST=mail.example.com
    SMTP_PORT=587
    SMTP_SECURE=false
    SMTP_USER=info@example.com
    SMTP_PASSWORD=
    
    ANTHROPIC_API_KEY=
    
    CRON_SECRET=generate-a-long-random-string
    EMAIL_AUTO_SEND_ENABLED=false
    WEBHOOK_EMAIL_SECRET=              # optional: webhook ingest instead of IMAP
    EMAIL_CRM_PERSISTENCE=memory       # quick start without DB tables
    Postgres-backed dev

    Remove EMAIL_CRM_PERSISTENCE=memory and apply migrations below so threads and drafts persist across restarts.

    2. Database migrations

    When DATABASE_URL points at your dev Postgres:

    bash
    
    psql "$DATABASE_URL" -f data/migrations/009_email_crm_jsonb.sql
    psql "$DATABASE_URL" -f data/migrations/010_email_crm_tasks_jsonb.sql
    psql "$DATABASE_URL" -c "\dt email_*"
    Do not use 001_email_crm_schema.sql

    001_email_crm_schema.sql is deprecated (column-model CRM). Always apply 009 + 010 only. If old column tables exist with data, migrate rows into JSONB data documents before 009 (which drops empty legacy tables only). ring-ringdom-org keeps the file under data/migrations/_deprecated/ for archaeology.

    3. Trigger ingest (local)

    Option A — cron poll (matches production):

    bash
    
    curl -sS -X POST "http://localhost:3000/api/cron/email-processor" \
      -H "Authorization: Bearer $CRON_SECRET" \
      -H "Content-Type: application/json" \
      -d '{"action":"poll"}'

    Option B — webhook (no IMAP required for the test):

    bash
    
    BODY='{"messageId":"<test@local>","from":"you@example.com","to":"info@example.com","subject":"Hi","bodyText":"Hello"}'
    SIG=$(echo -n "$BODY" | openssl dgst -sha256 -hmac "$WEBHOOK_EMAIL_SECRET" | awk '{print $2}')
    
    curl -X POST "http://localhost:3000/api/webhooks/email/inbound" \
      -H "Content-Type: application/json" \
      -H "X-Email-Webhook-Signature: $SIG" \
      -d "$BODY"

    4. SMTP smoke test

    1. Send a test message to your configured inbox (IMAP_USER).
    2. Run cron poll (or use the webhook example above).
    3. Open Admin → Email Inbox — thread should appear.
    4. Open Email Drafts — approve a draft, click send.
    5. Confirm reply in the sender mailbox and an outbound row in email_messages.

    Only then set EMAIL_AUTO_SEND_ENABLED=true.

    5. Admin UI checklist

    PageURLExpect
    Inbox/{locale}/admin/email-inboxLive threads from API
    Thread/{locale}/admin/email-inbox/<threadId>Message timeline
    Drafts/{locale}/admin/email-draftsApprove / reject / send
    Contacts/{locale}/admin/email-contactsCRM from processor
    Analytics/{locale}/admin/email-analyticsCost from email_api_usage
    Tasks/{locale}/admin/email-tasksAuto-created follow-ups

    6. Production cron

    Schedule the same poll endpoint on your deployed BASE_URL every 1–5 minutes:

    Optional analytics snapshot: GET $BASE_URL/api/cron/email-analytics with the same Bearer token.

    Troubleshooting

    SymptomCheck
    Empty inboxMigrations applied (or EMAIL_CRM_PERSISTENCE=memory)? Cron poll returning processed > 0?
    No AI draftANTHROPIC_API_KEY set? Security pipeline blocked? Check server logs.
    Duplicate processingShould not occur — email_messages Message-ID dedup
    Draft send failsSMTP_* credentials, port 587 STARTTLS, firewall to SMTP_HOST
    Auto-send silentEMAIL_AUTO_SEND_ENABLED=true and confidence rules met
    401 on cronCRON_SECRET matches Authorization: Bearer header

    Related

    • Email AI-CRM feature
    • Email AI-CRM API
    • Migrations
    • Environment

    Email AI-CRM developer guide

    Set up the Email AI-CRM module on a local or self-hosted Ring clone: configure .env.local, apply JSONB migrations when using Postgres, then verify ingest and draft send from the admin UI.

    1. Local environment

    Copy the EMAIL CRM block from env.local.template into .env.local:

    bash
    
    # .env.local
    IMAP_HOST=mail.example.com
    IMAP_PORT=993
    IMAP_TLS=true
    IMAP_USER=info@example.com
    IMAP_PASSWORD=
    
    SMTP_HOST=mail.example.com
    SMTP_PORT=587
    SMTP_SECURE=false
    SMTP_USER=info@example.com
    SMTP_PASSWORD=
    
    ANTHROPIC_API_KEY=
    
    CRON_SECRET=generate-a-long-random-string
    EMAIL_AUTO_SEND_ENABLED=false
    WEBHOOK_EMAIL_SECRET=              # optional: webhook ingest instead of IMAP
    EMAIL_CRM_PERSISTENCE=memory       # quick start without DB tables
    Postgres-backed dev

    Remove EMAIL_CRM_PERSISTENCE=memory and apply migrations below so threads and drafts persist across restarts.

    2. Database migrations

    When DATABASE_URL points at your dev Postgres:

    bash
    
    psql "$DATABASE_URL" -f data/migrations/009_email_crm_jsonb.sql
    psql "$DATABASE_URL" -f data/migrations/010_email_crm_tasks_jsonb.sql
    psql "$DATABASE_URL" -c "\dt email_*"
    Do not use 001_email_crm_schema.sql

    001_email_crm_schema.sql is deprecated (column-model CRM). Always apply 009 + 010 only. If old column tables exist with data, migrate rows into JSONB data documents before 009 (which drops empty legacy tables only). ring-ringdom-org keeps the file under data/migrations/_deprecated/ for archaeology.

    3. Trigger ingest (local)

    Option A — cron poll (matches production):

    bash
    
    curl -sS -X POST "http://localhost:3000/api/cron/email-processor" \
      -H "Authorization: Bearer $CRON_SECRET" \
      -H "Content-Type: application/json" \
      -d '{"action":"poll"}'

    Option B — webhook (no IMAP required for the test):

    bash
    
    BODY='{"messageId":"<test@local>","from":"you@example.com","to":"info@example.com","subject":"Hi","bodyText":"Hello"}'
    SIG=$(echo -n "$BODY" | openssl dgst -sha256 -hmac "$WEBHOOK_EMAIL_SECRET" | awk '{print $2}')
    
    curl -X POST "http://localhost:3000/api/webhooks/email/inbound" \
      -H "Content-Type: application/json" \
      -H "X-Email-Webhook-Signature: $SIG" \
      -d "$BODY"

    4. SMTP smoke test

    1. Send a test message to your configured inbox (IMAP_USER).
    2. Run cron poll (or use the webhook example above).
    3. Open Admin → Email Inbox — thread should appear.
    4. Open Email Drafts — approve a draft, click send.
    5. Confirm reply in the sender mailbox and an outbound row in email_messages.

    Only then set EMAIL_AUTO_SEND_ENABLED=true.

    5. Admin UI checklist

    PageURLExpect
    Inbox/{locale}/admin/email-inboxLive threads from API
    Thread/{locale}/admin/email-inbox/<threadId>Message timeline
    Drafts/{locale}/admin/email-draftsApprove / reject / send
    Contacts/{locale}/admin/email-contactsCRM from processor
    Analytics/{locale}/admin/email-analyticsCost from email_api_usage
    Tasks/{locale}/admin/email-tasksAuto-created follow-ups

    6. Production cron

    Schedule the same poll endpoint on your deployed BASE_URL every 1–5 minutes:

    Optional analytics snapshot: GET $BASE_URL/api/cron/email-analytics with the same Bearer token.

    Troubleshooting

    SymptomCheck
    Empty inboxMigrations applied (or EMAIL_CRM_PERSISTENCE=memory)? Cron poll returning processed > 0?
    No AI draftANTHROPIC_API_KEY set? Security pipeline blocked? Check server logs.
    Duplicate processingShould not occur — email_messages Message-ID dedup
    Draft send failsSMTP_* credentials, port 587 STARTTLS, firewall to SMTP_HOST
    Auto-send silentEMAIL_AUTO_SEND_ENABLED=true and confidence rules met
    401 on cronCRON_SECRET matches Authorization: Bearer header

    Related

    • Email AI-CRM feature
    • Email AI-CRM API
    • Migrations
    • Environment
    bash
    
    curl -sS -X POST "$BASE_URL/api/cron/email-processor" \
      -H "Authorization: Bearer ${CRON_SECRET}" \
      -H "Content-Type: application/json" \
      -d '{"action":"poll"}'
    bash
    
    curl -sS -X POST "$BASE_URL/api/cron/email-processor" \
      -H "Authorization: Bearer ${CRON_SECRET}" \
      -H "Content-Type: application/json" \
      -d '{"action":"poll"}'
    bash
    
    curl -sS -X POST "$BASE_URL/api/cron/email-processor" \
      -H "Authorization: Bearer ${CRON_SECRET}" \
      -H "Content-Type: application/json" \
      -d '{"action":"poll"}'