Skip to main content

Quick Start

Get up and running with the MuluTime Plugin SDK in less than 5 minutes. This guide will walk you through creating your first plugin step by step.

🚀 Installation

# Create a new project
mkdir my-mulutime-plugin
cd my-mulutime-plugin

# Initialize package.json
npm init -y

# Install the SDK
npm install @mulutime/plugin-sdk

# Install development dependencies
npm install -D typescript @types/node

📋 Your First Plugin

Let's create a simple notification plugin that sends emails when bookings are created.

Step 1: TypeScript Configuration

Create tsconfig.json:

{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"sourceMap": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}

Step 2: Create Your Plugin

Create src/index.ts:

import {
BasePlugin,
PluginManifest,
PluginCategory,
PluginPermission,
SystemEventType,
SystemEventPayload,
PluginContext
} from '@mulutime/plugin-sdk';

export class EmailNotificationPlugin extends BasePlugin {
manifest: PluginManifest = {
id: 'com.yourcompany.email-notifications',
name: 'Email Notifications',
version: '1.0.0',
description: 'Sends email notifications for booking events',
author: {
name: 'Your Name',
email: 'your.email@company.com'
},
license: 'MIT',
category: PluginCategory.NOTIFICATION,
type: [],
permissions: [
PluginPermission.READ_BOOKING_DATA,
PluginPermission.EXTERNAL_API_ACCESS
],
apiVersion: '1.0.0',
minSystemVersion: '1.0.0',
main: 'dist/index.js'
};

async onInstall(context: PluginContext): Promise<void> {
context.logger.info('Email notification plugin installed!');
// Initialize your plugin here
}

// Handle booking created events
async onBookingCreated(event: SystemEventPayload, context: PluginContext): Promise<void> {
const { bookingId, customerEmail, service } = event.data;

context.logger.info(`New booking created: ${bookingId}`);

// Send confirmation email
await this.sendEmail(context, {
to: customerEmail,
subject: `Booking Confirmed - ${service.name}`,
body: `Your booking has been confirmed!`
});
}

private async sendEmail(context: PluginContext, email: { to: string; subject: string; body: string }) {
// Your email sending logic here
context.logger.info(`Email sent to ${email.to}`);
}
}

// Export the plugin instance
export default new EmailNotificationPlugin();

Step 3: Build Your Plugin

Add build scripts to package.json:

{
"scripts": {
"build": "tsc",
"dev": "tsc --watch"
}
}

Then build:

npm run build

Step 4: Test Your Plugin

Create a simple test file test.ts:

import { TestUtils } from '@mulutime/plugin-sdk';
import { EmailNotificationPlugin } from './src/index';

async function testPlugin() {
const plugin = new EmailNotificationPlugin();
const mockContext = TestUtils.createMockContext({
pluginId: plugin.manifest.id,
permissions: plugin.manifest.permissions
});

// Test installation
await plugin.onInstall(mockContext);

// Test event handling
const mockEvent = TestUtils.createMockEvent('BOOKING_CREATED', {
bookingId: 'test-123',
customerEmail: 'test@example.com',
service: { name: 'Test Service' }
});

await plugin.onBookingCreated(mockEvent, mockContext);

console.log('Plugin test completed successfully!');
}

testPlugin().catch(console.error);

🎉 Congratulations!

You've created your first MuluTime plugin! Here's what you accomplished:

Set up a new plugin project
Created a plugin with event handling
Built the plugin with TypeScript
Tested the plugin functionality

Next Steps

📚 Learn Core Concepts

Understand plugin manifests, contexts, and lifecycle hooks

Learn More

🔧 Explore Examples

Check out real-world plugin examples and use cases

View Examples

Need Help?