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.