From 8a3124e296ca5d3d02b1778cba532db7c07b3e55 Mon Sep 17 00:00:00 2001 From: LenAnderson Date: Thu, 28 Dec 2023 01:28:28 +0000 Subject: [PATCH] add executeQuickReply to QR API --- .../extensions/quick-reply/api/QuickReplyApi.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/public/scripts/extensions/quick-reply/api/QuickReplyApi.js b/public/scripts/extensions/quick-reply/api/QuickReplyApi.js index 2e21507c4..712b10d58 100644 --- a/public/scripts/extensions/quick-reply/api/QuickReplyApi.js +++ b/public/scripts/extensions/quick-reply/api/QuickReplyApi.js @@ -66,6 +66,21 @@ export class QuickReplyApi { } } + /** + * Executes an existing quick reply. + * + * @param {String} setName name of the existing quick reply set + * @param {String} label label of the existing quick reply (text on the button) + * @param {Object} [args] optional arguments + */ + async executeQuickReply(setName, label, args = {}) { + const qr = this.getQrByLabel(setName, label); + if (!qr) { + throw new Error(`No quick reply with label "${label}" in set "${setName}" found.`); + } + return await qr.execute(args); + } + /** * Adds or removes a quick reply set to the list of globally active quick reply sets.