Sample integrating Telephony, Google Sheets, and Slot Filling with Dialogflow
Switch branches/tags
Nothing to show
Clone or download
sarahdwyer LICENSE update
Change-Id: Ic6c8e0d82d63c365e80b673a32b428e06336bbb7
Latest commit 36a26d0 Oct 29, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
dialogflow-agent Telephony initial commit Oct 26, 2018
functions Telephony initial commit Oct 26, 2018
.gitignore Telephony initial commit Oct 26, 2018 Telephony initial commit Oct 26, 2018
LICENSE LICENSE update Oct 29, 2018 Telephony initial commit Oct 26, 2018 Telephony initial commit Oct 26, 2018

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.


Select only one of the options below.

Option 1: Add to Dialogflow (Recommended)

To create this agent from our template:

Option 2: Firebase CLI

  1. Create a Dialogflow Agent.
  2. git clone
  3. Go to Settings ⚙ > Export and Import > Restore from zip using the in this directory.
  4. cd to the functions directory
  5. Run npm install.
  6. Install the Firebase CLI by running npm install -g firebase-tools
  7. Login with your Google account, firebase login
  8. Add your project to the sample with firebase use <project ID>
  • In Dialogflow console under Settings ⚙ > General tab > copy Project ID.
  1. Run firebase deploy --only functions:dialogflowFulfillment
  2. Back in Dialogflow Console > Fulfullment > Enable Webhook.
  3. Paste the URL from the Firebase Console’s events column into the URL field > Save.


Service Account Authentication with JWT/OAuth 2.0

  1. From the Dialogflow's console > go to Settings ⚙ and under the General tab > go the Project Id link, which will take you to the Google Cloud Platform console
  2. In the Cloud console, go to Menu ☰ > APIs & Services > Library
  3. Select Google Sheets API > Enable
  4. Under Menu ☰ > APIs & Services > Credentials > Create Credentials > Service Account Key.
  5. 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

Adding Service Account Details to Agent and a Google Sheet

  1. From your preferred Google Drive account, create a new spreadsheet and Share with the service account email
    • Should resemble
    • To find the Service account email, look in the private JSON file > client_email
  2. In the Dialogflow console > Fulfillment section > replace line 26 with the private JSON contents and line 56 with the service account-shared spreadsheetId.
    • You can find the spreadsheetId from the Google Sheets URL:<SPREADSHEETID>/

Getting a Dialogflow Telephony Gateway Phone Number

  1. From Settings ⚙ > General tab > Enable Beta features and APIs > Save
  2. 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

  1. 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.
  2. Add the following columns to your Google Sheet (A1 to E1): Date, Time (24HR), Name, Group, Number
  3. 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:

  1. File > Convert/Stream

  2. Choose Profile > Audio CD > Customize > Audio codec

    • WAV
    • Bitrate = 16
    • Channels = 1
    • Samplerate = 8000 > Apply > Save as File
  3. Upload this file through Google Cloud Platform console > Menu ☰ > Storage > Browser > select a bucket link and upload your audio file.

  4. Back in the Dialogflow console, you can now add Telephony Play audio responses with the following format:

    • Generally: gs://<bucket>/<object>
    • Ex: gs://

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

Make Contributions

Please read and follow the steps in the




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.