Home / DialogFlow ES / How to create new Dialogflow agent programmatically
DialogFlow ES

How to create new Dialogflow agent programmatically

Some people have asked me if it is possible to programmatically create a new Dialogflow agent. Until recently, this wasn’t possible. But Dialogflow recently added a method to their v2 API which allows this.

  1. Disclaimer

    This tutorial tells you how to achieve a specific task. If you blindly follow this tutorial without understanding the ramifications for your billing/resource quote etc. then you are solely responsible for the outcomes.

  2. Login to your Google cloud account

    If you remain logged in to your Google Cloud account, all these steps will go faster.

  3. Go to the agent creation documentation page

    First go to the appropriate link. This is the page which describes the next steps.
    Notice that you have an API explorer on the right side.

  4. Go to Google Cloud console and create a new project

    Log in to your Google Cloud Console. Click on “Create new project”

  5. Copy the project ID

    You need to get the projectID and not the project name.

  6. Go the API explorer browser window and paste the project ID

    Type the following in the API explorer textbox called parent (See image):

  7. Go the Request body textbox and click on the plus sign

    You will see that there is a dropdown with some kind of intellisense inside the Request body textbox.

  8. Add a field for the displayName

    This will become the name of your agent.

  9. Click on the Execute button

    Scroll down and click on the Execute button at the bottom of the page.

  10. Authenticate with the API explorer

    You will also give permission to the API explorer to execute these commands on your account’s behalf.

  11. Verify that you get a success message

    If you see a success message, your new Dialogflow agent has been created.

  12. Now do the same from your code

    Remember that everything you can do from the API explorer can also be done programmatically.

Now, there are a few things we haven’t considered here.

Can we use an existing projectID to create a new agent? (No, because it will overwrite it)

Can we create multiple agents per project using this method? (No, for the same reason as above)

How can we automatically create a new Google cloud project in the first place so we can automate the whole thing end to end?

You can follow similar steps and use this API method, but make sure you really understand the ramifications of creating new Google Cloud projects on your billing and quote etc.

<— End of article —>

This website contains affiliate links. See the disclosure page for more details. 
"The magic key I needed as a non-programmer"

The custom payload generator was the magic key I needed (as a non-programmer) to build a good demo with rich responses in DialogFlow Messenger. I've only used it for 30 minutes and am thrilled. I've spent hours trying to figure out some of the intricacies of DialogFlow on my own. Over and over, I kept coming back to Aravind's tutorials available on-line. I trust the other functionalities I learn to use in the app will save me additional time and heartburn.

- Kathleen R
Cofounder, gathrHealth
"Much clearer than the official documentation to be honest"

Thanks a lot for the advice (of buying and following your videos)! They helped a lot indeed. Everything is very clear when you explain, much clearer than the official documentation to be honest 🙂

Neuraz T
Review for Learn Dialogflow CX
"I will strongly recommend this course because even I can learn how to design chatbot (no programming background)"

I think Aravind really did a great job to introduce dialogflow to people like me, without programming background. He organizes his course in very clear manner since I have been a college professor for 20 years. It is very easy for me to recognize how great Aravind’s course is! Very use-friend and very easy to follow. He doesn’t have any strong accent when he gives the lectures. It is so easy for me to understand. Really appreciate it.

Yes, I will strongly recommend this course because even I can learn how to design chatbot (no programming background) after studying Avarind’s course, you definitely can!

Ann Cai
Review for Learn Dialogflow ES

Similar Posts

  • When tried to do the same using code getting 404 error. May be bacause of Authentication Error. How will we give authentication through script other than creating service account manually? The Goal is to create a dialogflow Agent completly through scrpit. Thanks in Advance