Skip to main content

$faq.getReplies

This method returns all messages that are part of an answer to a question from an FAQ module in the knowledge base.

Syntax

This method accepts the basic wording of the FAQ question with the prefix /KnowledgeBase in it as the string argument (an optional parameter). If you do not specify this parameter, the path to the intent that the bot switched to the state with getReplies will be used.

$faq.getReplies("/KnowledgeBase/FAQ.topic/Root/Intent path");

A JSON object with the answer parameters from the FAQ is returned as a response.

caution
If you apply this method with an intent not from the FAQ, an error will occur in the script.

How to use

Let’s look at an example. The bot knowledge base includes the FAQ.Contact Information module. You can set the answer to the question *In which countries do you have branches? * in all available formats: enter a text, as well as upload an image, audio file, and file.

state: GetReplies
intent!: /KnowledgeBase/FAQ.Contact Information/Root/In which countries do you have branches?
script:
var answers = $faq.getReplies("/KnowledgeBase/FAQ.Contact Information/Root/In which countries do you have branches?")
$reactions.answer(JSON.stringify(answers))

An array of JSON objects will be sent as a response:

[
{
"type": "text",
"text": "We have offices all over the world!",
"markup": "html"
},
{
"type": "image",
"imageUrl": "https://example.com/image.jpg",
"uploadDate": 1668087929071 // The date the image was uploaded in Unix format.
// This field is used to display the upload date in the knowledge base interface.
},
{
"type": "audio",
"audioUrl": "https://example.com/audio.mp3",
"audioName": "Audio.mp3",
"uploadDate": 1668087947270
},
{
"type":"file",
"fileUrl": "https://example.com/file.pdf",
"fileName": "File.pdf",
"uploadDate": 1668087969706
}
]