Answer Question

Verb: answerQuestion

Available from: <Enterprise>

Answers questions, based on the answers and questions contained in the Knowledge Base used for the interaction.

Syntax

answerQuestion --kb(String) [--version(Numeric)] [--minimumscore(Numeric)] [--topn(Numeric)] [--options(Nullable<AnswerQuestionOptions>)] [--botHistoryMessageId(String)] --culture(Culture) --text(String) (String)=answer (String)=tags (String)=context (Numeric)=score (List<String>)=options (DataTable)=data (Boolean)=success

Inputs

Script Designer Required AcceptedTypes Description
--kb Knowledge Base Required Text Knowledge Base that will be used to query the answer based on the user's question.
For the execution of the command to occur, it is necessary to first create a Knowledge Base, in which it must contain the possible questions from the user and the closest answers to the question asked. This base is built according to a template and used on IBM Robotic Process Automation Studio, through the menu "Tools> Model Builder Machine Learning".
--version Version Optional Number Knowledge Base version used.
--context Context(Obsolete) Optional Text Context to look for on the analysed text.
1. The context provides patterns and themes that the Chatbot should look for to give more accurate answers to the user.
2. This parameter is obsolete, the output parameter Context should be used instead.
--minimumscore Minimum Score Optional Number Minimum acceptable score of the answer in relation to the user's question.
--topn Answers Quantity Optional Number Number of responses that are returned, which may bring more than one answer from the Knowledge Base used.
--options Options Optional AnswerQuestionOptions Option that will be used if, when querying answers in the Knowledge Base, other forms of research might be considered as well, such as:
  • Use Synonyms
  • --botHistoryMessageId Bot Ask History Optional Text Identifier referring to the conversation history returned by the commands of the category "Communication" and subcategory "Ask", and which will associate the responses returned by the Answer Question command to the history.
    --culture Language Required Culture Language that is used in the bot conversation:
  • en-US
  • pt-BR
  • pt-PT

  • The variable of type "Language" can be obtained previously through the Create a Language command.
    --text Text Required Text Text that contains the user's response.

    Outputs

    Script Designer AcceptedTypes Description
    answer Answer Text Returns the answer that has the highest score in relation to the user's question.
    tags Tags Text Returns the tags for the context of the question and answer in the interaction.
    The labels are configured in the Knowledge Base used by the command.
    context Context Text Returns the context of the conversation.
    score Score Number Returns the score for the best answer.
    options Additional Answers List<Text> Returns a list of additional responses to the user's question.
    data Data Data Table Returns a data table with information about the questions, answers, contexts, scores and labels.
    success Success Boolean Returns "True", if the script runs successfully, or "False", otherwise.

    Example

    In the following example, the Answer Question command takes the user's speech, returned by the Bot Ask command to analyze the text based on the "KB-flower-shop" knowledge base model. Then, it returns the most appropriate answer to the user's question. In this case, the user is able to ask questions such as "What kind of products do you have?" or "What chocolates do you have?".

    defVar --name userResponse --type String
    defVar --name betterResponse --type String
    defVar --name tag --type String
    defVar --name botLanguage --type Language
    createLanguage --culture en-US botLanguage=value
    botConnect --type "Chat" --language ${botLanguage} --autoanswer  --timeout 00:05:00
        botAsk --retry  --attempts 3 --retrytext "What is your question?" --language ${botLanguage} --text "Hello! How can I help you?" --timeout 00:01:00 userResponse=value
        while --left "${tag}" --operator "Equal_To" --right closure --negate
            answerQuestion --kb "KB-flower-shop" --minimumscore 500 --culture en-US --text "${userResponse}" betterResponse=answer tag=tags
            if --left "${tag}" --operator "Equal_To" --right "+closure"
                botSay --text "${betterResponse}"
                break
            endIf
            botAsk --retry  --attempts 3 --retrytext "What is your question?" --language ${botLanguage} --text "${betterResponse}" --timeout 00:01:00 userResponse=value
        endWhile
    botDisconnect
    

    Download file

    For the above script to work correctly, the knowledge base must be published using the Machine Learning Model Builder in IBM RPA Studio.

    See Also

  • Boolean Extract
  • Classify Text
  • Extract Address
  • Extract CNPJ
  • Extract CPF
  • Extract Date
  • Extract E-mail Address
  • Extract Intent
  • Extract Monetary Value
  • Extract Named Entities
  • Extract Numbers
  • Extract Phone Number
  • Extract Quantity
  • Extract Time Span
  • Parse Sentences
  • Search Postal Code
  • Spell Checker
  • Summarize Text
  • Synonyms