diff --git a/packages/basic.gblib/services/DialogKeywords.ts b/packages/basic.gblib/services/DialogKeywords.ts index c9e31657..5fe713da 100644 --- a/packages/basic.gblib/services/DialogKeywords.ts +++ b/packages/basic.gblib/services/DialogKeywords.ts @@ -618,11 +618,22 @@ export class DialogKeywords { * @example SEND TEMPLATE TO "+199988887777","image.jpg" * */ - public async sendTemplateTo({ pid, mobile, filename: text}) { + public async sendTemplateTo({ pid, mobile, filename}) { const { min, user, proc } = await DialogKeywords.getProcessInfo(pid); - GBLogEx.info(min, `BASIC: SEND TEMPLATE TO '${mobile}',filename '${text}'.`); + GBLogEx.info(min, `BASIC: SEND TEMPLATE TO '${mobile}',filename '${filename}'.`); const service = new GBConversationalService(min.core); + + let text; + if (filename.endsWith('.docx')) { + text = await min.kbService.getAnswerTextByMediaName(min.instance.instanceId, filename); + } + else{ + text = filename; + } + + return await service.fillAndBroadcastTemplate(min, mobile, text); + } /** diff --git a/packages/basic.gblib/services/KeywordsExpressions.ts b/packages/basic.gblib/services/KeywordsExpressions.ts index 4d6c0a4d..431b1c1f 100644 --- a/packages/basic.gblib/services/KeywordsExpressions.ts +++ b/packages/basic.gblib/services/KeywordsExpressions.ts @@ -1027,7 +1027,7 @@ export class KeywordsExpressions { keywords[i++] = [ /^\s*(send template to)(\s*)(.*)/gim, ($0, $1, $2, $3) => { - const params = this.getParams($3, ['mobile', 'text']); + const params = this.getParams($3, ['mobile', 'filename']); return `await dk.sendTemplateTo({pid: pid, ${params}})`; } ];