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
2 changes: 1 addition & 1 deletion integrations/zendesk/integration.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
12 changes: 6 additions & 6 deletions integrations/zendesk/src/events/message-received.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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({
Expand Down
Loading