Intents are a large part of the lifeblood of DialogFlow, and when you are using the python client you will often need to get intents to modify, delete, or update.
To interact directly with an intent, you always need to get the full intent path, which is:
intents_client = dialogflow.IntentsClient()
name = intents_client.intent_path(dialogflow_project_id(), intent_UUID)
You can then delete, update, or get the intent with that "name".
intent = intents_client.get_intent(name) #Get the intent
intents_client.delete_intent(name) #Delete the intent, etc
However, the intent_UUID is not the display name (which is shown as the "intent name" in the visual admin), it is the unique identifier. There are a few ways to grab this. The first is to pull up the "Edit Intent" page in the DialogFlow admin. The UUID is then the last part of the url:
https://dialogflow.cloud.google.com/#/agent/xxxxx/editIntent/1c681506-fca2-4fd4-9eac-09eed28507ad/
This works just fine with a limited amount of intents, but it doesn't work if you need to get something dynamically, or a large number.
Currently, the only way I've found to get an intent based on the display name is through retreiving all of the intents, then looping through them with a search string search.
intents_client = dialogflow.IntentsClient()
parent = intents_client.project_agent_path(dialogflow_project_id())
intent_to_find_display_name = "My Intent Name"
intents = intents_client.list_intents(parent)
for intent in intents:
if intent_to_find_display_name == intent.display_name:
intent_to_find = intent
if intent_to_find:
#do stuff with intent_to_find
You can also grab the full name (what you would normally get from intents_client.intent_path(dialogflow_project_id(), intent_UUID)
) from it at that point with.
intent_to_find.name