Integrations Overview
Integrations
Section titled “Integrations”Microfn provides powerful integration capabilities that allow your serverless functions to connect with AI assistants, development tools, and external services. These integrations extend the reach of your functions beyond traditional HTTP APIs.
Available Integrations
Section titled “Available Integrations”| Integration | Description | Use Cases |
|---|---|---|
| Model Context Protocol (MCP) | Connect AI assistants to your functions | Claude, AI automation, intelligent workflows |
Model Context Protocol (MCP)
Section titled “Model Context Protocol (MCP)”MCP enables AI assistants like Claude to directly interact with your Microfn functions:
- Direct function discovery - AI can list and understand your functions
- Intelligent execution - AI determines when and how to call functions
- Context-aware responses - Functions provide data for AI reasoning
- Automated workflows - Chain multiple function calls intelligently
Quick Setup
Section titled “Quick Setup”// For Claude Desktop or other MCP clients{ "mcpServers": { "microfn": { "command": "npx", "args": ["-y", "mcp-remote", "https://mcp.microfn.dev/sse"] } }}API Integrations
Section titled “API Integrations”Microfn functions can integrate with any service that provides an API:
Webhook Receivers
Section titled “Webhook Receivers”Receive webhooks from external services:
// GitHub webhook receiverexport default async function main(input) { const { headers, body } = input; const event = headers["x-github-event"];
switch(event) { case "push": return handlePush(body); case "pull_request": return handlePR(body); default: return { received: true }; }}API Clients
Section titled “API Clients”Call external APIs from your functions:
import secret from "@microfn/secret";
export default async function main(input) { const apiKey = await secret.getRequired("EXTERNAL_API_KEY");
const response = await fetch("https://api.service.com/endpoint", { headers: { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json" }, body: JSON.stringify(input) });
return await response.json();}Platform Integrations
Section titled “Platform Integrations”Zapier
Section titled “Zapier”Connect Microfn to thousands of apps via Zapier:
- Use webhook triggers in Zapier
- Point to your Microfn function URL
- Process data and return results
- Continue workflow in Zapier
// Zapier-compatible functionexport default async function main(input) { // Process Zapier payload const result = await processData(input);
// Return in Zapier-expected format return { id: result.id, status: "success", data: result };}Make (Integromat)
Section titled “Make (Integromat)”Similar to Zapier, integrate with Make.com:
export default async function main(input) { // Make.com sends data in specific format const { trigger, data } = input;
const processed = await handleMakeWebhook(trigger, data);
return { success: true, output: processed };}Create applets that trigger Microfn functions:
export default async function main(input) { // IFTTT webhook format const { value1, value2, value3 } = input;
return { message: `Processed: ${value1}`, timestamp: new Date() };}Communication Platforms
Section titled “Communication Platforms”Build Slack apps and slash commands:
export default async function main(input) { const { command, text, user_name, channel_id } = input;
if (command === "/microfn") { const result = await processSlackCommand(text, user_name);
return { response_type: "in_channel", text: result.message, attachments: result.attachments }; }}Discord
Section titled “Discord”Create Discord bots and webhooks:
export default async function main(input) { const { content, author, channel } = input;
// Process Discord message const response = await handleDiscordMessage(content, author);
// Send to Discord webhook await sendDiscordWebhook(channel, response);
return { processed: true };}Microsoft Teams
Section titled “Microsoft Teams”Integrate with Teams workflows:
export default async function main(input) { const { type, from, text } = input;
if (type === "message") { return { type: "message", text: `Processed: ${text}` }; }}Development Tools
Section titled “Development Tools”GitHub Actions
Section titled “GitHub Actions”Trigger functions from GitHub workflows:
name: Deployon: [push]jobs: notify: runs-on: ubuntu-latest steps: - name: Trigger Microfn run: | curl -X POST https://microfn.dev/run/user/function \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${{ secrets.MICROFN_TOKEN }}" \ -d '{"event": "deploy", "sha": "${{ github.sha }}"}'CI/CD Pipelines
Section titled “CI/CD Pipelines”Integrate with any CI/CD system:
// Deployment notification functionexport default async function main(input) { const { pipeline, status, commit, branch } = input;
// Log deployment await logDeployment({ pipeline, status, commit, branch, timestamp: new Date() });
// Send notifications if (status === "failed") { await notifyTeam("Deployment failed", input); }
return { logged: true };}Database Integrations
Section titled “Database Integrations”Supabase
Section titled “Supabase”import { createClient } from '@supabase/supabase-js';import secret from "@microfn/secret";
export default async function main(input) { const supabaseUrl = await secret.getRequired("SUPABASE_URL"); const supabaseKey = await secret.getRequired("SUPABASE_KEY");
const supabase = createClient(supabaseUrl, supabaseKey);
const { data, error } = await supabase .from('users') .select('*') .eq('id', input.userId);
return { user: data[0], error };}Firebase
Section titled “Firebase”import { initializeApp } from 'firebase/app';import { getFirestore } from 'firebase/firestore';import secret from "@microfn/secret";
export default async function main(input) { const firebaseConfig = JSON.parse( await secret.getRequired("FIREBASE_CONFIG") );
const app = initializeApp(firebaseConfig); const db = getFirestore(app);
// Use Firestore const doc = await db.collection('users').doc(input.userId).get();
return { user: doc.data() };}Payment Integrations
Section titled “Payment Integrations”Stripe
Section titled “Stripe”import Stripe from 'stripe';import secret from "@microfn/secret";
export default async function main(input) { const stripe = new Stripe( await secret.getRequired("STRIPE_SECRET_KEY") );
// Handle Stripe webhook const { type, data } = input;
switch(type) { case "payment_intent.succeeded": return handlePaymentSuccess(data.object); case "customer.subscription.created": return handleNewSubscription(data.object); default: return { received: true }; }}PayPal
Section titled “PayPal”export default async function main(input) { const { event_type, resource } = input;
// Verify PayPal webhook const verified = await verifyPayPalWebhook(input);
if (!verified) { return { error: "Invalid webhook signature" }; }
// Process PayPal event switch(event_type) { case "PAYMENT.CAPTURE.COMPLETED": return handlePaymentComplete(resource); default: return { processed: true }; }}Analytics Integrations
Section titled “Analytics Integrations”Google Analytics
Section titled “Google Analytics”export default async function main(input) { const { event, parameters } = input;
// Send to Google Analytics await fetch(`https://www.google-analytics.com/mp/collect`, { method: 'POST', body: JSON.stringify({ client_id: input.clientId, events: [{ name: event, params: parameters }] }) });
return { tracked: true };}Mixpanel
Section titled “Mixpanel”import Mixpanel from 'mixpanel';
export default async function main(input) { const mixpanel = Mixpanel.init( await secret.getRequired("MIXPANEL_TOKEN") );
mixpanel.track(input.event, { distinct_id: input.userId, ...input.properties });
return { tracked: true };}Custom Integrations
Section titled “Custom Integrations”Build custom integrations for any service:
import secret from "@microfn/secret";
class CustomServiceClient { constructor(apiKey) { this.apiKey = apiKey; this.baseUrl = "https://api.customservice.com"; }
async request(endpoint, data) { const response = await fetch(`${this.baseUrl}${endpoint}`, { method: 'POST', headers: { 'Authorization': `Bearer ${this.apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify(data) });
return await response.json(); }}
export default async function main(input) { const apiKey = await secret.getRequired("CUSTOM_SERVICE_KEY"); const client = new CustomServiceClient(apiKey);
const result = await client.request('/process', input);
return result;}Best Practices
Section titled “Best Practices”- Use environment variables for API keys and secrets
- Validate webhooks with signatures when available
- Implement retry logic for unreliable services
- Cache responses to reduce API calls
- Log integration events for debugging
- Handle rate limits gracefully
- Document integration requirements
- Test with webhook tools like ngrok or webhook.site
Next Steps
Section titled “Next Steps”- Model Context Protocol (MCP) - Deep dive into AI assistant integration