fulfillment-telephony-nodejs
fulfillment-telephony-nodejs copied to clipboard
Sample integrating Telephony, Google Sheets, and Slot Filling with Dialogflow
Dialogflow Fulfillment with Telephony, Google Sheets API, and Slot Filling
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.
Setup
Select only one of the options below.
Option 1: Add to Dialogflow (Recommended)
To create this agent from our template:

Option 2: Firebase CLI
- 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.
Configuration
Service Account Authentication with JWT/OAuth 2.0
- 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:
Adding Service Account Details to Agent and a Google Sheet
- From your preferred Google Drive account, create a new spreadsheet and Share with the service account email
- Should resemble
[email protected]
- 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:
Getting a Dialogflow Telephony Gateway Phone Number
- 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
Testing this Sample
- 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
.
Adding Audio Files to Agent (Optional)
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:
Related Samples
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.
References & Issues
- 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
Make Contributions
Please read and follow the steps in the CONTRIBUTING.md
License
See LICENSE.md
Terms
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.