broadcastCampaignToList
Send targeted email campaigns to specific contact lists with a single API request. Personalize content and ensure safe retries using unique keys for efficiency.
Instructions
The broadcast campaign API allows the user to trigger campaigns to the entire contact list using a single API request.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| campaignId | Yes | Campaign id of the campaign to be triggered | |
| campaign_data | No | Optional set of personalization parameters for the campaign. Each key represents a variable (e.g., "first_name") to be used in the email template. If a key is missing, the backend will fetch values from contact properties or default to an empty string. | |
| idempotencyKey | No | Optional unique key to allow retries of the same campaign within 24 hours. Allows safe resending. For example: "2024-09-05T17:00:00Z". | |
| listId | Yes | Id of the contact list or segment for which the campaign should be triggered. | |
| subject | No | Optional subject line of the campaign. This will appear as the subject of the email sent to recipients. |
Implementation Reference
- src/server.ts:467-491 (handler)The handler function for the 'broadcastCampaignToList' tool. It receives parameters, calls bulkTriggerMailmodoCampaign to perform the broadcast, and formats the response as MCP content.async (params) => { try { const { campaignId, ...newparams } = params; const respone = await bulkTriggerMailmodoCampaign(mmApiKey, params.campaignId, newparams); // Here you would typically integrate with your event sending system // For example: eventBus.emit(eventName, eventData) // For demonstration, we'll just return a success message return { content: [{ type: "text", text: respone.message ?`Successfully sent email to '${params.listId} for the campaignId ${params.campaignId} with message ${respone.message}.`: `Something went wrong. Please check if the email is correct`, }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : "Failed to delete", }], isError: true }; } }
- src/server.ts:443-466 (schema)Input schema validation using Zod for the 'broadcastCampaignToList' tool parameters.{ campaignId: z.string().describe('Campaign id of the campaign to be triggered'), listId: z .string({ required_error: 'listId is required', invalid_type_error: 'listId must be a string', }) .describe('Id of the contact list or segment for which the campaign should be triggered.'), subject: z .string() .optional() .describe('Optional subject line of the campaign. This will appear as the subject of the email sent to recipients.'), idempotencyKey: z .string() .optional() .describe('Optional unique key to allow retries of the same campaign within 24 hours. Allows safe resending. For example: "2024-09-05T17:00:00Z".'), campaign_data: z .record(z.string()) .optional() .describe('Optional set of personalization parameters for the campaign. Each key represents a variable (e.g., "first_name") to be used in the email template. If a key is missing, the backend will fetch values from contact properties or default to an empty string.'), },
- src/server.ts:440-492 (registration)Registration of the 'broadcastCampaignToList' MCP tool on the server, specifying name, description, input schema, and handler.server.tool( "broadcastCampaignToList", "The broadcast campaign API allows the user to trigger campaigns to the entire contact list using a single API request.", { campaignId: z.string().describe('Campaign id of the campaign to be triggered'), listId: z .string({ required_error: 'listId is required', invalid_type_error: 'listId must be a string', }) .describe('Id of the contact list or segment for which the campaign should be triggered.'), subject: z .string() .optional() .describe('Optional subject line of the campaign. This will appear as the subject of the email sent to recipients.'), idempotencyKey: z .string() .optional() .describe('Optional unique key to allow retries of the same campaign within 24 hours. Allows safe resending. For example: "2024-09-05T17:00:00Z".'), campaign_data: z .record(z.string()) .optional() .describe('Optional set of personalization parameters for the campaign. Each key represents a variable (e.g., "first_name") to be used in the email template. If a key is missing, the backend will fetch values from contact properties or default to an empty string.'), }, async (params) => { try { const { campaignId, ...newparams } = params; const respone = await bulkTriggerMailmodoCampaign(mmApiKey, params.campaignId, newparams); // Here you would typically integrate with your event sending system // For example: eventBus.emit(eventName, eventData) // For demonstration, we'll just return a success message return { content: [{ type: "text", text: respone.message ?`Successfully sent email to '${params.listId} for the campaignId ${params.campaignId} with message ${respone.message}.`: `Something went wrong. Please check if the email is correct`, }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : "Failed to delete", }], isError: true }; } } );
- TypeScript interface defining the structure for bulk trigger campaign request, used likely by the tool's helper function.export interface BulkTriggerCampaignRequest { listId: string; subject?: string; idempotencyKey?: string; campaign_data?: Record<string, string>; }