From 2d6cfeb0fa054c5075ab28ba410cfca5450d5ead Mon Sep 17 00:00:00 2001 From: devlikepro Date: Fri, 23 Jan 2026 09:57:58 +0700 Subject: [PATCH] [core] ChatWoot - use chat id from incoming message to use either @lid or @c.us (likely @lid in MOST cases now) --- src/apps/chatwoot/client/ContactConversationService.ts | 3 +++ src/apps/chatwoot/client/ids.ts | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/apps/chatwoot/client/ContactConversationService.ts b/src/apps/chatwoot/client/ContactConversationService.ts index 901315f7..accfe960 100644 --- a/src/apps/chatwoot/client/ContactConversationService.ts +++ b/src/apps/chatwoot/client/ContactConversationService.ts @@ -19,6 +19,7 @@ import { Locale } from '@waha/apps/chatwoot/i18n/locale'; import { CacheForConfig } from '../cache/ConversationCache'; import { IConversationCache } from '../cache/IConversationCache'; +import { AttributeKey } from '@waha/apps/chatwoot/const'; export interface ContactInfo { ChatId(): string; @@ -63,6 +64,8 @@ export class ContactConversationService { `Updating if required contact custom attributes for chat.id: ${chatId}, contact.id: ${cwContact.data.id}`, ); const attributes = await contactInfo.Attributes(); + // Keep the current chat id in sync to reply using the latest address. + attributes[AttributeKey.WA_CHAT_ID] = chatId; await this.contactService.upsertCustomAttributes( cwContact.data, attributes, diff --git a/src/apps/chatwoot/client/ids.ts b/src/apps/chatwoot/client/ids.ts index c136ec03..b15a2c06 100644 --- a/src/apps/chatwoot/client/ids.ts +++ b/src/apps/chatwoot/client/ids.ts @@ -27,15 +27,15 @@ export function GetAllChatIDs(contact: any): Array { } export function FindChatID(contact: any): string | null { + if (GetChatID(contact)) { + return GetChatID(contact); + } if (GetJID(contact)) { return GetJID(contact); } if (GetLID(contact)) { return GetLID(contact); } - if (GetChatID(contact)) { - return GetChatID(contact); - } return null; }