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.
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.
- Login to your Google cloud account
If you remain logged in to your Google Cloud account, all these steps will go faster.
- 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.
- Go to Google Cloud console and create a new project
Log in to your Google Cloud Console. Click on "Create new project"
- Copy the project ID
You need to get the projectID and not the project name.
- Go the API explorer browser window and paste the project ID
Type the following in the API explorer textbox called parent (See image):
- 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.
- Add a field for the displayName
This will become the name of your agent.
- Click on the Execute button
Scroll down and click on the Execute button at the bottom of the page.
- Authenticate with the API explorer
You will also give permission to the API explorer to execute these commands on your account's behalf.
- Verify that you get a success message
If you see a success message, your new Dialogflow agent has been created.
- 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.
- Using Collect.chat for preNLU bots
- Reader Question: How to get some sample training data for Dialogflow?
- Getting the top 3 (or top N) intents in Dialogflow: An experiment
- Dialogflow Regexp (regular expression) entity
- Using Dialogflow for educational bots
- Chatbot makes $3 million in sales in 1 hour
- Reader Question: Intent based FAQ bots vs knowledge based FAQ bots
- Should you use Dialogflow from scratch?
- 3 ways Airtable can speed up your Dialogflow prototype development
- Automatically generating a rich Dialogflow website chatbot