I am trying to integrate DialogFlow using the Python SDK. Code:
def detect_action_from_phrase(self, phrase):
"""Returns the result of detect intent with texts as inputs.
Using the same `session_id` between requests allows continuation
of the conversaion."""
print("Called intent detection")
session_client = dialogflow.SessionsClient()
session = session_client.session_path(self.project_id, self.session_id)
text_input = dialogflow.types.TextInput(
text=phrase, language_code=self.language_code)
query_input = dialogflow.types.QueryInput(text=text_input)
print("NLP getting resp")
response = session_client.detect_intent(
session=session, query_input=query_input)
print("Received resp")
intent = response.query_result.intent
action = response.query_result.action
print('=' * 20)
print('Query text: {}'.format(response.query_result.query_text))
print('Detected intent: {} (confidence: {})\n'.format(
response.query_result.intent.display_name,
response.query_result.intent_detection_confidence))
print("Action: {}\n".format(action))
print('Fulfillment text: {}\n'.format(
response.query_result.fulfillment_text))
return action
I set session_id to "1".
I have an account credential JSON file, which an environment variable points to as explained in the docs.
Everything works fine locally, but when I use it on AWS Elastic Beanstalk, for some reason it works sometimes and other times completely times out. The script starts timing out just after printing "NLP getting resp".
I don't understand this. Any tips on why this is happening or a good way to debug it?
I'm using the v2 API and SDK.