Mirra
Get Started

Mirra SDK

Overview of the Mirra SDK tools and libraries

The Mirra SDK provides a typed, idiomatic interface for interacting with the Mirra Platform. It is available for TypeScript/Node.js.

Installation

npm install @mirra-messenger/sdk

View on npm

Authentication

Initialize the SDK with your API key (from the web portal or mobile app):

import { MirraSDK } from '@mirra-messenger/sdk';
 
const mirra = new MirraSDK({
  apiKey: process.env.MIRRA_API_KEY
});

Always load your API key from environment variables rather than hardcoding it.

Core Modules

The SDK provides programmatic access to:

Memory

Store and retrieve knowledge with semantic search capabilities.

// Create a memory entity
await mirra.memory.create({
  type: 'note',
  content: 'Important meeting notes...',
  metadata: { topic: 'project-x' }
});
 
// Semantic search
const results = await mirra.memory.search({
  query: 'meeting notes about project',
  limit: 10
});

AI

Access language models for chat, streaming, and decision-making.

// Chat completion
const response = await mirra.ai.chat({
  messages: [{ role: 'user', content: 'Summarize this document...' }],
  model: 'claude-3-5-sonnet'
});
 
// Streaming response
for await (const chunk of mirra.ai.chatStream({ messages })) {
  process.stdout.write(chunk.delta);
}
 
// Decision making with reasoning
const decision = await mirra.ai.decide({
  prompt: 'Which approach should we take?',
  options: [
    { id: 'a', label: 'Option A' },
    { id: 'b', label: 'Option B' }
  ]
});

Scripts

Deploy and execute serverless functions.

// Create a script
const script = await mirra.scripts.create({
  name: 'My Automation',
  description: 'Processes incoming data',
  code: 'async function main(params) { return { success: true }; } module.exports = { main };',
  runtime: 'nodejs18'
});
 
// Execute a script
const result = await mirra.scripts.invoke({
  scriptId: script.id,
  payload: { data: 'input' }
});

Resources

Manage API integrations and call external services.

// List available resources
const resources = await mirra.resources.list();
 
// Call a resource method
const result = await mirra.resources.call({
  resourceId: 'google-calendar',
  method: 'listEvents',
  params: { maxResults: 10 }
});

Documents

Upload, process, and search documents in your knowledge graph.

// Upload a document
const doc = await mirra.documents.upload({
  file: base64Content,
  filename: 'report.pdf',
  mimeType: 'application/pdf'
});
 
// Search across documents
const results = await mirra.documents.search({
  query: 'quarterly revenue',
  limit: 5
});

Flows

Create event-driven and scheduled automations.

// Create an event-triggered flow
const flow = await mirra.flows.createEventFlow({
  title: 'New Message Handler',
  description: 'Responds to incoming messages',
  trigger: {
    type: 'event',
    config: { eventSource: 'telegram' }
  },
  scriptId: 'my-script-id'
});
 
// Create a scheduled flow
const cronFlow = await mirra.flows.createTimeFlow({
  title: 'Daily Report',
  description: 'Generates daily summary',
  trigger: {
    type: 'time',
    config: { cronExpression: '0 9 * * *' }
  },
  scriptId: 'report-script-id'
});

Templates

Browse and install pre-built automation templates.

// List available templates
const templates = await mirra.templates.list();
 
// Install a template
await mirra.templates.install('template-id');

Marketplace

Discover scripts, resources, and templates from the community.

// Browse marketplace
const items = await mirra.marketplace.browse({
  type: 'script',
  category: 'productivity'
});
 
// Search
const results = await mirra.marketplace.search('email automation');

Integration Adapters

The SDK includes pre-built adapters for popular services:

CategoryIntegrations
MessagingTelegram, Mirra Messaging
GoogleGmail, Calendar, Drive, Sheets, Docs
ProductivityJira, Trello
SocialTwitter
CryptoJupiter Exchange, Wallet operations

Access adapters directly on the SDK instance:

// Send a Telegram message
await mirra.telegram.sendMessage({
  chatId: '123456',
  text: 'Hello from Mirra!'
});
 
// Create a Google Calendar event
await mirra.googleCalendar.createEvent({
  title: 'Team Meeting',
  startTime: '2025-01-30T10:00:00Z',
  endTime: '2025-01-30T11:00:00Z'
});

For more details, see the Authentication Guide.

On this page