File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import { SendTextDto } from '../dto/sendMessage.dto';
1111import mimeTypes from 'mime-types' ;
1212import { SendAudioDto } from '../dto/sendMessage.dto' ;
1313import { SendMediaDto } from '../dto/sendMessage.dto' ;
14- import NodeCache from 'node-cache' ;
1514import { ROOT_DIR } from '../../config/path.config' ;
1615
1716export class ChatwootService {
@@ -614,6 +613,7 @@ export class ChatwootService {
614613 const media = [
615614 'imageMessage' ,
616615 'documentMessage' ,
616+ 'documentWithCaptionMessage' ,
617617 'audioMessage' ,
618618 'videoMessage' ,
619619 'stickerMessage' ,
@@ -632,6 +632,8 @@ export class ChatwootService {
632632 messageContextInfo : msg . messageContextInfo ?. stanzaId ,
633633 stickerMessage : msg . stickerMessage ?. fileSha256 . toString ( 'base64' ) ,
634634 documentMessage : msg . documentMessage ?. caption ,
635+ documentWithCaptionMessage :
636+ msg . documentWithCaptionMessage ?. message ?. documentMessage ?. caption ,
635637 audioMessage : msg . audioMessage ?. caption ,
636638 } ;
637639
Original file line number Diff line number Diff line change @@ -116,6 +116,17 @@ export async function initInstance() {
116116 configService . get < Auth > ( 'AUTHENTICATION' ) . INSTANCE . WEBHOOK_URL ;
117117 logger . verbose ( 'Instance webhook: ' + instanceWebhook ) ;
118118
119+ const chatwootAccountId =
120+ configService . get < Auth > ( 'AUTHENTICATION' ) . INSTANCE . CHATWOOT_ACCOUNT_ID ;
121+ logger . verbose ( 'Chatwoot account id: ' + chatwootAccountId ) ;
122+
123+ const chatwootToken =
124+ configService . get < Auth > ( 'AUTHENTICATION' ) . INSTANCE . CHATWOOT_TOKEN ;
125+ logger . verbose ( 'Chatwoot token: ' + chatwootToken ) ;
126+
127+ const chatwootUrl = configService . get < Auth > ( 'AUTHENTICATION' ) . INSTANCE . CHATWOOT_URL ;
128+ logger . verbose ( 'Chatwoot url: ' + chatwootUrl ) ;
129+
119130 instance . instanceName = instanceName ;
120131
121132 waMonitor . waInstances [ instance . instanceName ] = instance ;
@@ -137,6 +148,22 @@ export async function initInstance() {
137148 }
138149 }
139150
151+ if ( chatwootUrl && chatwootToken && chatwootAccountId ) {
152+ logger . verbose ( 'Creating chatwoot for instance: ' + instanceName ) ;
153+ try {
154+ chatwootService . create ( instance , {
155+ enabled : true ,
156+ url : chatwootUrl ,
157+ token : chatwootToken ,
158+ account_id : chatwootAccountId ,
159+ sign_msg : false ,
160+ } ) ;
161+ logger . verbose ( 'Chatwoot created' ) ;
162+ } catch ( error ) {
163+ logger . log ( error ) ;
164+ }
165+ }
166+
140167 try {
141168 const state = instance . connectionStatus ?. state ;
142169
You can’t perform that action at this time.
0 commit comments