Enhancing the Google Dialogflow Python client
In this section, we will enhance our program to prepare it for the XAI dialog we will build using the functions we wrote in the previous sections.
For this section, use python_client_02.py
.
The goal of this section is to transform the query and response dialog of python_client_01.py
into a function that can be called by various XAI requests a user might make.
Creating a dialog function
The import and credential code at the beginning of the program remains unchanged. We will simply create a function that will receive our our_query
variable and return the response:
def dialog(our_query):
# session variables
session_client = dialogflow.SessionsClient()
session = session_client.session_path(DIALOGFLOW_PROJECT_ID,
SESSION_ID)
# Our query
our_input = dialogflow.types.TextInput(text=our_query,
language_code=DIALOGFLOW_LANGUAGE_CODE)
query = dialogflow...