The following is a restaurant reservation sample that involves interacting with the restaurant's agent through a provided Dialogflow Telephony Gateway phone number in order to make a reservation and alternatively, the user can opt to have a call be placed to the restaurant's main line. This sample will highlight certain Telephony features that can bring more depth and substance to a typical agent.
Telephony features: + Synthesize speech for SSML support + Playing audio + Call transfers
The reservation data will be saved using the Google Sheets API. In addition, slot filling simplifies your agent by letting you obtain multiple, required parameters within a single intent as well as automatically managing contexts via output contexts. If any parameters are missing from a user utterance, your agent will automatically prompt users for the required parameters.
Select only one of the options below.
To create this agent from our template:
- Create a Dialogflow Agent.
git clone https://github.com/dialogflow/fulfillment-telephony-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 events column into the URL field > Save.
- From the Dialogflow's console > go to Settings ⚙ and under the
General
tab > go theProject Id
link, which will take you to the Google Cloud Platform console - In the Cloud console, go to Menu ☰ > APIs & Services > Library
- Select Google Sheets API > Enable
- Under Menu ☰ > APIs & Services > Credentials > Create Credentials > Service Account Key.
- From the dropdown, select New Service Account
- name:
telephony-sample
- role: Project/Owner
- key type: JSON > Create
- JSON file will be downloaded to your local machine
- name:
- From your preferred Google Drive account, create a new spreadsheet and Share with the service account email
- Should resemble
telephonyfulfillment@telephonysample.iam.gserviceaccount.com
- To find the Service account email, look in the private JSON file > client_email
- Should resemble
- In the Dialogflow console > Fulfillment section > replace
line 26
with the private JSON contents andline 56
with the service account-shared spreadsheetId.- You can find the spreadsheetId from the Google Sheets URL:
https://docs.google.com/spreadsheets/d/<SPREADSHEETID>/
- You can find the spreadsheetId from the Google Sheets URL:
- From Settings ⚙ > General tab > Enable Beta features and APIs > Save
- Go to the Integrations section >
- Select an Area Code (optional) > Next > Choose a number
- You can always view your agent's number by visiting Integrations > Dialogflow Telephony Gateway
- From the Dialogflow console, replace all the phone numbers in the Telephony
Call transfer
responses to a number that you can ensure it is working as expected. - Add the following columns to your Google Sheet (A1 to E1):
Date
,Time (24HR)
,Name
,Group
,Number
- Now you can test out this sample by calling the Dialogflow Telephony agent's number at
+1 415-582-6862
.
For Telephony's playing audio files feature, you can use VLC in order to properly reformat a given .wav file with the following steps:
-
File > Convert/Stream
-
Choose Profile > Audio CD > Customize > Audio codec
- WAV
- Bitrate = 16
- Channels = 1
- Samplerate = 8000 > Apply > Save as File
-
Upload this file through Google Cloud Platform console > Menu ☰ > Storage > Browser > select a bucket link and upload your audio file.
-
Back in the Dialogflow console, you can now add Telephony
Play audio
responses with the following format:- Generally:
gs://<bucket>/<object>
- Ex:
gs://telephonysample.appspot.com/gcloud-multi.wav
- Generally:
Name | Language |
---|---|
Fulfillment & Regex Validation | Node.js |
Weather: Fulfillment & WWO API | Node.js |
Basic Slot Filling | 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 |
For Fulfillment Webhook JSON Requests & Responses.
- Questions? Try StackOverflow, Dialogflow Help Forum, or Support.
- For bugs, please report an issue on Github.
- Dialogflow Documentation.
- Dialogflow Fulfillment Classes Reference.
- For more info on the Actions on Google NPM module
- For more info on Building Actions on Google with Dialogflow Agents Documentation
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 and Dialogflow's Terms of Use and Privacy Policy.