Skip to content

Commit 421e762

Browse files
committed
fix(chatwoot.service): Ensure conversation checks are robust before toggling status
- Added null checks for conversation object in reopenConversation mode and when finding unresolved conversations. - Improved logging for better debugging of conversation retrieval.
1 parent 9e1f9cb commit 421e762

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ export class ChatwootService {
705705
if (this.provider.reopenConversation) {
706706
this.logger.verbose(`Found conversation in reopenConversation mode: ${JSON.stringify(inboxConversation)}`);
707707

708-
if (this.provider.conversationPending && inboxConversation.status !== 'open') {
708+
if (inboxConversation && this.provider.conversationPending && inboxConversation.status !== 'open') {
709709
await client.conversations.toggleStatus({
710710
accountId: this.provider.accountId,
711711
conversationId: inboxConversation.id,
@@ -716,7 +716,7 @@ export class ChatwootService {
716716
}
717717
} else {
718718
inboxConversation = contactConversations.payload.find(
719-
(conversation) => conversation.status !== 'resolved' && conversation.inbox_id == filterInbox.id,
719+
(conversation) => conversation && conversation.status !== 'resolved' && conversation.inbox_id == filterInbox.id,
720720
);
721721
this.logger.verbose(`Found conversation: ${JSON.stringify(inboxConversation)}`);
722722
}

0 commit comments

Comments
 (0)