Last active
January 11, 2018 14:59
-
-
Save Elleo/f54dffe9b92924e9ce8585dec66d8a08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handle_question(question, channel, slack_client, cape_client): | |
# Retrieve a list of answers to the user's question | |
answers = cape_client.answer(question, CAPE_TOKEN) | |
if len(answers) > 0: | |
# Respond with the highest confidence answer | |
slack_client.api_call("chat.postMessage", channel=channel, | |
text=answers[0]['answerText'], | |
as_user=True) | |
else: | |
# No answer was found above the current confidence threshold | |
slack_client.api_call("chat.postMessage", channel=channel, | |
text="Sorry! I don't know the answer to that.", | |
as_user=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment