def CheckIntent(user_query): session_client = dialogflow_v2.SessionsClient() session = session_client.session_path("adviserbot-bluy", "testrun1") intent_client = dialogflow_v2.IntentsClient() parent = dialogflow_v2.AgentsClient.agent_path("adviserbot-bluy") intents = intent_client.list_intents(request={"parent": parent}) # for intent in intents: # print("Intent display name: {}".format(intent.display_name)) text_input = dialogflow_v2.TextInput(text=user_query, language_code="en-US") query_input = dialogflow_v2.QueryInput(text=text_input) response = session_client.detect_intent( request={"session": session, "query_input": query_input} ) # if response.query_result.intent.display_name == 'Check Prerequisites': intent = response.query_result.intent.display_name params = response.query_result.parameters.get('course') # Get the prereqs here and print the prereqs print(response.query_result.fulfillment_text) # print( # "Detected intent: {} (confidence: {})\n".format( # response.query_result.intent.display_name, # response.query_result.intent_detection_confidence, # ) # ) if intent == "Check Sufficiency": return (intent, [response.query_result.parameters.get("course"), response.query_result.parameters.get("course1")]) return intent, params
def sample_delete_intent(): # Create a client client = dialogflow_v2.IntentsClient() # Initialize request argument(s) request = dialogflow_v2.DeleteIntentRequest(name="name_value", ) # Make the request client.delete_intent(request=request)
def sample_get_intent(): # Create a client client = dialogflow_v2.IntentsClient() # Initialize request argument(s) request = dialogflow_v2.GetIntentRequest(name="name_value", ) # Make the request response = client.get_intent(request=request) # Handle the response print(response)
def sample_list_intents(): # Create a client client = dialogflow_v2.IntentsClient() # Initialize request argument(s) request = dialogflow_v2.ListIntentsRequest(parent="parent_value", ) # Make the request page_result = client.list_intents(request=request) # Handle the response for response in page_result: print(response)
def sample_update_intent(): # Create a client client = dialogflow_v2.IntentsClient() # Initialize request argument(s) intent = dialogflow_v2.Intent() intent.display_name = "display_name_value" request = dialogflow_v2.UpdateIntentRequest(intent=intent, ) # Make the request response = client.update_intent(request=request) # Handle the response print(response)
def sample_batch_update_intents(): # Create a client client = dialogflow_v2.IntentsClient() # Initialize request argument(s) request = dialogflow_v2.BatchUpdateIntentsRequest( intent_batch_uri="intent_batch_uri_value", parent="parent_value", ) # Make the request operation = client.batch_update_intents(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response)
def sample_batch_delete_intents(): # Create a client client = dialogflow_v2.IntentsClient() # Initialize request argument(s) intents = dialogflow_v2.Intent() intents.display_name = "display_name_value" request = dialogflow_v2.BatchDeleteIntentsRequest( parent="parent_value", intents=intents, ) # Make the request operation = client.batch_delete_intents(request=request) print("Waiting for operation to complete...") response = operation.result() # Handle the response print(response)