The Cookbook.

Patterns for common integration scenarios. All examples use standard Node.js/Express.

Pattern 01

Simple Data Fetch

The most common pattern. The AI asks for data (e.g. Stock Price, Weather, Status), acts as a proxy, and returns JSON.

GET
app.post("/weather", (req, res) => {
  const { city } = req.body;
  // Mock response
  res.json({ 
    temp: 22, 
    condition: "Sunny",
    city: city 
  });
});
Pattern 02

Third-Party SDK Wrapper

Wrap an existing heavy SDK (Notion, Salesforce, Stripe) in a lightweight endpoint.

Tip: Use configurationSchema to let users input their own OAuth tokens.

SDK
const { Client } = require("@notionhq/client");

app.post("/notion/search", async (req, res) => {
  const { query } = req.body;
  const notion = new Client({ auth: process.env.NOTION_KEY });
  
  const response = await notion.search({
    query: query,
    filter: { property: "object", value: "page" }
  });
  
  res.json({ 
    results: response.results.map(p => ({ 
      id: p.id, 
      title: p.properties.Name.title[0].plain_text 
    }))
  });
});
Pattern 03

Utility / Logic

Offload complex logic that LLMs struggle with (Date math, Encryption, Complex Regex) to deterministic code.

UTIL
app.post("/calc", (req, res) => {
  const { expression } = req.body;
  
  // Safe eval using a math library recommended
  try {
    const result = eval(expression.replace(/[^0-9+\-*/().]/g, ''));
    res.json({ result });
  } catch {
    res.status(400).json({ error: "Invalid expression" });
  }
});