Skip to content

Instantly share code, notes, and snippets.

@Elleo
Last active January 11, 2018 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elleo/f54dffe9b92924e9ce8585dec66d8a08 to your computer and use it in GitHub Desktop.
Save Elleo/f54dffe9b92924e9ce8585dec66d8a08 to your computer and use it in GitHub Desktop.
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