Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions apps/docs/content/docs/tools/gmail.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Send emails using Gmail
| `to` | string | Yes | Recipient email address |
| `subject` | string | Yes | Email subject |
| `body` | string | Yes | Email body content |
| `cc` | string | No | CC recipients \(comma-separated\) |
| `bcc` | string | No | BCC recipients \(comma-separated\) |

#### Output

Expand All @@ -87,6 +89,8 @@ Draft emails using Gmail
| `to` | string | Yes | Recipient email address |
| `subject` | string | Yes | Email subject |
| `body` | string | Yes | Email body content |
| `cc` | string | No | CC recipients \(comma-separated\) |
| `bcc` | string | No | BCC recipients \(comma-separated\) |

#### Output

Expand All @@ -107,13 +111,15 @@ Read emails from Gmail
| `folder` | string | No | Folder/label to read emails from |
| `unreadOnly` | boolean | No | Only retrieve unread messages |
| `maxResults` | number | No | Maximum number of messages to retrieve \(default: 1, max: 10\) |
| `includeAttachments` | boolean | No | Download and include email attachments |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `content` | string | Email content or summary |
| `metadata` | object | Email metadata |
| `content` | string | Text content of the email |
| `metadata` | json | Metadata of the email |
| `attachments` | file[] | Attachments of the email |

### `gmail_search`

Expand Down
1 change: 1 addition & 0 deletions apps/docs/content/docs/tools/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"exa",
"file",
"firecrawl",
"generic_webhook",
"github",
"gmail",
"google_calendar",
Expand Down
2 changes: 2 additions & 0 deletions apps/docs/content/docs/tools/outlook.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ Draft emails using Outlook
| `to` | string | Yes | Recipient email address |
| `subject` | string | Yes | Email subject |
| `body` | string | Yes | Email body content |
| `cc` | string | No | CC recipients \(comma-separated\) |
| `bcc` | string | No | BCC recipients \(comma-separated\) |

#### Output

Expand Down
23 changes: 23 additions & 0 deletions apps/sim/blocks/blocks/gmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,27 @@ export const GmailBlock: BlockConfig<GmailToolResponse> = {
condition: { field: 'operation', value: ['send_gmail', 'draft_gmail'] },
required: true,
},
// Advanced Settings - Additional Recipients
{
id: 'cc',
title: 'CC',
type: 'short-input',
layout: 'full',
placeholder: 'CC recipients (comma-separated)',
condition: { field: 'operation', value: ['send_gmail', 'draft_gmail'] },
mode: 'advanced',
required: false,
},
{
id: 'bcc',
title: 'BCC',
type: 'short-input',
layout: 'full',
placeholder: 'BCC recipients (comma-separated)',
condition: { field: 'operation', value: ['send_gmail', 'draft_gmail'] },
mode: 'advanced',
required: false,
},
// Label/folder selector (basic mode)
{
id: 'folder',
Expand Down Expand Up @@ -198,6 +219,8 @@ export const GmailBlock: BlockConfig<GmailToolResponse> = {
to: { type: 'string', description: 'Recipient email address' },
subject: { type: 'string', description: 'Email subject' },
body: { type: 'string', description: 'Email content' },
cc: { type: 'string', description: 'CC recipients (comma-separated)' },
bcc: { type: 'string', description: 'BCC recipients (comma-separated)' },
// Read operation inputs
folder: { type: 'string', description: 'Gmail folder' },
manualFolder: { type: 'string', description: 'Manual folder name' },
Expand Down
29 changes: 24 additions & 5 deletions apps/sim/tools/gmail/draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ export const gmailDraftTool: ToolConfig<GmailSendParams, GmailToolResponse> = {
visibility: 'user-or-llm',
description: 'Email body content',
},
cc: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'CC recipients (comma-separated)',
},
bcc: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'BCC recipients (comma-separated)',
},
},

request: {
Expand All @@ -70,14 +82,21 @@ export const gmailDraftTool: ToolConfig<GmailSendParams, GmailToolResponse> = {
'Content-Type': 'application/json',
}),
body: (params: GmailSendParams): Record<string, any> => {
const email = [
const emailHeaders = [
'Content-Type: text/plain; charset="UTF-8"',
'MIME-Version: 1.0',
`To: ${params.to}`,
`Subject: ${params.subject}`,
'',
params.body,
].join('\n')
]

if (params.cc) {
emailHeaders.push(`Cc: ${params.cc}`)
}
if (params.bcc) {
emailHeaders.push(`Bcc: ${params.bcc}`)
}

emailHeaders.push(`Subject: ${params.subject}`, '', params.body)
const email = emailHeaders.join('\n')

return {
message: {
Expand Down
6 changes: 3 additions & 3 deletions apps/sim/tools/gmail/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export const gmailReadTool: ToolConfig<GmailReadParams, GmailToolResponse> = {
},

outputs: {
content: { type: 'string' },
metadata: { type: 'json' },
attachments: { type: 'file[]' },
content: { type: 'string', description: 'Text content of the email' },
metadata: { type: 'json', description: 'Metadata of the email' },
attachments: { type: 'file[]', description: 'Attachments of the email' },
},

params: {
Expand Down
29 changes: 24 additions & 5 deletions apps/sim/tools/gmail/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ export const gmailSendTool: ToolConfig<GmailSendParams, GmailToolResponse> = {
visibility: 'user-or-llm',
description: 'Email body content',
},
cc: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'CC recipients (comma-separated)',
},
bcc: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'BCC recipients (comma-separated)',
},
},

request: {
Expand All @@ -63,14 +75,21 @@ export const gmailSendTool: ToolConfig<GmailSendParams, GmailToolResponse> = {
'Content-Type': 'application/json',
}),
body: (params: GmailSendParams): Record<string, any> => {
const email = [
const emailHeaders = [
'Content-Type: text/plain; charset="UTF-8"',
'MIME-Version: 1.0',
`To: ${params.to}`,
`Subject: ${params.subject}`,
'',
params.body,
].join('\n')
]

if (params.cc) {
emailHeaders.push(`Cc: ${params.cc}`)
}
if (params.bcc) {
emailHeaders.push(`Bcc: ${params.bcc}`)
}

emailHeaders.push(`Subject: ${params.subject}`, '', params.body)
const email = emailHeaders.join('\n')

return {
raw: Buffer.from(email).toString('base64url'),
Expand Down
2 changes: 2 additions & 0 deletions apps/sim/tools/gmail/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ interface BaseGmailParams {
// Send operation parameters
export interface GmailSendParams extends BaseGmailParams {
to: string
cc?: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider updating the EmailMetadata interface (lines 40-45) to include a cc field for consistency with the new parameter

bcc?: string
subject: string
body: string
}
Expand Down
46 changes: 38 additions & 8 deletions apps/sim/tools/outlook/draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ export const outlookDraftTool: ToolConfig<OutlookDraftParams, OutlookDraftRespon
visibility: 'user-or-llm',
description: 'Email body content',
},
cc: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'CC recipients (comma-separated)',
},
bcc: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'BCC recipients (comma-separated)',
},
},

outputs: {
Expand Down Expand Up @@ -65,20 +77,38 @@ export const outlookDraftTool: ToolConfig<OutlookDraftParams, OutlookDraftRespon
}
},
body: (params: OutlookDraftParams): Record<string, any> => {
return {
// Helper function to parse comma-separated emails
const parseEmails = (emailString?: string) => {
if (!emailString) return []
return emailString
.split(',')
.map((email) => email.trim())
.filter((email) => email.length > 0)
.map((email) => ({ emailAddress: { address: email } }))
}

const message: any = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Using any type reduces type safety. Consider defining a proper interface for the message structure

Context Used: Context - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used to maintain type safety. (link)

subject: params.subject,
body: {
contentType: 'Text',
content: params.body,
},
toRecipients: [
{
emailAddress: {
address: params.to,
},
},
],
toRecipients: parseEmails(params.to),
}

// Add CC if provided
const ccRecipients = parseEmails(params.cc)
if (ccRecipients.length > 0) {
message.ccRecipients = ccRecipients
}

// Add BCC if provided
const bccRecipients = parseEmails(params.bcc)
if (bccRecipients.length > 0) {
message.bccRecipients = bccRecipients
}

return message
},
},
transformResponse: async (response) => {
Expand Down
2 changes: 2 additions & 0 deletions apps/sim/tools/outlook/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export interface OutlookReadResponse extends ToolResponse {
export interface OutlookDraftParams {
accessToken: string
to: string
cc?: string
bcc?: string
subject: string
body: string
}
Expand Down