The Core Problem

DeFi projects face a unique marketing challenge: their users live in Telegram groups, not on websites. Traditional marketing channels — email newsletters, SEO blog posts, paid ads — underperform because crypto traders and degens congregate in Telegram communities where they expect real-time, interactive experiences.

The problem compounds when you operate multiple DeFi products: a trading bot, a slot game, a token launch service. Each product needs its own Telegram bot with its own onboarding flow, user preferences, and engagement cadence. Managing these independently creates silos where a user who loves the slot game never learns about the trading bot.

DeFiKit's BotMatrix solves this with a serverless orchestration layer that connects all Telegram bots through a shared message queue, enabling automated cross-promotion, unified user profiles, and event-driven marketing sequences.

The Solution: BotMatrix Orchestration Layer

BotMatrix is a NestJS monolith built on grammY and Prisma that sits above individual bot instances. Instead of each bot managing its own user database, every interaction flows through BotMatrix:

```

User → Bot A → SQS Queue → BotMatrix Processor → Database → Bot B Notification

```

This design enables four critical marketing automation capabilities:

1. **Unified user profiles**: A single user across multiple bots gets consolidated preferences and behavior history

2. **Event-driven cross-promotion**: When a user completes an action in Bot A, BotMatrix schedules a Bot B invite

3. **Automated job scheduling**: Time-based marketing sequences (welcome, re-engagement, referral prompts)

4. **Behavioral segmentation**: Users are tagged by activity level, token holdings, and response rates

Architecture Overview

The SQS Ingestion Layer

Every bot interaction is serialized as a JSON event and pushed to an AWS SQS queue. This decouples user-facing bots from the marketing processor:

```typescript

interface BotEvent {

userId: string;

botId: string;

eventType: 'command' | 'message' | 'game_result' | 'referral';

timestamp: Date;

data: Record<string, unknown>;

}

```

Because SQS handles buffering, the bots never block on database writes. Marketing sequences can process events asynchronously without affecting the user experience.

The Prisma Database Schema

BotMatrix uses a relational schema that connects users to bots, groups, commands, and jobs:

```prisma

model UserPrivilege {

userId String

botId String

role String // 'admin', 'user', 'vip'

createdAt DateTime @default(now())

@@id([userId, botId])

}

model Job {

id String @id @default(cuid())

botId String

userId String?

type String // 'welcome', 're_engagement', 'cross_promotion'

status String // 'pending', 'running', 'completed'

runAt DateTime

createdAt DateTime @default(now())

}

```

The Agent System

BotMatrix includes an agent abstraction for complex automation flows. Each agent has a purpose and can spawn sub-agents for parallel tasks:

```typescript

interface Agent {

id: string;

name: string;

purpose: string; // 'cross_promotion', 'retention', 'onboarding'

status: string;

}

```

For example, the cross-promotion agent monitors game completion events. When a user finishes 5 rounds in the slot game, it triggers an onboarding sequence for the trading bot — complete with a personalized message about how trading signals complement their gaming rewards.

Step 1: Automated User Onboarding

When a new user joins any DeFiKit bot, BotMatrix orchestrates a multi-step onboarding sequence:

```

T+0: Welcome message + feature overview

T+5min: Interactive demo (inline keyboard with test commands)

T+1hr: Value proposition for other DeFiKit products

T+24hr: Referral program invitation

T+72hr: Re-engagement if inactive

```

Each step is a configurable Job in the database. The sequence adapts based on which bot the user joined through — slot game users get different messaging than trading bot users.

Step 2: Cross-Promotion Automation

Cross-promotion is the most direct marketing automation win. DeFiKit's event matching rules connect user actions across bots:

```sql

-- When a trading signal generates a profitable trade

-- Send a promotional message for the slot game

INSERT INTO jobs (bot_id, user_id, type, run_at, status)

VALUES ('casino-slot-bot', @userId, 'cross_promotion',

DATEADD('hour', 1, NOW()), 'pending');

```

The 1-hour delay ensures the user isn't spammed immediately. The message itself is templated and personalized:

```

🎰 *Nice trade, {username}!*

While you wait for the next signal, why not try your luck?

Our slot game paid out 2.3 SOL in rewards this week alone.

👉 /play_casino

```

Step 3: Group-Level Topic Routing

BotMatrix supports Telegram supergroup topics for organized community management. Each product channel (trading signals, game updates, token alerts) gets its own topic within a master group:

```prisma

model TelegramGroupTopic {

groupId String

topicId String

name String

product String // 'trading', 'gaming', 'tokens'

}

```

This structure means a single Telegram group serves as the hub for all DeFiKit products, with automated topic assignment based on user activity.

Step 4: Serverless Deployment

The entire BotMatrix stack runs on AWS with minimal operational overhead:

| Component | Service | Cost |

|-----------|---------|------|

| Bot instances | EC2 t3.micro (via SQS listeners) | ~$8/mo |

| Message queue | SQS (1M requests free tier) | ~$0 |

| Database | RDS PostgreSQL db.t3.micro | ~$15/mo |

| User profiles | Prisma + PostgreSQL | Included |

| Total infrastructure | — | **~$25/mo** |

The serverless SQS layer ensures that even if all 6+ bots are hammered simultaneously during a market event, messages queue up and process in order without dropping data.

Results

DeFiKit's automated marketing pipeline shows measurable improvements in user progression:

| Metric | Before BotMatrix | After BotMatrix |

|--------|-----------------|-----------------|

| Cross-product adoption rate | 8% | 34% |

| 7-day user retention | 22% | 51% |

| Average onboarding completion | 40% | 78% |

| Automated promotions sent/day | 0 (manual) | 200+ |

| Cost per new user acquired | ~$0.50 (ads) | $0.02 (cross-promo) |

Key Takeaways

- **Serverless queues are the backbone of multi-bot marketing**: SQS decouples user-facing latency from marketing logic, letting both scale independently

- **Cross-promotion requires timing, not frequency**: A well-timed single message (1-hour delay after a positive experience) outperforms 5 immediate spam messages

- **Unified user profiles unlock behavioral segmentation**: Without a shared database, you can't tell that a slot game user is also a trading bot user

- **Telegram supergroup topics enable scalable community management**: One master group with topic-based routing replaces 6 fragmented groups

- **The 8% → 34% cross-product adoption lift validates the architecture**: Users don't discover secondary products naturally — they need automated, contextual invitations at the right moment