Fulfillment: How to Integrate Dialogflow with Google Calendar
Summary
TLDRIn this episode of 'Deconstructing Chatbots', Priyanka Vergadia guides viewers on integrating Dialogflow agents with backend systems like databases or CRMs using fulfillment. The tutorial covers enabling the Google Calendar API, setting up a service account, and creating a calendar. It then demonstrates how to implement fulfillment in Dialogflow for scheduling appointments, including handling calendar conflicts, by connecting the Dialogflow agent to Google Calendar through a Cloud Function.
Takeaways
- 📕 Deconstructing Chatbots is a series hosted by Priyanka Vergadia focusing on chatbot development.
- 💵 Dialogflow agents require back-end integration, such as with databases or calendars, to transfer information using business logic.
- 💵 Fulfillment in Dialogflow is a code piece deployed as a webhook that connects the agent to business logic on a per-intent basis.
- 💵 For dynamic responses and back-end actions, Dialogflow's NLP-extracted information is used during conversations.
- 💵 The example in the episode is an appointment scheduler chatbot that needs to integrate with a calendar for real-world functionality.
- 💵 To integrate with Google Calendar, the Google Calendar API must be enabled in the Google Cloud Project.
- 💵 A service account key is created and a JSON file is downloaded, which is used for authentication in the fulfillment.
- 💵 The calendar ID from Google Calendar is required and should be replaced in the index.js file for the fulfillment to work.
- 💵 The fulfillment code includes functions for making appointments and handling calendar events, checking for conflicts.
- 💵 After setting up the fulfillment and enabling the webhook in the Schedule Appointment intent, the chatbot can be tested for functionality.
- 💵 The chatbot can now handle appointment scheduling, checking for availability, and providing appropriate responses based on the calendar's status.
Q & A
What is the purpose of fulfillment in Dialogflow?
-Fulfillment in Dialogflow is a piece of code deployed as a webhook that allows a Dialogflow agent to call business logic on a per intent basis, enabling dynamic responses or actions on the backend.
How does Dialogflow's natural language processing contribute to generating responses?
-Dialogflow's natural language processing extracts information which can then be used to generate dynamic responses or trigger actions on the backend during a conversation.
What is the role of the Google Calendar API in integrating Dialogflow with a calendar system?
-The Google Calendar API is used to enable the Dialogflow agent to interact with Google Calendar, allowing it to check for scheduling conflicts and set up appointments.
How do you enable the Google Calendar API for a Google Cloud Project?
-You navigate to APIs & Services in the Google Cloud Platform console, find Google Calendar API, and enable it for your cloud project.
What is a service account key in the context of Google Cloud Platform?
-A service account key is a credential that allows a service account to authenticate and act on behalf of your Dialogflow agent when interacting with Google Cloud services.
Why is it necessary to create a new calendar in Google Calendar?
-Creating a new calendar is necessary to have a dedicated space for the appointments scheduled by the Dialogflow agent, ensuring they are separate from personal or other events.
How do you grant the Dialogflow agent permission to manage events in the Google Calendar?
-You grant permission by adding the client email from the service account key to the new calendar and setting the permission to 'Make changes to events'.
What is the purpose of the 'package.json' and 'index.js' files in setting up fulfillment?
-The 'package.json' file lists the project dependencies, while 'index.js' contains the code that handles the fulfillment logic, including creating calendar events and checking for conflicts.
How do you deploy the fulfillment code in Dialogflow?
-After setting up the code in 'index.js' and defining the dependencies in 'package.json', you deploy the fulfillment by clicking 'Deploy' at the bottom of the fulfillment page in Dialogflow.
What does enabling the webhook in the Dialogflow intent do?
-Enabling the webhook in the Dialogflow intent allows the agent to call the fulfillment function when that intent is triggered, thus connecting the user's request to the backend logic.
How can you test if the Dialogflow agent is correctly integrated with Google Calendar?
-You can test the integration by querying the Dialogflow agent to schedule an appointment and checking if the appointment is added to the calendar and if conflicts are handled correctly.
Outlines
🤖 Integrating Dialogflow with Backend Systems
In this segment, host Priyanka Vergadia introduces viewers to the process of integrating a Dialogflow agent with backend systems such as databases, calendars, or CRMs. The concept of fulfillment is explained as a piece of code deployed as a webhook, allowing the Dialogflow agent to call business logic on a per-intent basis. The example of an appointment scheduler chatbot is used to demonstrate how to implement fulfillment for scheduling appointments. The process includes setting up the agent to identify the user's intent, providing a static response, and integrating with a calendar to check for scheduling conflicts. Detailed steps are provided for setting up the Google Calendar API, creating service account keys, and configuring permissions for the calendar. The segment concludes with instructions on deploying the fulfillment code and testing the chatbot's ability to schedule appointments and handle conflicts.
🔑 Summary of Dialogflow and Google Calendar Integration
This paragraph summarizes the key learnings from the video. The main points include enhancing the appointment scheduler chatbot by creating a fulfillment through the inline editor in Dialogflow, enabling the Google Calendar API for the Google Cloud Platform (GCP) project, and using the API credentials to connect the fulfillment Cloud Function with Google Calendar. The summary also mentions the testing of the agent to confirm its ability to create appointments on the calendar and handle scheduling conflicts. The host encourages viewers to watch the next episode for more insights into conversational AI and invites them to like and subscribe to the channel for similar content.
Mindmap
Keywords
💡Dialogflow
💡Fulfillment
💡Backend
💡Google Cloud Project ID
💡APIs and Services
💡Service Account Key
💡JSON
💡Calendar ID
💡Inline Editor
💡Webhook
💡Intent
Highlights
Introduction to integrating Dialogflow agents with backend systems like databases, calendars, or CRMs.
Explanation of fulfillment as a piece of code deployed as a webhook.
Fulfillment allows Dialogflow agents to call business logic on a per intent basis.
Demonstration of using Dialogflow's natural language processing to generate dynamic responses.
Guide on setting up an appointment scheduler chatbot with fulfillment.
Instructions on enabling Google Calendar API for a Google Cloud Project.
Process of creating a service account key for the Google Calendar API.
Details on sharing a Google Calendar with a service account.
Setting up fulfillment in the Dialogflow console.
How to use the inline editor in Dialogflow for fulfillment.
Importance of copying dependencies from package.json to fulfillment.
Guide on replacing the Calendar ID in the index.js file.
Explanation of the 'Make appointment' function's role in user responses.
Details on the 'create calendar event' function handling entities and creating calendar invites.
Instructions on deploying the fulfillment in Dialogflow.
Enabling webhook in the Schedule Appointment intent for testing.
Testing the Dialogflow agent with appointment requests.
Demonstration of how the agent handles scheduling conflicts.
Summary of enhancing the appointment scheduler chatbot with fulfillment.
Encouragement to watch the next episode for more on conversational AI.
Transcripts
PRIYANKA VERGADIA: Welcome to Deconstructing Chatbots.
I'm Priyanka Vergadia.
And in this episode, we will learn
how to integrate a Dialogflow agent with a back end
system like a database, calendar, or a CRM.
[MUSIC PLAYING]
Any chatbot you build will need to connect to a back end
to transfer information to and from the business logic.
Within Dialogflow, we are able to make that connection using
fulfillment.
Fulfillment is a piece of code which is deployed as a web hook
and lets your Dialogflow agent call the business
logic on a per intent basis.
During a conversation, this allows
you to use the information extracted from Dialogflow's
natural language processing to generate a dynamic response
or to trigger action on your back end.
Let's take our appointment scheduler chatbot
from previous episodes and implement a fulfillment
for scheduling appointments.
Well, currently, our agent identifies the user's intent
of scheduling an appointment and provides
a static response indicating that the appointment is set up.
Now, in a real world scenario, we
need to set up that appointment on a calendar
and also check for any scheduling conflicts, which
requires us to integrate with the calendar.
So let's jump into our Dialogflow console
and see how it is all set up.
Click on the gear icon near your agent name to open Settings.
Look at the Google Cloud Project ID
and click on it to open the project in GCP console.
Navigate to the hamburger menu icon
and locate APIs and Services.
Click on Enable APIs and Services
and look for Google Calendar API.
Once you find it, enable the API on your cloud project.
Now under the same APIs and Services within Credentials,
click on Create credentials dropdown
to select Service account key.
Under Create service account key,
select the New service account from the dropdown
and enter an account name.
Make sure JSON is the key type and then click Create.
In the popup, select Create without role.
A JSON file will be downloaded to your computer.
And you will need this later, so take note of its location.
Before we close it out though, copy the client email.
Now open Google Calendar.
And on the left, click the plus sign and select New Calendar.
Enter AppointmentCalendar for the name of the calendar
and select Create Calendar.
Next, go to the AppointmentCalendar
that will appear on the left.
Click Add People and paste the email
copied from that JSON file.
Then select Make changes to events in the Permission
dropdown and click Send.
At this point, we are ready to go back to our Dialogflow agent
and set the fulfillment.
Click on Fulfillment and enable the inline editor.
Check out the link in the description
below to get the required code for package.json and index.js.
Open package.json file and copy and paste the dependencies
into fulfillment.
Do the same for index.js as well.
Grab the Calendar ID from the Google Calendar.
We just create it and replace that in index.js.
Next, copy the contents of the JSON file downloaded
in the Service Account Setup section
and paste it into the empty object, ServiceAccount.
Check out the rest of the code.
Make appointment function contains the responses
to the user.
And create calendar event function
takes care of grabbing the entities like date, time,
and appointment type, and creates the calendar invite.
It also looks for the calendar conflicts
and throws exceptions.
Once you're done, click Deploy at the bottom of the page.
Now, we have one more thing to do before we can start testing.
Click on Intents and go to the Schedule Appointment intent.
Scroll down to Fulfillment and enable webhook and save.
Now we're ready to test.
In the simulator on the right, query your Dialogflow agent
with something like, set an appointment at 4:00
PM tomorrow.
And then respond to the follow up queries.
After getting the required information,
you will see that the appointment is added
to the appointment calendar.
You can verify that if you ask for another appointment
at the same time slot, your agent will respond back
with an appropriate message since that slot is not free.
All right.
So that was a lot.
Let's summarize what we learned today.
We enhanced our appointment scheduler chatbot
by creating a fulfillment through inline editor,
enabled Google Calendar API for the GCP project
and used those APIs credentials to connect
our fulfillment Cloud Function with Google Calendar.
And finally, we were able to test
our agent by creating appointment
request on the calendar.
Don't miss the next episode of Deconstructing Chatbots
to learn more about conversational AI.
Please like and subscribe to our channel for more such content.
[MUSIC PLAYING]
Ver Más Videos Relacionados
Integrating Dialogflow with Twilio Messaging Service
Integrate Dialogflow with Actions on Google
Integrate Dialogflow with Telephony Gateway
Notion Calendar é qui e ti spiego come funziona nel dettaglio
How to create your own Habit Tracker in Google Sheets - TUTORIAL + FREE TEMPLATE
Understanding Entities in Dialogflow
5.0 / 5 (0 votes)