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
532 changes: 518 additions & 14 deletions apps/sim/blocks/blocks/trello.ts

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions apps/sim/tools/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3859,19 +3859,27 @@ import {
tinybirdTruncateDatasourceTool,
} from '@/tools/tinybird'
import {
trelloAddChecklistItemTool,
trelloAddChecklistTool,
trelloAddCommentTool,
trelloAddLabelTool,
trelloAddMemberTool,
trelloCreateBoardTool,
trelloCreateCardTool,
trelloCreateListTool,
trelloDeleteCardTool,
trelloGetActionsTool,
trelloGetBoardTool,
trelloGetCardTool,
trelloListCardsTool,
trelloListListsTool,
trelloListMembersTool,
trelloRemoveLabelTool,
trelloRemoveMemberTool,
trelloSearchTool,
trelloUpdateCardTool,
trelloUpdateChecklistItemTool,
trelloUpdateListTool,
} from '@/tools/trello'
import {
triggerDevActivateScheduleTool,
Expand Down Expand Up @@ -6511,15 +6519,23 @@ export const tools: Record<string, ToolConfig> = {
trello_list_cards: trelloListCardsTool,
trello_create_card: trelloCreateCardTool,
trello_update_card: trelloUpdateCardTool,
trello_delete_card: trelloDeleteCardTool,
trello_get_actions: trelloGetActionsTool,
trello_add_comment: trelloAddCommentTool,
trello_create_board: trelloCreateBoardTool,
trello_get_board: trelloGetBoardTool,
trello_create_list: trelloCreateListTool,
trello_update_list: trelloUpdateListTool,
trello_get_card: trelloGetCardTool,
trello_add_checklist: trelloAddChecklistTool,
trello_add_checklist_item: trelloAddChecklistItemTool,
trello_update_checklist_item: trelloUpdateChecklistItemTool,
trello_add_label: trelloAddLabelTool,
trello_remove_label: trelloRemoveLabelTool,
trello_add_member: trelloAddMemberTool,
trello_remove_member: trelloRemoveMemberTool,
trello_list_members: trelloListMembersTool,
trello_search: trelloSearchTool,
trigger_dev_trigger_task: triggerDevTriggerTaskTool,
trigger_dev_batch_trigger_task: triggerDevBatchTriggerTaskTool,
trigger_dev_get_batch: triggerDevGetBatchTool,
Expand Down
148 changes: 148 additions & 0 deletions apps/sim/tools/trello/add_checklist_item.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
import { getErrorMessage } from '@sim/utils/errors'
import { env } from '@/lib/core/config/env'
import {
extractTrelloErrorMessage,
mapTrelloChecklistItem,
TRELLO_API_BASE_URL,
} from '@/tools/trello/shared'
import type {
TrelloAddChecklistItemParams,
TrelloAddChecklistItemResponse,
} from '@/tools/trello/types'
import type { ToolConfig } from '@/tools/types'

export const trelloAddChecklistItemTool: ToolConfig<
TrelloAddChecklistItemParams,
TrelloAddChecklistItemResponse
> = {
id: 'trello_add_checklist_item',
name: 'Trello Add Checklist Item',
description: 'Add an item to a Trello checklist',
version: '1.0.0',

oauth: {
required: true,
provider: 'trello',
},

params: {
accessToken: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Trello OAuth access token',
},
checklistId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Trello checklist ID to add the item to (24-character hex string)',
},
name: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Name of the checklist item',
},
pos: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Position of the item (top, bottom, or positive float)',
},
checked: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'Whether the item should start checked off',
},
},

request: {
url: (params) => {
if (!params.checklistId) {
throw new Error('Checklist ID is required')
}
if (!params.name) {
throw new Error('Checklist item name is required')
}
const apiKey = env.TRELLO_API_KEY

if (!apiKey) {
throw new Error('TRELLO_API_KEY environment variable is not set')
}

const url = new URL(
`${TRELLO_API_BASE_URL}/checklists/${params.checklistId.trim()}/checkItems`
)
url.searchParams.set('key', apiKey)
url.searchParams.set('token', params.accessToken)
url.searchParams.set('name', params.name.trim())

if (params.pos) url.searchParams.set('pos', params.pos)
if (params.checked !== undefined) url.searchParams.set('checked', String(params.checked))

return url.toString()
},
method: 'POST',
headers: () => ({
Accept: 'application/json',
}),
},

transformResponse: async (response) => {
const data = await response.json().catch(() => null)

if (!response.ok) {
const error = extractTrelloErrorMessage(response, data, 'Failed to add checklist item')

return {
success: false,
output: {
error,
},
error,
}
}

try {
const item = mapTrelloChecklistItem(data)

return {
success: true,
output: {
item,
},
}
} catch (error) {
const message = getErrorMessage(error, 'Failed to parse created checklist item')

return {
success: false,
output: {
error: message,
},
error: message,
}
}
},

outputs: {
item: {
type: 'json',
description: 'Created checklist item (id, name, state, pos, idChecklist)',
optional: true,
properties: {
id: { type: 'string', description: 'Checklist item ID' },
name: { type: 'string', description: 'Checklist item name' },
state: { type: 'string', description: 'Item state (complete or incomplete)' },
pos: { type: 'number', description: 'Item position on the checklist' },
idChecklist: {
type: 'string',
description: 'Checklist ID containing the item',
optional: true,
},
},
},
},
}
11 changes: 11 additions & 0 deletions apps/sim/tools/trello/create_card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ export const trelloCreateCardTool: ToolConfig<TrelloCreateCardParams, TrelloCrea
description: 'A Trello label ID',
},
},
memberIds: {
type: 'array',
required: false,
visibility: 'user-or-llm',
description: 'Member IDs to assign to the card',
items: {
type: 'string',
description: 'A Trello member ID',
},
},
},

request: {
Expand Down Expand Up @@ -111,6 +121,7 @@ export const trelloCreateCardTool: ToolConfig<TrelloCreateCardParams, TrelloCrea
if (params.due) body.due = params.due
if (params.dueComplete !== undefined) body.dueComplete = params.dueComplete
if (params.labelIds?.length) body.idLabels = params.labelIds
if (params.memberIds?.length) body.idMembers = params.memberIds

return body
},
Expand Down
85 changes: 85 additions & 0 deletions apps/sim/tools/trello/delete_card.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { env } from '@/lib/core/config/env'
import { extractTrelloErrorMessage, TRELLO_API_BASE_URL } from '@/tools/trello/shared'
import type { TrelloDeleteCardParams, TrelloDeleteCardResponse } from '@/tools/trello/types'
import type { ToolConfig } from '@/tools/types'

export const trelloDeleteCardTool: ToolConfig<TrelloDeleteCardParams, TrelloDeleteCardResponse> = {
id: 'trello_delete_card',
name: 'Trello Delete Card',
description: 'Permanently delete a Trello card',
version: '1.0.0',

oauth: {
required: true,
provider: 'trello',
},

params: {
accessToken: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Trello OAuth access token',
},
cardId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Trello card ID to permanently delete (24-character hex string)',
},
},

request: {
url: (params) => {
if (!params.cardId) {
throw new Error('Card ID is required')
}
const apiKey = env.TRELLO_API_KEY

if (!apiKey) {
throw new Error('TRELLO_API_KEY environment variable is not set')
}

const url = new URL(`${TRELLO_API_BASE_URL}/cards/${params.cardId.trim()}`)
url.searchParams.set('key', apiKey)
url.searchParams.set('token', params.accessToken)

return url.toString()
},
method: 'DELETE',
headers: () => ({
Accept: 'application/json',
}),
},

transformResponse: async (response) => {
const data = await response.json().catch(() => null)

if (!response.ok) {
const error = extractTrelloErrorMessage(response, data, 'Failed to delete card')

return {
success: false,
output: {
success: false,
error,
},
error,
}
}

return {
success: true,
output: {
success: true,
},
}
},

outputs: {
success: {
type: 'boolean',
description: 'Whether the card was deleted',
},
},
}
22 changes: 22 additions & 0 deletions apps/sim/tools/trello/get_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ export const trelloGetActionsTool: ToolConfig<TrelloGetActionsParams, TrelloGetA
visibility: 'user-or-llm',
description: 'Page number for action results',
},
since: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Only return actions after this date (ISO 8601 timestamp) or action ID, for paging through long histories',
},
before: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Only return actions before this date (ISO 8601 timestamp) or action ID, for paging through long histories',
},
},

request: {
Expand Down Expand Up @@ -92,6 +106,14 @@ export const trelloGetActionsTool: ToolConfig<TrelloGetActionsParams, TrelloGetA
url.searchParams.set('page', String(params.page))
}

if (params.since) {
url.searchParams.set('since', params.since)
}

if (params.before) {
url.searchParams.set('before', params.before)
}

return url.toString()
},
method: 'GET',
Expand Down
16 changes: 16 additions & 0 deletions apps/sim/tools/trello/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,47 @@
import { trelloAddChecklistTool } from '@/tools/trello/add_checklist'
import { trelloAddChecklistItemTool } from '@/tools/trello/add_checklist_item'
import { trelloAddCommentTool } from '@/tools/trello/add_comment'
import { trelloAddLabelTool } from '@/tools/trello/add_label'
import { trelloAddMemberTool } from '@/tools/trello/add_member'
import { trelloCreateBoardTool } from '@/tools/trello/create_board'
import { trelloCreateCardTool } from '@/tools/trello/create_card'
import { trelloCreateListTool } from '@/tools/trello/create_list'
import { trelloDeleteCardTool } from '@/tools/trello/delete_card'
import { trelloGetActionsTool } from '@/tools/trello/get_actions'
import { trelloGetBoardTool } from '@/tools/trello/get_board'
import { trelloGetCardTool } from '@/tools/trello/get_card'
import { trelloListCardsTool } from '@/tools/trello/list_cards'
import { trelloListListsTool } from '@/tools/trello/list_lists'
import { trelloListMembersTool } from '@/tools/trello/list_members'
import { trelloRemoveLabelTool } from '@/tools/trello/remove_label'
import { trelloRemoveMemberTool } from '@/tools/trello/remove_member'
import { trelloSearchTool } from '@/tools/trello/search'
import { trelloUpdateCardTool } from '@/tools/trello/update_card'
import { trelloUpdateChecklistItemTool } from '@/tools/trello/update_checklist_item'
import { trelloUpdateListTool } from '@/tools/trello/update_list'

export {
trelloListListsTool,
trelloListCardsTool,
trelloCreateCardTool,
trelloUpdateCardTool,
trelloDeleteCardTool,
trelloGetActionsTool,
trelloAddCommentTool,
trelloCreateBoardTool,
trelloGetBoardTool,
trelloCreateListTool,
trelloUpdateListTool,
trelloGetCardTool,
trelloAddChecklistTool,
trelloAddChecklistItemTool,
trelloUpdateChecklistItemTool,
trelloAddLabelTool,
trelloRemoveLabelTool,
trelloAddMemberTool,
trelloRemoveMemberTool,
trelloListMembersTool,
trelloSearchTool,
}

export * from '@/tools/trello/types'
Loading
Loading