Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,25 @@ VECTOR_DB_ENABLED=false
# VECTOR_DB_TYPE=pinecone|weaviate|chroma
# VECTOR_DB_API_KEY=your-api-key
# VECTOR_DB_ENDPOINT=https://your-instance.vectordb.com

# Cross-Platform Bot Integration (Optional)
# ManyChat Configuration
MANYCHAT_ENABLED=false
# MANYCHAT_API_KEY=your-manychat-api-key
# MANYCHAT_WEBHOOK_URL=https://your-app.com/webhooks/manychat

# BotBuilders Configuration
BOTBUILDERS_ENABLED=false
# BOTBUILDERS_API_KEY=your-botbuilders-api-key
# BOTBUILDERS_API_SECRET=your-botbuilders-api-secret
# BOTBUILDERS_ENDPOINT=https://api.botbuilders.com

# OpenClaw Configuration
OPENCLAW_ENABLED=false
# OPENCLAW_API_KEY=your-openclaw-api-key
# OPENCLAW_WEBHOOK_URL=https://your-app.com/webhooks/openclaw

# Moltbook Configuration
MOLTBOOK_ENABLED=false
# MOLTBOOK_API_KEY=your-moltbook-api-key
# MOLTBOOK_ENDPOINT=https://api.moltbook.com
137 changes: 136 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ The Grand United Fields of Theories

## Overview

This project includes comprehensive quality and hardening features:
This project includes comprehensive quality and hardening features, along with cross-platform bot integration:

- **Cross-Platform Connectivity**: Integration with ManyChat, BotBuilders, OpenClaw, and Moltbook
- **Config Validation**: Type-safe configuration with Zod validation
- **Telemetry**: Optional OpenTelemetry integration (no vendor lock-in)
- **Security Scanning**: Trivy vulnerability scanning and SBOM generation
Expand Down Expand Up @@ -82,6 +83,132 @@ npm run validate:config

The validation performs no network calls - only local parsing and validation.

## Cross-Platform Bot Integration

### Supported Platforms

This project provides comprehensive cross-platform connectivity for popular bot platforms:

1. **ManyChat**: Facebook Messenger bot platform with webhook support
2. **BotBuilders**: Multi-platform bot building solution with API integration
3. **OpenClaw**: Open-source bot framework with real-time messaging
4. **Moltbook**: Data synchronization and messaging platform

### Platform Configuration

Each platform can be enabled independently via environment variables:

**ManyChat:**

```bash
MANYCHAT_ENABLED=true
MANYCHAT_API_KEY=your-manychat-api-key
MANYCHAT_WEBHOOK_URL=https://your-app.com/webhooks/manychat
```

**BotBuilders:**

```bash
BOTBUILDERS_ENABLED=true
BOTBUILDERS_API_KEY=your-botbuilders-api-key
BOTBUILDERS_API_SECRET=your-botbuilders-api-secret
BOTBUILDERS_ENDPOINT=https://api.botbuilders.com
```

**OpenClaw:**

```bash
OPENCLAW_ENABLED=true
OPENCLAW_API_KEY=your-openclaw-api-key
OPENCLAW_WEBHOOK_URL=https://your-app.com/webhooks/openclaw
```

**Moltbook:**

```bash
MOLTBOOK_ENABLED=true
MOLTBOOK_API_KEY=your-moltbook-api-key
MOLTBOOK_ENDPOINT=https://api.moltbook.com
```

### Platform Usage

**Initialize Platform Manager:**

```typescript
import { PlatformManager, PlatformType } from './platforms';

const manager = new PlatformManager({
manychat: {
enabled: true,
apiKey: process.env.MANYCHAT_API_KEY,
webhookUrl: process.env.MANYCHAT_WEBHOOK_URL,
},
// ... other platforms
});

await manager.initialize();
```

**Send Message to Specific Platform:**

```typescript
const message = await manager.sendMessage(PlatformType.MANYCHAT, 'user123', 'Hello from the bot!');
```

**Broadcast Message to All Platforms:**

```typescript
const messages = await manager.broadcastMessage(
'user123',
'This message goes to all enabled platforms'
);
```

**Handle Incoming Webhooks:**

```typescript
const message = await manager.handleWebhook(PlatformType.MANYCHAT, webhookPayload);
```

**Get User Profile:**

```typescript
const connector = manager.getConnector(PlatformType.MANYCHAT);
const profile = await connector.getUserProfile('user123');
```

### Platform Features

- **Unified Message Interface**: Consistent message structure across all platforms
- **Webhook Support**: Receive messages from platform webhooks
- **User Profile Retrieval**: Get user information from each platform
- **Error Handling**: Graceful error handling and validation
- **Type Safety**: Full TypeScript support with type definitions
- **Broadcast Messaging**: Send messages to multiple platforms simultaneously
- **Platform Status**: Check if platforms are ready and enabled

### Running the Example

To see the cross-platform integration in action, run the included example:

```bash
# Build the project first
npm run build

# Run the platform integration example
npm run example:platforms
```

This will demonstrate:

- Initializing multiple platform connectors
- Sending messages to specific platforms
- Broadcasting to all platforms
- Handling incoming webhooks
- Retrieving user profiles
- Checking platform status

## Telemetry

### OpenTelemetry Integration
Expand Down Expand Up @@ -256,6 +383,14 @@ Check Issues tab for the Renovate Dependency Dashboard
│ │ └── validator.ts # Smoke test script
│ ├── telemetry/ # OpenTelemetry integration
│ │ └── index.ts # Tracer and logger setup
│ ├── platforms/ # Cross-platform bot integrations
│ │ ├── types.ts # Platform type definitions
│ │ ├── manychat.ts # ManyChat connector
│ │ ├── botbuilders.ts # BotBuilders connector
│ │ ├── openclaw.ts # OpenClaw connector
│ │ ├── moltbook.ts # Moltbook connector
│ │ ├── manager.ts # Platform manager
│ │ └── index.ts # Platform exports
│ └── index.ts # Main entry point
├── .github/
│ └── workflows/ # GitHub Actions workflows
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"test": "node --test",
"validate:config": "node dist/config/validator.js",
"build": "tsc",
"example:platforms": "node dist/examples/platform-integration.js",
"prepare": "husky install || true"
},
"keywords": [
Expand Down
65 changes: 65 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,48 @@ export const ConfigSchema = z.object({
endpoint: z.string().url().optional(),
})
.optional(),

// Platform integrations (optional)
platforms: z
.object({
// ManyChat configuration
manychat: z
.object({
enabled: z.coerce.boolean().default(false),
apiKey: z.string().optional(),
webhookUrl: z.string().url().optional(),
})
.optional(),
Comment on lines +46 to +52
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration allows optional apiKey, apiSecret, webhookUrl, and endpoint fields, but the connector implementations require apiKey (and sometimes apiSecret) to initialize. This creates a mismatch where the config schema allows these to be undefined, but the connectors will throw errors at runtime. Consider making required fields non-optional in the schema or adjusting the validation logic to check for required fields when enabled is true.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah please delete everything that I got from all connections


// BotBuilders configuration
botbuilders: z
.object({
enabled: z.coerce.boolean().default(false),
apiKey: z.string().optional(),
apiSecret: z.string().optional(),
endpoint: z.string().url().optional(),
})
.optional(),

// OpenClaw configuration
openclaw: z
.object({
enabled: z.coerce.boolean().default(false),
apiKey: z.string().optional(),
webhookUrl: z.string().url().optional(),
})
.optional(),

// Moltbook configuration
moltbook: z
.object({
enabled: z.coerce.boolean().default(false),
apiKey: z.string().optional(),
endpoint: z.string().url().optional(),
})
.optional(),
})
.optional(),
});

export type Config = z.infer<typeof ConfigSchema>;
Expand Down Expand Up @@ -70,6 +112,29 @@ export function loadConfig(): Config {
apiKey: process.env.VECTOR_DB_API_KEY,
endpoint: process.env.VECTOR_DB_ENDPOINT,
},
platforms: {
manychat: {
enabled: process.env.MANYCHAT_ENABLED,
apiKey: process.env.MANYCHAT_API_KEY,
webhookUrl: process.env.MANYCHAT_WEBHOOK_URL,
},
botbuilders: {
enabled: process.env.BOTBUILDERS_ENABLED,
apiKey: process.env.BOTBUILDERS_API_KEY,
apiSecret: process.env.BOTBUILDERS_API_SECRET,
endpoint: process.env.BOTBUILDERS_ENDPOINT,
},
openclaw: {
enabled: process.env.OPENCLAW_ENABLED,
apiKey: process.env.OPENCLAW_API_KEY,
webhookUrl: process.env.OPENCLAW_WEBHOOK_URL,
},
moltbook: {
enabled: process.env.MOLTBOOK_ENABLED,
apiKey: process.env.MOLTBOOK_API_KEY,
endpoint: process.env.MOLTBOOK_ENDPOINT,
},
},
};

// Parse and validate configuration
Expand Down
127 changes: 127 additions & 0 deletions src/examples/platform-integration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/**
* Example: Cross-Platform Bot Integration
*
* This example demonstrates how to use the cross-platform bot integration
* to send messages and handle webhooks across multiple platforms.
*/

import { PlatformManager, PlatformType } from '../platforms';

async function runExample() {
console.log('=== Cross-Platform Bot Integration Example ===\n');

// Initialize the platform manager with multiple platforms
const manager = new PlatformManager({
manychat: {
enabled: true,
apiKey: 'demo-manychat-key',
webhookUrl: 'https://example.com/webhooks/manychat',
},
botbuilders: {
enabled: true,
apiKey: 'demo-botbuilders-key',
apiSecret: 'demo-botbuilders-secret',
endpoint: 'https://api.botbuilders.example',
},
openclaw: {
enabled: true,
apiKey: 'demo-openclaw-key',
},
moltbook: {
enabled: true,
apiKey: 'demo-moltbook-key',
endpoint: 'https://api.moltbook.example',
},
});

// Initialize all enabled platforms
console.log('Initializing platform connectors...');
await manager.initialize();

const enabledPlatforms = manager.getEnabledPlatforms();
console.log(
`✓ Initialized ${enabledPlatforms.length} platforms: ${enabledPlatforms.join(', ')}\n`
);

// Example 1: Send a message to a specific platform
console.log('Example 1: Send message to ManyChat');
const manychatMessage = await manager.sendMessage(
PlatformType.MANYCHAT,
'user123',
'Hello from ManyChat connector!'
);
console.log(`✓ Message sent:`, {
id: manychatMessage.id,
platform: manychatMessage.platform,
text: manychatMessage.text,
});
console.log();

// Example 2: Broadcast a message to all platforms
console.log('Example 2: Broadcast message to all platforms');
const broadcastMessages = await manager.broadcastMessage(
'user456',
'This is a broadcast message!'
);
console.log(`✓ Broadcast sent to ${broadcastMessages.length} platforms:`);
broadcastMessages.forEach((msg) => {
console.log(` - ${msg.platform}: ${msg.id}`);
});
console.log();

// Example 3: Handle incoming webhook from ManyChat
console.log('Example 3: Handle incoming webhook');
const webhookPayload = {
id: 'webhook-msg-789',
userId: 'webhook-user',
text: 'User message from ManyChat',
timestamp: Date.now(),
};

const receivedMessage = await manager.handleWebhook(PlatformType.MANYCHAT, webhookPayload);
if (receivedMessage) {
console.log(`✓ Webhook processed:`, {
id: receivedMessage.id,
platform: receivedMessage.platform,
userId: receivedMessage.userId,
text: receivedMessage.text,
});
}
console.log();

// Example 4: Get user profile
console.log('Example 4: Get user profile');
const connector = manager.getConnector(PlatformType.BOTBUILDERS);
if (connector) {
const profile = await connector.getUserProfile('user789');
if (profile) {
console.log(`✓ User profile retrieved:`, {
id: profile.id,
platform: profile.platform,
name: profile.name,
});
}
}
console.log();

// Example 5: Check platform status
console.log('Example 5: Platform status check');
enabledPlatforms.forEach((platform) => {
const isEnabled = manager.isPlatformEnabled(platform);
console.log(` - ${platform}: ${isEnabled ? 'enabled' : 'disabled'}`);
});
console.log();

// Cleanup: Shutdown all platform connectors
console.log('Shutting down platform connectors...');
await manager.shutdown();
console.log('✓ All platforms shut down gracefully\n');

console.log('=== Example completed successfully ===');
}

// Run the example
runExample().catch((error) => {
console.error('Example failed:', error);
process.exit(1);
});
Loading