From 8d7e2cb2b67e4de3773a3015a54c8a537e70168a Mon Sep 17 00:00:00 2001 From: Mathieu Faucher <99497774+Math-Fauch@users.noreply.github.com> Date: Wed, 11 Mar 2026 10:15:55 -0400 Subject: [PATCH] fix(integrations/zendesk): comply to new payload (#15001) --- integrations/zendesk/integration.definition.ts | 2 +- integrations/zendesk/src/events/message-received.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/integrations/zendesk/integration.definition.ts b/integrations/zendesk/integration.definition.ts index fb63c93ed86..7268d6b0b6c 100644 --- a/integrations/zendesk/integration.definition.ts +++ b/integrations/zendesk/integration.definition.ts @@ -6,7 +6,7 @@ import { actions, events, configuration, channels, states, user } from './src/de export default new sdk.IntegrationDefinition({ name: 'zendesk', title: 'Zendesk', - version: '3.1.0', + version: '3.1.1', icon: 'icon.svg', description: 'Optimize your support workflow. Trigger workflows from ticket updates as well as manage tickets, access conversations, and engage with customers.', diff --git a/integrations/zendesk/src/events/message-received.ts b/integrations/zendesk/src/events/message-received.ts index bccca915cde..ab197849d3f 100644 --- a/integrations/zendesk/src/events/message-received.ts +++ b/integrations/zendesk/src/events/message-received.ts @@ -1,10 +1,11 @@ import { createOrUpdateUser } from '@botpress/common' +import _ from 'lodash' import type { ZendeskClient } from '../client' import type { TriggerPayload } from '../triggers' import { retrieveHitlConversation } from './hitl-ticket-filter' import * as bp from '.botpress' -const COMMENT_ON_BEHALF_START = '----------------------------------------------\n\n!***' +const ON_BEHALF_REGEXP: RegExp = /!\*{3}|\*{3}!/ export const executeMessageReceived = async ({ zendeskClient, @@ -67,12 +68,11 @@ export const executeMessageReceived = async ({ }) } - let messageWithoutAuthor: string + let messageWithoutAuthor = _.trimStart(zendeskTrigger.comment, '-').trim() + const firstLine = messageWithoutAuthor.split('\n').at(0) - if (zendeskTrigger.comment.startsWith(COMMENT_ON_BEHALF_START)) { - messageWithoutAuthor = zendeskTrigger.comment.split('\n').slice(5).join('\n') - } else { - messageWithoutAuthor = zendeskTrigger.comment.split('\n').slice(3).join('\n') + if (firstLine && ON_BEHALF_REGEXP.test(firstLine)) { + messageWithoutAuthor = messageWithoutAuthor.split('\n').slice(1).join('\n').trim() } await client.createMessage({