Back to Documentation

Official Plugins

Extend RANA with official plugins for Slack, Discord, voice, email, and document processing. Or create your own custom plugins.

npm install @rana/plugins

Slack Integration

Build AI-powered Slack bots with conversation context

import { SlackPlugin } from '@rana/plugins/slack';

const slack = new SlackPlugin({
  token: process.env.SLACK_BOT_TOKEN,
  signingSecret: process.env.SLACK_SIGNING_SECRET,
  appToken: process.env.SLACK_APP_TOKEN
});

// Handle messages
slack.onMessage(async (message, context) => {
  const response = await chat({
    messages: [
      ...context.threadHistory,  // Previous messages in thread
      { role: 'user', content: message.text }
    ]
  });

  await context.reply(response.content);
});

// Handle slash commands
slack.onCommand('/ask', async (command, context) => {
  const answer = await agent.run(command.text);
  await context.respond(answer);
});

// Start listening
await slack.start();

Discord Integration

Create Discord bots with slash commands and threads

import { DiscordPlugin } from '@rana/plugins/discord';

const discord = new DiscordPlugin({
  token: process.env.DISCORD_BOT_TOKEN,
  clientId: process.env.DISCORD_CLIENT_ID
});

// Handle mentions
discord.onMention(async (message, context) => {
  const response = await chat({
    messages: [{ role: 'user', content: message.content }]
  });

  await message.reply(response.content);
});

// Register slash commands
discord.registerCommand({
  name: 'ask',
  description: 'Ask the AI a question',
  handler: async (interaction) => {
    const question = interaction.options.getString('question');
    const answer = await agent.run(question);
    await interaction.reply(answer);
  }
});

await discord.start();

Voice Integration

Build voice-enabled AI applications

import { VoicePlugin } from '@rana/plugins/voice';

const voice = new VoicePlugin({
  sttProvider: 'whisper',       // Speech-to-text
  ttsProvider: 'elevenlabs',    // Text-to-speech
  ttsVoice: 'rachel'
});

// Transcribe audio
const transcript = await voice.transcribe(audioBuffer, {
  language: 'en',
  format: 'mp3'
});

// Generate speech
const audio = await voice.synthesize(text, {
  speed: 1.0,
  emotion: 'friendly'
});

// Full voice conversation
const response = await voice.converse(audioInput, async (text) => {
  return await chat({
    messages: [{ role: 'user', content: text }]
  });
});
// Returns { text: string, audio: Buffer }

Email Integration

AI-powered email processing and responses

import { EmailPlugin } from '@rana/plugins/email';

const email = new EmailPlugin({
  imap: {
    host: 'imap.gmail.com',
    user: process.env.EMAIL_USER,
    password: process.env.EMAIL_PASSWORD
  },
  smtp: {
    host: 'smtp.gmail.com',
    user: process.env.EMAIL_USER,
    password: process.env.EMAIL_PASSWORD
  }
});

// Process incoming emails
email.onEmail(async (message, context) => {
  // Classify the email
  const category = await classify(message.text, [
    'support', 'sales', 'feedback', 'spam'
  ]);

  if (category === 'support') {
    const response = await agent.run(
      `Respond to this support email: ${message.text}`
    );

    await context.reply({
      subject: `Re: ${message.subject}`,
      body: response
    });
  }
});

await email.start();

Document Processing

Extract and process documents with AI

import { DocsPlugin } from '@rana/plugins/docs';

const docs = new DocsPlugin({
  ocrProvider: 'google-vision',   // For scanned documents
  extractors: ['pdf', 'docx', 'xlsx', 'pptx']
});

// Extract text from any document
const content = await docs.extract(fileBuffer, {
  filename: 'report.pdf',
  ocr: true  // Enable OCR for scanned pages
});

// Extract structured data
const data = await docs.extractStructured(invoice, {
  schema: {
    vendor: 'string',
    amount: 'number',
    date: 'date',
    lineItems: 'array'
  }
});

// Summarize document
const summary = await docs.summarize(fileBuffer, {
  maxLength: 500,
  style: 'executive-summary'
});

Custom Plugins

Create your own plugins with the plugin API

import { createPlugin, PluginContext } from '@rana/core';

const myPlugin = createPlugin({
  name: 'my-plugin',
  version: '1.0.0',

  // Initialize
  async init(context: PluginContext) {
    console.log('Plugin initialized');
  },

  // Add tools to agents
  tools: [
    {
      name: 'my_tool',
      description: 'Does something useful',
      parameters: { query: { type: 'string' } },
      handler: async ({ query }) => {
        return await doSomething(query);
      }
    }
  ],

  // Add middleware
  middleware: [
    async (request, next) => {
      console.log('Before request');
      const response = await next(request);
      console.log('After request');
      return response;
    }
  ]
});

// Register plugin
agent.use(myPlugin);

All Available Plugins

@rana/plugins/slack
@rana/plugins/discord
@rana/plugins/voice
@rana/plugins/email
@rana/plugins/docs
@rana/plugins/notion
@rana/plugins/github
@rana/plugins/jira