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 Delete DialogFlow Intents Using the Python Library

There are two ways to delete an intent in python using the DialogFlow Python Client. You can delete them singularly, or you can batch delete them.

In either case, you first grab the dialogflow.IntentsClients and the project_agent_path.


intents_client = dialogflow.IntentsClient()
parent = intents_client.project_agent_path(manage_dialogflow_project_id())

How to Delete an Individual DialogFlow Intent

To delete an intent, you just need to know the full name of the intent. Notice, that is NOT the display name. There are multiple ways to get the intent name using the python client.

At that point, intents are simply deleted with the "delete_intent" call.


intents_client.delete_intent(intent_name)

Deleting All Dialogflow Intents

To delete all the intents, you just need a list of the intents, which you can get with:


intents = intents_client.list_intents(parent)
Then you can batch delete them:

if intents:
  intents_client.batch_delete_intents(parent, intents)

You could also filter the above list before deleting it, such as.


intents_client = dialogflow.IntentsClient()
parent = intents_client.project_agent_path(manage_dialogflow_project_id())

intents_to_delete = []
intents = intents_client.list_intents(parent)
for intent in intents:
    log(intent.name)
    log(intent.display_name)
    if ## Condition met for deletion, such as '"search_string" in intent.display_name:'
      intents_to_delete.append(intent)

if intents_to_delete:
    intents_client.batch_delete_intents(parent, intents_to_delete)

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