create_draft_email
Create draft emails in HubSpot by defining campaign details, content, and recipient settings for marketing communications.
Instructions
メールの下書きを作成。既存メールを複製する場合はget_emailで取得したcontent等を渡す
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | キャンペーン名 | |
| subject | Yes | メール件名 | |
| htmlBody | No | HTML本文(シンプルなメール用) | |
| content | No | メールコンテンツ構造(flexAreas, widgets等を含む詳細設定) | |
| from | No | 送信者情報 { fromName, replyTo } | |
| subscriptionDetails | No | 配信設定 { officeLocationId } | |
| to | No | 送信先設定 { contactIlsLists, suppressGraymail } |
Implementation Reference
- src/server.ts:118-139 (handler)The MCP tool handler that executes create_draft_email. It parses the request arguments using CreateDraftEmailSchema, calls the HubSpot client's createDraftEmail method, and returns a success message with the email ID, name, and subject.case 'create_draft_email': { const args = CreateDraftEmailSchema.parse(request.params.arguments); const result = await this.hubspot.createDraftEmail( args.name, args.subject, { htmlBody: args.htmlBody, content: args.content, from: args.from, subscriptionDetails: args.subscriptionDetails, to: args.to, } ); return { content: [ { type: 'text', text: `✅ メール下書きを作成しました\nID: ${result.id}\n名前: ${args.name}\n件名: ${args.subject}`, }, ], }; }
- src/hubspot/client.ts:58-91 (handler)The HubSpot API client implementation of createDraftEmail. Constructs the email data object with name, subject, emailType 'BATCH_EMAIL', and state 'DRAFT', then optionally adds htmlBody, content, from, subscriptionDetails, and to fields before calling the createEmail method.async createDraftEmail( name: string, subject: string, options?: { htmlBody?: string; content?: any; from?: any; subscriptionDetails?: any; to?: any; } ) { const data: any = { name, subject, emailType: 'BATCH_EMAIL', state: 'DRAFT', }; if (options?.htmlBody) { data.emailBody = options.htmlBody; } if (options?.content) { data.content = options.content; } if (options?.from) { data.from = options.from; } if (options?.subscriptionDetails) { data.subscriptionDetails = options.subscriptionDetails; } if (options?.to) { data.to = options.to; } return this.createEmail(data); }
- src/tools/types.ts:13-21 (schema)Zod schema definition for CreateDraftEmailSchema. Validates the input parameters including required fields (name, subject) and optional fields (htmlBody, content, from, subscriptionDetails, to).export const CreateDraftEmailSchema = z.object({ name: z.string().describe('メールキャンペーンの名前'), subject: z.string().describe('メールの件名'), htmlBody: z.string().optional().describe('HTMLメール本文(シンプルなメール用)'), content: z.any().optional().describe('メールコンテンツ構造(flexAreas, widgets等を含む詳細設定)'), from: z.any().optional().describe('送信者情報 { fromName, replyTo }'), subscriptionDetails: z.any().optional().describe('配信設定 { officeLocationId }'), to: z.any().optional().describe('送信先設定 { contactIlsLists, suppressGraymail }'), });
- src/server.ts:64-78 (registration)Tool registration in the MCP server's tools list. Defines the create_draft_email tool with its description and input schema including required fields (name, subject) and optional fields (htmlBody, content, from, subscriptionDetails, to).name: 'create_draft_email', description: 'メールの下書きを作成。既存メールを複製する場合はget_emailで取得したcontent等を渡す', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'キャンペーン名' }, subject: { type: 'string', description: 'メール件名' }, htmlBody: { type: 'string', description: 'HTML本文(シンプルなメール用)' }, content: { type: 'object', description: 'メールコンテンツ構造(flexAreas, widgets等を含む詳細設定)' }, from: { type: 'object', description: '送信者情報 { fromName, replyTo }' }, subscriptionDetails: { type: 'object', description: '配信設定 { officeLocationId }' }, to: { type: 'object', description: '送信先設定 { contactIlsLists, suppressGraymail }' }, }, required: ['name', 'subject'], },
- src/hubspot/client.ts:42-47 (helper)Helper method createEmail that performs the actual POST request to HubSpot's /marketing/v3/emails endpoint with the provided data. Called by createDraftEmail after constructing the email data object.async createEmail(data: any) { return this.request('/marketing/v3/emails', { method: 'POST', body: JSON.stringify(data), }); }