Install the SDK.
Install and run the Server.
Write code.
// app-node.ts
import express, { Request, Response } from "express";
import { Resonate, Context } from "@resonatehq/sdk";
// Initialize Resonate Scheduler
const resonate = new Resonate();
// Define your workflow
export async function downloadAndSummarize(ctx: Context, url: string) {
const content = await ctx.run(download, url);
conar summary = await ctx.run(summarize, content);
return summary;
}
async function download(ctx: Context, url: string): string {
return "This is the content";
}
async function summarize(ctx: Context, content: string): string {
return "This is the summary";
}
resonate.register(
"downloadAndSummarize",
downloadAndSummarize,
);
// Start the Resonate application
resonate.start();
// Define a route handler for the /summarize endpoint
app.post("/summarize", async (req: Request, res: Response) => {
const url = req.body?.url;
try {
// Call the resonate function
let summary = await resonate.run(
"downloadAndSummarize",
"summarize-" + url,
url
);
res.send(summary);
} catch (e) {
res.status(500).send("An error occurred.");
}
});
app.listen(3000, () => {
console.log("Listening on port 3000");
});
Continue building an AI summarization agent with the quickstart tutorial.