def handle_message(self, message):
    'Respond to the user message by retriving documents from the knowledge base. \n    \n        Args:\n            message ([type]): [description]\n        '
    query = message.text
    (candidates, similarities) = self.vector_index.retrieve(query, self.topk)
    selected = [candidate for (candidate, similarity) in zip(candidates, similarities) if (similarity >= self.threshold)]
    result = {}
    if selected:
        documents = self.es_index.get_answer_by_question_ids(selected)
        response = self.template.render(documents=documents)
        result['response'] = BotMessage(message.sender_id, response.strip())
    else:
        selected = [candidate for (candidate, similarity) in zip(candidates, similarities) if (similarity >= self.prompt_threshold)]
        if selected:
            documents = self.es_index.get_documents_by_ids(selected)
            prompt = self.prompt_template.render(documents=documents)
            result['prompt'] = BotMessage(message.sender_id, prompt.strip())
    return result
Respond to the user message by retriving documents from the knowledge base. 

Args:
    message ([type]): [description]
def handle_message(self, message):
    'Respond to the user message by retriving documents from the knowledge base. \n    \n        Args:\n            message ([type]): [description]\n        '
    query = message.text
    (candidates, similarities) = self.vector_index.retrieve(query, self.topk)
    selected = [candidate for (candidate, similarity) in zip(candidates, similarities) if (similarity >= self.threshold)]
    result = {}
    if selected:
        documents = self.es_index.get_answer_by_question_ids(selected)
        response = self.template.render(documents=documents)
        result['response'] = BotMessage(message.sender_id, response.strip())
    else:
        selected = [candidate for (candidate, similarity) in zip(candidates, similarities) if (similarity >= self.prompt_threshold)]
        if selected:
            documents = self.es_index.get_documents_by_ids(selected)
            prompt = self.prompt_template.render(documents=documents)
            result['prompt'] = BotMessage(message.sender_id, prompt.strip())
    return result