Disclosure : Some of the links in this post are affiliate links so if you click on the link and purchase the item, I will receive a commission.

How to Get Intents Using the Python DialogFlow Client

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

How to Get the DialogFlow Intent Name in Python

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.

How to Search for an Intent Display Name in DialogFlow

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

Other How to Build a Chatbot Articles

placeholder image

Cookie Consent

This website uses cookies or similar technologies, to enhance your browsing experience and provide personalized recommendations. By continuing to use our website, you agree to our Privacy Policy