In this example, we'll be creating a simple Python-based API that calls to the agent we created in the Dialogflow console to invoke Dummy Intent, as shown:
- Firstly, we must import the Dialogflow module to the project. To do so, use the following code:
import dialogflow
- To get the project ID into the script, we can fetch it from the runtime environment variables. To do so, use the following code:
import osproject_id = os.getenv("DIALOGFLOW_PROJECT_ID")
- We will also declare a unique session ID to store the records of the conversations made in any single session with the user:
session_id="any_random_unique_string"
- We'll now create a handy function that will allow us to repeatedly perform a ...