diff --git a/packages/basic.gblib/services/DialogKeywords.ts b/packages/basic.gblib/services/DialogKeywords.ts index b70b6a36..c9e31657 100644 --- a/packages/basic.gblib/services/DialogKeywords.ts +++ b/packages/basic.gblib/services/DialogKeywords.ts @@ -612,6 +612,19 @@ export class DialogKeywords { return await this.internalSendFile({ pid, mobile, channel: proc.channel, filename, caption }); } + /** + * Sends a template to a given mobile. + * + * @example SEND TEMPLATE TO "+199988887777","image.jpg" + * + */ + public async sendTemplateTo({ pid, mobile, filename: text}) { + const { min, user, proc } = await DialogKeywords.getProcessInfo(pid); + GBLogEx.info(min, `BASIC: SEND TEMPLATE TO '${mobile}',filename '${text}'.`); + const service = new GBConversationalService(min.core); + return await service.fillAndBroadcastTemplate(min, mobile, text); + } + /** * Sends a file to the current user. * diff --git a/packages/basic.gblib/services/KeywordsExpressions.ts b/packages/basic.gblib/services/KeywordsExpressions.ts index 0f9d405e..4d6c0a4d 100644 --- a/packages/basic.gblib/services/KeywordsExpressions.ts +++ b/packages/basic.gblib/services/KeywordsExpressions.ts @@ -1028,7 +1028,7 @@ export class KeywordsExpressions { /^\s*(send template to)(\s*)(.*)/gim, ($0, $1, $2, $3) => { const params = this.getParams($3, ['mobile', 'text']); - return `await dk.fillAndBroadcastTemplate({pid: pid, ${params}})`; + return `await dk.sendTemplateTo({pid: pid, ${params}})`; } ];