Skip to main content
Glama

sendEvent

Track customer behavior and trigger automations by sending custom or predefined system events to Omnisend. Utilize event data, including contact details and properties, for targeted marketing actions.

Instructions

Send a customer event to Omnisend. Events are used to track customer behavior and can trigger automations. Can be custom events or predefined system events.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
eventDataYesEvent data

Implementation Reference

  • The MCP tool handler that processes input arguments, invokes the sendEvent helper, filters the response, and formats the output as text content or error message.
    async (args) => { try { const response = await sendEvent(args.eventData); // Filter event data to include only defined fields const filteredEvent = filterEventFields(response); return { content: [ { type: "text", text: JSON.stringify(filteredEvent, null, 2) } ] }; } catch (error) { if (error instanceof Error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } return { content: [{ type: "text", text: "An unknown error occurred" }] }; } } );
  • JSON schema defining the input parameters for the sendEvent tool, requiring eventData with eventName and contact.
    { additionalProperties: false, properties: { eventData: { additionalProperties: false, description: "Event data", properties: { eventName: { description: "Event name", type: "string" }, eventTime: { description: "Event time in RFC3339 format", type: "string" }, eventVersion: { description: "Event version", type: "string" }, contact: { additionalProperties: true, description: "Contact information", properties: { contactID: { type: "string" }, email: { type: "string" }, firstName: { type: "string" }, lastName: { type: "string" }, phone: { type: "string" } }, type: "object" }, properties: { additionalProperties: true, description: "Additional event properties", properties: {}, type: "object" } }, required: ["eventName", "contact"], type: "object" } }, required: ["eventData"], type: "object" },
  • Registers the sendEvent tool on the MCP server, including name, description, schema, and handler function.
    export const registerEventsTools = (server: McpServer) => { // Send event tool server.tool( "sendEvent", "Send a customer event to Omnisend. Events are used to track customer behavior and can trigger automations. Can be custom events or predefined system events.", { additionalProperties: false, properties: { eventData: { additionalProperties: false, description: "Event data", properties: { eventName: { description: "Event name", type: "string" }, eventTime: { description: "Event time in RFC3339 format", type: "string" }, eventVersion: { description: "Event version", type: "string" }, contact: { additionalProperties: true, description: "Contact information", properties: { contactID: { type: "string" }, email: { type: "string" }, firstName: { type: "string" }, lastName: { type: "string" }, phone: { type: "string" } }, type: "object" }, properties: { additionalProperties: true, description: "Additional event properties", properties: {}, type: "object" } }, required: ["eventName", "contact"], type: "object" } }, required: ["eventData"], type: "object" }, async (args) => { try { const response = await sendEvent(args.eventData); // Filter event data to include only defined fields const filteredEvent = filterEventFields(response); return { content: [ { type: "text", text: JSON.stringify(filteredEvent, null, 2) } ] }; } catch (error) { if (error instanceof Error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } return { content: [{ type: "text", text: "An unknown error occurred" }] }; } } ); };
  • Helper function that performs the actual API call to POST event data to Omnisend's /events endpoint.
    export const sendEvent = async (eventData: Partial<Event>): Promise<Event> => { try { const response = await omnisendApi.post<Event>('/events', eventData); return response.data; } catch (error) { if (error instanceof Error) { throw new Error(`Error sending event: ${error.message}`); } else { throw new Error('Unknown error occurred when sending event'); } } };
  • Helper function used in the tool handler to filter and sanitize the event response fields before returning.
    export const filterEventFields = (event: any) => { return { eventID: event.eventID, eventName: event.eventName, email: event.email, phone: event.phone, contactID: event.contactID, contact: event.contact ? filterContactFields(event.contact) : undefined, properties: event.properties, createdAt: event.createdAt }; };

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/plutzilla/omnisend-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server