Skip to content

Commit 94e95b4

Browse files
committed
fix(intercom): snooze via the manage-conversation endpoint, coerce snoozed_until, guard path ids, add user/lead recipient types
1 parent cd4ae8b commit 94e95b4

20 files changed

Lines changed: 76 additions & 20 deletions

‎apps/sim/blocks/blocks/intercom.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,11 @@ Return ONLY the subject line - no explanations.`,
854854
id: 'to_type',
855855
title: 'To Type',
856856
type: 'dropdown',
857-
options: [{ label: 'Contact', id: 'contact' }],
857+
options: [
858+
{ label: 'Contact', id: 'contact' },
859+
{ label: 'User', id: 'user' },
860+
{ label: 'Lead', id: 'lead' },
861+
],
858862
required: true,
859863
condition: {
860864
field: 'operation',
@@ -1354,6 +1358,7 @@ Return ONLY the numeric timestamp.`,
13541358
ticket_open,
13551359
ticket_is_shared,
13561360
ticket_snoozed_until,
1361+
snoozed_until,
13571362
ticket_assignee_id,
13581363
tag_name,
13591364
tag_id_update,
@@ -1406,6 +1411,10 @@ Return ONLY the numeric timestamp.`,
14061411
cleanParams.include_translations = include_translations === 'true'
14071412
}
14081413

1414+
if (operation === 'snooze_conversation' && snoozed_until) {
1415+
cleanParams.snoozed_until = Number(snoozed_until)
1416+
}
1417+
14091418
if (operation === 'close_conversation' && close_body) {
14101419
cleanParams.body = close_body
14111420
}
@@ -1638,6 +1647,7 @@ export const IntercomV2Block: BlockConfig = {
16381647
ticket_open,
16391648
ticket_is_shared,
16401649
ticket_snoozed_until,
1650+
snoozed_until,
16411651
ticket_assignee_id,
16421652
tag_name,
16431653
tag_id_update,
@@ -1690,6 +1700,10 @@ export const IntercomV2Block: BlockConfig = {
16901700
cleanParams.include_translations = include_translations === 'true'
16911701
}
16921702

1703+
if (operation === 'snooze_conversation' && snoozed_until) {
1704+
cleanParams.snoozed_until = Number(snoozed_until)
1705+
}
1706+
16931707
if (operation === 'close_conversation' && close_body) {
16941708
cleanParams.body = close_body
16951709
}

‎apps/sim/tools/intercom/assign_conversation.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { buildIntercomUrl, handleIntercomError } from '@/tools/intercom/types'
22
import { INTERCOM_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
33
import type { ToolConfig } from '@/tools/types'
4+
import { safeUrlPathSegment } from '@/tools/url-path'
45

56
export interface IntercomAssignConversationParams {
67
accessToken: string
@@ -57,7 +58,9 @@ const assignConversationBase = {
5758

5859
request: {
5960
url: (params: IntercomAssignConversationParams) =>
60-
buildIntercomUrl(`/conversations/${params.conversationId}/parts`),
61+
buildIntercomUrl(
62+
`/conversations/${safeUrlPathSegment(params.conversationId, 'conversationId')}/parts`
63+
),
6164
method: 'POST',
6265
headers: (params: IntercomAssignConversationParams) => ({
6366
Authorization: `Bearer ${params.accessToken}`,

‎apps/sim/tools/intercom/attach_contact_to_company.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { buildIntercomUrl, handleIntercomError } from '@/tools/intercom/types'
22
import { INTERCOM_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
33
import type { ToolConfig } from '@/tools/types'
4+
import { safeUrlPathSegment } from '@/tools/url-path'
45

56
export interface IntercomAttachContactToCompanyParams {
67
accessToken: string
@@ -41,7 +42,7 @@ const attachContactToCompanyBase = {
4142

4243
request: {
4344
url: (params: IntercomAttachContactToCompanyParams) =>
44-
buildIntercomUrl(`/contacts/${params.contactId}/companies`),
45+
buildIntercomUrl(`/contacts/${safeUrlPathSegment(params.contactId, 'contactId')}/companies`),
4546
method: 'POST',
4647
headers: (params: IntercomAttachContactToCompanyParams) => ({
4748
Authorization: `Bearer ${params.accessToken}`,

‎apps/sim/tools/intercom/close_conversation.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { buildIntercomUrl, handleIntercomError } from '@/tools/intercom/types'
22
import { INTERCOM_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
33
import type { ToolConfig } from '@/tools/types'
4+
import { safeUrlPathSegment } from '@/tools/url-path'
45

56
export interface IntercomCloseConversationParams {
67
accessToken: string
@@ -48,7 +49,9 @@ const closeConversationBase = {
4849

4950
request: {
5051
url: (params: IntercomCloseConversationParams) =>
51-
buildIntercomUrl(`/conversations/${params.conversationId}/parts`),
52+
buildIntercomUrl(
53+
`/conversations/${safeUrlPathSegment(params.conversationId, 'conversationId')}/parts`
54+
),
5255
method: 'POST',
5356
headers: (params: IntercomCloseConversationParams) => ({
5457
Authorization: `Bearer ${params.accessToken}`,

‎apps/sim/tools/intercom/create_message.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const createMessageBase = {
8585
type: 'string',
8686
required: true,
8787
visibility: 'user-or-llm',
88-
description: 'Recipient type: "contact"',
88+
description: 'Recipient role: "user" or "lead"',
8989
},
9090
to_id: {
9191
type: 'string',

‎apps/sim/tools/intercom/create_note.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { buildIntercomUrl, handleIntercomError } from '@/tools/intercom/types'
22
import { INTERCOM_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
33
import type { ToolConfig } from '@/tools/types'
4+
import { safeUrlPathSegment } from '@/tools/url-path'
45

56
export interface IntercomCreateNoteParams {
67
accessToken: string
@@ -51,7 +52,7 @@ const createNoteBase = {
5152

5253
request: {
5354
url: (params: IntercomCreateNoteParams) =>
54-
buildIntercomUrl(`/contacts/${params.contactId}/notes`),
55+
buildIntercomUrl(`/contacts/${safeUrlPathSegment(params.contactId, 'contactId')}/notes`),
5556
method: 'POST',
5657
headers: (params: IntercomCreateNoteParams) => ({
5758
Authorization: `Bearer ${params.accessToken}`,

‎apps/sim/tools/intercom/delete_contact.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { buildIntercomUrl, handleIntercomError } from '@/tools/intercom/types'
22
import { INTERCOM_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
33
import type { ToolConfig } from '@/tools/types'
4+
import { safeUrlPathSegment } from '@/tools/url-path'
45

56
export interface IntercomDeleteContactParams {
67
accessToken: string
@@ -36,7 +37,8 @@ const intercomDeleteContactBase = {
3637
},
3738

3839
request: {
39-
url: (params: IntercomDeleteContactParams) => buildIntercomUrl(`/contacts/${params.contactId}`),
40+
url: (params: IntercomDeleteContactParams) =>
41+
buildIntercomUrl(`/contacts/${safeUrlPathSegment(params.contactId, 'contactId')}`),
4042
method: 'DELETE',
4143
headers: (params: IntercomDeleteContactParams) => ({
4244
Authorization: `Bearer ${params.accessToken}`,

‎apps/sim/tools/intercom/detach_contact_from_company.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { buildIntercomUrl, handleIntercomError } from '@/tools/intercom/types'
22
import { INTERCOM_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
33
import type { ToolConfig } from '@/tools/types'
4+
import { safeUrlPathSegment } from '@/tools/url-path'
45

56
export interface IntercomDetachContactFromCompanyParams {
67
accessToken: string
@@ -41,7 +42,9 @@ const detachContactFromCompanyBase = {
4142

4243
request: {
4344
url: (params: IntercomDetachContactFromCompanyParams) =>
44-
buildIntercomUrl(`/contacts/${params.contactId}/companies/${params.companyId}`),
45+
buildIntercomUrl(
46+
`/contacts/${safeUrlPathSegment(params.contactId, 'contactId')}/companies/${safeUrlPathSegment(params.companyId, 'companyId')}`
47+
),
4548
method: 'DELETE',
4649
headers: (params: IntercomDetachContactFromCompanyParams) => ({
4750
Authorization: `Bearer ${params.accessToken}`,

‎apps/sim/tools/intercom/get_company.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { buildIntercomUrl, handleIntercomError } from '@/tools/intercom/types'
22
import { INTERCOM_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
33
import type { ToolConfig } from '@/tools/types'
4+
import { safeUrlPathSegment } from '@/tools/url-path'
45

56
export interface IntercomGetCompanyParams {
67
accessToken: string
@@ -35,7 +36,8 @@ const getCompanyBase = {
3536
},
3637

3738
request: {
38-
url: (params: IntercomGetCompanyParams) => buildIntercomUrl(`/companies/${params.companyId}`),
39+
url: (params: IntercomGetCompanyParams) =>
40+
buildIntercomUrl(`/companies/${safeUrlPathSegment(params.companyId, 'companyId')}`),
3941
method: 'GET',
4042
headers: (params: IntercomGetCompanyParams) => ({
4143
Authorization: `Bearer ${params.accessToken}`,

‎apps/sim/tools/intercom/get_contact.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from '@/tools/intercom/types'
66
import { INTERCOM_CREDENTIAL_OAUTH } from '@/tools/shared/saved-credentials'
77
import type { ToolConfig } from '@/tools/types'
8+
import { safeUrlPathSegment } from '@/tools/url-path'
89

910
export interface IntercomGetContactParams {
1011
accessToken: string
@@ -39,7 +40,8 @@ const intercomGetContactBase = {
3940
},
4041

4142
request: {
42-
url: (params: IntercomGetContactParams) => buildIntercomUrl(`/contacts/${params.contactId}`),
43+
url: (params: IntercomGetContactParams) =>
44+
buildIntercomUrl(`/contacts/${safeUrlPathSegment(params.contactId, 'contactId')}`),
4345
method: 'GET',
4446
headers: (params: IntercomGetContactParams) => ({
4547
Authorization: `Bearer ${params.accessToken}`,

0 commit comments

Comments
 (0)