10.51.10 • Published 5 years ago

@botpress/qna v10.51.10

Weekly downloads
86
License
AGPL-3.0-only
Repository
github
Last release
5 years ago

Botpress Q&A ⚡

Botpress Q&A is a Botpress module that adds the unified Q&A management interface to your bot admin panel.

It either relies on the NLU module or on Microsoft QnA Maker for recognizing the questions. By default it also uses the builtins module to send the text response, but it's configurable (see below).

Installation

⚠️ This module only works with the new Botpress X.

  • Install the peer dependencies and the module iteslf yarn add @botpress/builtins @botpress/nlu @botpress/qna (note: you can skip the builtins module if you use the custom text renderer.)
  • Configure NLU or register at Microsoft QnA Maker and provide the API key for it

Configuration

The following properties can be configured either in the qna.json file or using the environment variables:

KeyEnvironment VariableRequiredDefault
qnaDirQNA_DIRNo./qnaThe directory where the Q&A data is stored.
textRendererQNA_TEXT_RENDERERNo#builtin_text (requires @botpress/builtins to be installed)The renderer used to format the text responses.
exportCsvEncodingQNA_EXPORT_CSV_ENCODINGNoutf8Encoding for CSV that can be exported from Q&A module
qnaMakerApiKeyQNA_MAKER_API_KEYNoAPI-key for Microsoft QnA Maker. If provided QnA maker gets used to save items and search through them (instead of NLU-module)
qnaMakerKnowledgebaseQNA_MAKER_KNOWLEDGEBASENobotpressName of the QnA Maker knowledgebase to use
qnaCategoriesQNA_CATEGORIESNoComma-separated list of categories to use within QNA-module
qnaShowTypingQNA_SHOW_TYPINGNo0sThe time of showing typing indicators

Usage

Go to the bot admin panel and choose Q&A from the left hand side menu.

This opens Q&A module's page that allows you to manage questions. You can:

  • create new questions by filling in the form at the top
  • edit existing questions by changing appropriate fields of their forms
  • remove or disable questions by either clicking "Remove" button or changing "Enabled" checkbox
  • filter questions via search-input

Each questions can be associated either with text-answer (by default it'll use #builtin_text renderer to send it) or with redirect to another flow node. You can specify behavior via "Reply with" radio-button.

Qna-package adds middleware that listens to user's messages and if they match an intent of the question it either responds with an answer, or redirects to some flow-node.

Programmatic usage

botpress-qna exposes public API for importing/exporting questions: bp.qna.import and bp.qna.export. See examples below on how to use them.

// Importing questions provided as an array of objects
const questions = [
  { questions: ['Question1', 'Question2'], action: 'text', answer: 'Answer1' },
  { questions: ['Question3'], action: 'redirect', answer: 'main.flow.json#some-node' }
]
await bp.qna.import(questions)

// Importing questions from json-string
const questionsJson = `[
  { "questions": [ "Question1", "Question2" ], "action": "text", "answer": "Answer1" },
  { "questions": [ "Question3" ], "action": "redirect", "answer": "main.flow.json#some-node" }
]`
await bp.qna.import(questions, { format: 'json' })

// Importing questions from csv-string
// Note: consequtive questions with similar answer will be merged into one record with multiple questions
const questionsCsv = 
`"Question1","text","Answer1"
"Question2","text","Answer1"
"Question3","redirect","main.flow.json#some-node"`
await bp.qna.import(questions, { format: 'csv' })
const questionsExported = await bp.qna.export() // Should return structure similar to "questions" const in previous example

const questionsFlatExported = await bp.qna.export({ flat: true })
// Should return a flat structure with question-string in each record like this (might be useful for exporting to CSV):
// 
// [
//   { question: 'Question1', action: 'text', answer: 'Answer1' },
//   { question: 'Question2', action: 'text', answer: 'Answer1' },
//   { question: 'Question3', action: 'redirect', answer: 'main.flow.json#some-node' }
// ]
const answers = await bp.qna.answersOn('How can I reach you out?')
// [ { questions: [ 'How can I reach you out?' ],
//     answer: 'You could find us on Facebook!',
//     id: 116,
//     confidence: 100,
//     enabled: true,
//     action: 'text' } ]

Controlling if Q&A should intercept

It may appear that it's not useful for Q&A to just intercept all the users' messages and try to match them against Q&A's intents. This can be customized by providing a hook to Q&A module that will prevent interception when returning false or a promise resolving to false.

The hook is a function accepting event and state parameters:

bp.qna.shouldProcessMessage((event, state) => Promise.resolve(false))
bp.qna.shouldProcessMessage(async (event, state) => state.qnaEnabled) // It's also possible to use an async-function

Contributing

The best way to help right now is by helping with the exising issues here on GitHub and by reporting new issues!

License

Botpress is dual-licensed under AGPLv3 and the Botpress Proprietary License.

By default, any bot created with Botpress is licensed under AGPLv3, but you may change to the Botpress License from within your bot's web interface in a few clicks.

For more information about how the dual-license works and why it works that way please see the FAQS.

10.51.10

5 years ago

10.51.9

5 years ago

10.51.8

5 years ago

10.51.7

5 years ago

10.51.6

5 years ago

10.51.5

5 years ago

10.51.4

5 years ago

10.51.3

5 years ago

10.51.2

5 years ago

10.51.1

5 years ago

10.51.0

5 years ago

10.50.0

6 years ago

10.49.0

6 years ago

10.48.5

6 years ago

10.48.4

6 years ago

10.48.3

6 years ago

10.48.2

6 years ago

10.48.1

6 years ago

10.48.0

6 years ago

10.47.1

6 years ago

10.47.0

6 years ago

10.46.5

6 years ago

10.46.4

6 years ago

10.46.3

6 years ago

10.46.2

6 years ago

10.46.1

6 years ago

10.46.0

6 years ago

10.45.0

6 years ago

10.44.2

6 years ago

10.44.1

6 years ago

10.44.0

6 years ago

10.43.0

6 years ago

10.42.0

6 years ago

10.41.1

6 years ago

10.41.0

6 years ago

10.40.0

6 years ago

10.39.0

6 years ago

10.38.0

6 years ago

10.37.1

6 years ago

10.36.1

6 years ago

10.36.0

6 years ago

10.35.1

6 years ago

10.35.0

6 years ago

10.34.0

6 years ago

10.33.2

6 years ago

10.33.1

6 years ago

10.33.0

6 years ago

10.32.0

6 years ago

10.31.0

6 years ago

10.30.0

6 years ago

10.28.0

6 years ago

10.27.1

6 years ago

10.27.0

6 years ago

10.26.0

6 years ago

10.25.2

6 years ago

10.25.1

6 years ago

10.25.0

6 years ago

10.24.4

6 years ago

10.24.3

6 years ago

10.24.2

6 years ago

10.24.1

6 years ago

10.24.0

6 years ago

10.23.0

6 years ago

10.22.4

6 years ago

10.22.3

6 years ago

10.22.2

6 years ago

10.22.1

6 years ago

10.22.0

6 years ago

10.21.0

6 years ago

10.20.1

6 years ago

10.20.0

6 years ago

10.19.0

6 years ago

10.18.0

6 years ago

10.17.3

6 years ago

10.17.2

6 years ago

10.17.1

6 years ago

10.17.0

6 years ago

10.16.1

6 years ago

10.16.0

6 years ago

10.15.0

6 years ago

10.14.2

6 years ago

10.14.1

6 years ago

10.14.0

6 years ago

10.13.4

6 years ago

10.13.3

6 years ago