Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.supaproxy.cloud/llms.txt

Use this file to discover all available pages before exploring further.

Consumer plugins define how users interact with the AI. Each consumer type handles message ingestion, response delivery, and channel binding for a specific platform.

Installation

npm install @supaproxy/consumers

ConsumerPlugin interface

interface ConsumerPlugin<TConfig = unknown> {
  /** Unique type identifier, e.g. "slack", "api" */
  type: string;

  /** Human-readable name */
  name: string;

  /** Short description shown in the dashboard */
  description: string;

  /** Zod schema for configuration fields */
  configSchema: ZodSchema<TConfig>;

  /** Start listening for messages */
  start(config: TConfig, handler: MessageHandler): Promise<void>;

  /** Stop listening and clean up resources */
  stop(): Promise<void>;

  /** Send a response back to the consumer */
  sendResponse(channel: string, message: string): Promise<void>;
}

Available plugins

Listens for mentions via Slack Socket Mode. Binds channels to workspaces.
import { slackConsumer } from "@supaproxy/consumers";

// Config schema requires:
// - botToken: Slack bot OAuth token
// - appToken: Slack app-level token (for Socket Mode)
Config fieldTypeDescription
botTokenstringSlack bot OAuth token
appTokenstringApp-level token for Socket Mode

Adding a custom consumer

To add a new consumer type (e.g. Discord), create a plugin that implements ConsumerPlugin and register it.

1. Implement the interface

import { z } from "zod";
import type { ConsumerPlugin, MessageHandler } from "@supaproxy/consumers";

const configSchema = z.object({
  botToken: z.string().min(1, "Bot token is required"),
  guildId: z.string().min(1, "Guild ID is required"),
});

type DiscordConfig = z.infer<typeof configSchema>;

export const discordConsumer: ConsumerPlugin<DiscordConfig> = {
  type: "discord",
  name: "Discord",
  description: "Discord bot integration via gateway.",
  configSchema,

  async start(config, handler) {
    // Connect to Discord gateway
    // Listen for messages mentioning the bot
    // Call handler.onMessage() for each incoming message
  },

  async stop() {
    // Disconnect from gateway, clean up listeners
  },

  async sendResponse(channel, message) {
    // Send message to the Discord channel
  },
};

2. Register the plugin

Add it to the consumer registry so the server discovers it automatically:
import { consumerRegistry } from "@supaproxy/consumers";
import { discordConsumer } from "./discord";

consumerRegistry.register(discordConsumer);

3. Dashboard integration

No dashboard changes are needed. The dashboard reads the configSchema from the API and renders form fields dynamically. Your Discord consumer will appear in the “Add Consumer” dropdown with the correct configuration form.