This sample demonstrates how to create and update developer entities using the Dialogflow Node.js Client and the Dialogflow Fulfillment Library. It also demonstrates how to create session entities from your fulfillment code.
The sample consists of two parts:
- A Dialogflow agent that asks users trivia about their favorite city
- Scripts that automate the creation and deletion of developer entities.
The following sections describe how to set up use the agent and accompanying scripts.
Select only one of the options below to set up the Dialogflow agent for this sample.
To create this agent from our template:
- Create a Dialogflow Agent.
- Clone this repo:
git clone https://github.com/dialogflow/city-streets-trivia-nodejs.git
. - Go to Settings ⚙ > Export and Import > Restore from zip using the
dialogflow-agent.zip
in this directory. cd
to thefunctions
directory.- Run
npm install
. - Install the Firebase CLI by running
npm install -g firebase-tools
. - Login with your Google account,
firebase login
. - Add your project to the sample with
firebase use <project ID>
.- In Dialogflow console under Settings ⚙ > General tab > copy Project ID.
- Run
firebase deploy --only functions:dialogflowFulfillment
. - Back in Dialogflow Console > Fulfullment > Enable Webhook.
- Paste the URL from the Firebase Console’s Trigger column under the Functions > Dashboard tab into the URL field > Save.
- Clone this repo:
git clone https://github.com/dialogflow/city-streets-trivia-nodejs.git
. - Run
npm install
. - Create a service account and obtain a credentials JSON file, following the instructions in Setting up authentication. Choose "Dialogflow API Admin" when selecting the role.
- Once you have downloaded the JSON file, rename it to
credentials.json
and place it in the root of the repo. - Each script assumes you have created a Dialogflow agent and it has a project ID of
city-streets-trivia
. If your project ID is different, you should find and replace the single occurrence of this string in each script with your own ID.
This script demonstrates how to create developer entities through code. Running it will result in the creation of city
and street
entities in the agent whose name is specified in the script.
Note that if you created your agent using the Add to Dialogflow button in this README.md, your agent will already have these entities. In this case, to run create.js successfully you should delete the "city" and "street" entities from the agent via Dialogflow's UI.
To run the script, use the following command:
> node create.js
This script demonstrates how to update developer entities through code. Running it will update the city
developer entity to include values defined in the script. In production, a similar script could be used to keep Dialogflow entities synchronized with data fetched from a datastore.
To run the script, use the following command:
> node update.js
Name | Language |
---|---|
Fulfillment & Regex Validation | Node.js |
Weather: Fulfillment & WWO API | Node.js |
Bike Shop: Fulfillment & Google Calendar API | Node.js |
Temperature Trivia: Fulfillment & Actions on Google | Node.js |
Fulfillment & Actions on Google | Node.js |
Fulfillment & Firestore Database | Node.js |
Multi-language/locale | Node.js |
Basic Slot Filling | Node.js |
Alexa Importer | Node.js |
For Fulfillment Webhook JSON Requests & Responses.
- Questions? Try StackOverflow or Dialogflow Developer Community.
- For bugs, please report an issue on Github.
- Dialogflow Documentation.
- Dialogflow Classes Reference Doc.
- For more info about billing.
Please read and follow the steps in the CONTRIBUTING.md.
See LICENSE.md.
Your use of this sample is subject to, and by using or downloading the sample files you agree to comply with, the Google APIs Terms of Service.