feat: Show webhook_url for chatwoot

This commit is contained in:
Davidson Gomes
2023-07-13 11:19:48 -03:00
parent b4a9941452
commit eb83d89307
8 changed files with 83 additions and 26 deletions

View File

@@ -42,22 +42,26 @@ export class ChatwootService {
}
private async getProvider(instance: InstanceDto) {
const provider = await this.waMonitor.waInstances[
instance.instanceName
].findChatwoot();
try {
const provider = await this.waMonitor.waInstances[
instance.instanceName
].findChatwoot();
if (!provider) {
if (!provider) {
return null;
}
return provider;
} catch (error) {
return null;
}
return provider;
}
private async clientCw(instance: InstanceDto) {
const provider = await this.getProvider(instance);
if (!provider) {
throw new Error('provider not found');
this.logger.error('provider not found');
}
this.provider = provider;
@@ -78,7 +82,7 @@ export class ChatwootService {
this.logger.verbose('create chatwoot: ' + instance.instanceName);
this.waMonitor.waInstances[instance.instanceName].setChatwoot(data);
return { chatwoot: { ...instance, chatwoot: data } };
return data;
}
public async find(instance: InstanceDto): Promise<ChatwootDto> {
@@ -583,6 +587,21 @@ export class ChatwootService {
}
}
if (body.message_type === 'template' && body.content_type === 'input_csat') {
const data: SendTextDto = {
number: chatId,
textMessage: {
text: body.content,
},
options: {
delay: 1200,
presence: 'composing',
},
};
await waInstance?.textMessage(data);
}
return { message: 'bot' };
} catch (error) {
console.log(error);