Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
How to use Mailofly with OpenAI, Anthropic Claude, and LangChain function calling.
import OpenAI from "openai"; import { Mailofly } from "@mailofly/node"; const openai = new OpenAI(); const mailofly = new Mailofly(process.env.MAILOFLY_API_KEY!); const emailTools: OpenAI.ChatCompletionTool[] = [ { type: "function", function: { name: "send_email", description: "Send an email to a user via Mailofly.", parameters: { type: "object", properties: { to: { type: "string", description: "Recipient email address" }, subject: { type: "string", description: "Subject line of the email" }, body: { type: "string", description: "HTML content of the email" }, }, required: ["to", "subject", "body"], }, }, }, ];
async function handleToolCall(toolCall: OpenAI.ChatCompletionMessageToolCall) { if (toolCall.function.name === "send_email") { const args = JSON.parse(toolCall.function.arguments); const result = await mailofly.emails.send({ from: "AI Assistant <assistant@yourdomain.com>", to: args.to, subject: args.subject, html: args.body, }); return JSON.stringify(result); } }