diff --git a/packages/functionals/botpress-qna/README.md b/packages/functionals/botpress-qna/README.md index 2cfe4ec3154..284ab8d5e46 100755 --- a/packages/functionals/botpress-qna/README.md +++ b/packages/functionals/botpress-qna/README.md @@ -22,6 +22,7 @@ The following properties can be configured either in the `qna.json` file or usin | `exportCsvEncoding` | `QNA_EXPORT_CSV_ENCODING` | No | `utf8` | Encoding for CSV that can be exported from Q&A module | `qnaMakerApiKey` | `QNA_MAKER_API_KEY` | No | | API-key for [Microsoft QnA Maker](https://www.qnamaker.ai). If provided QnA maker gets used to save items and search through them (instead of NLU-module) | `qnaMakerKnowledgebase` | `QNA_MAKER_KNOWLEDGEBASE` | No | `botpress` | Name of the QnA Maker knowledgebase to use +| `qnaCategories` | `QNA_CATEGORIES` | No | | Comma-separated list of categories to use within QNA-module # Usage diff --git a/packages/functionals/botpress-qna/src/index.js b/packages/functionals/botpress-qna/src/index.js index d506f520159..a70df647b6b 100755 --- a/packages/functionals/botpress-qna/src/index.js +++ b/packages/functionals/botpress-qna/src/index.js @@ -27,7 +27,8 @@ module.exports = { textRenderer: { type: 'string', required: true, default: '#builtin_text', env: 'QNA_TEXT_RENDERER' }, exportCsvEncoding: { type: 'string', required: false, default: 'utf8', env: 'QNA_EXPORT_CSV_ENCODING' }, qnaMakerApiKey: { type: 'string', required: false, env: 'QNA_MAKER_API_KEY' }, - qnaMakerKnowledgebase: { type: 'string', required: false, default: 'botpress', env: 'QNA_MAKER_KNOWLEDGEBASE' } + qnaMakerKnowledgebase: { type: 'string', required: false, default: 'botpress', env: 'QNA_MAKER_KNOWLEDGEBASE' }, + qnaCategories: { type: 'string', required: false, default: '', env: 'QNA_CATEGORIES' } }, async init(bp, configurator) { const config = await configurator.loadAll() @@ -61,7 +62,7 @@ module.exports = { async ready(bp, configurator) { const config = await configurator.loadAll() const storage = this.storage - let categories = [] + const categories = config.qnaCategories.split(',') bp.qna = { /** * Parses and imports questions; consecutive questions with similar answer get merged @@ -148,18 +149,7 @@ module.exports = { * @param {String} question - question to match against * @returns {Array.<{questions: Array, answer: String, id: String, confidence: Number, metadata: Array}>} */ - answersOn: storage.answersOn.bind(storage), - - /** - * @param {string[]} categoriesToRegister - array of category names to register - */ - - registerCategories(categoriesToRegister) { - if (!_.isArray(categoriesToRegister)) { - return - } - categories = [...categories, ...categoriesToRegister] - } + answersOn: storage.answersOn.bind(storage) } const router = bp.getRouter('botpress-qna')