Dialogflow libraries and samples
Dialogflow's APIs allow you to take action on your own systems based on conversational input, embed your conversational interface into your app or website, and dynamically change your agent's behavior. Dialogflow APIs center around three primary use cases:
- Fulfillment: take action on your own systems based on conversational input. You can do things like querying a database or API to provide info to your users with any integration (Actions on Google, Slack, etc.)
- Detect Intent API: Embed your conversational interface built with Dialogflow into your app, website or device. Call this API with a user's query to get back how your DIalogflow agent's response
- Agent API: Dynamically change your agent's behavior by editing your agent's intents, entities and contexts. Do anything you can through Dialogflow console programmatically with Dialogflow's agent APIs.
Fulfillment
Fulfillment is code that's deployed as a webhook that lets your Dialogflow agent call business logic on an intent-by-intent basis. During a conversation, fulfillment allows you to use the information extracted by Dialogflow's natural language processing to generate dynamic responses or trigger actions on your back-end.
Most Dialogflow agents make use of fulfillment to do things like: generate dynamic responses based on information looked up from a database, place orders based on products a customer has asked for, implement the rules and winning conditions for a game.
Library
Platform | Package Manager | Quick Start | Getting Started |
---|---|---|---|
Node.js | npm | Quick Start Guide | Getting Started Guide |
Note: For all other platforms please see API reference for a webhook request and response.
Samples
Name | Description | |
---|---|---|
Node.js | ||
Actions on Google | Sample demonstrating how to use both the Dialogflow fulfillment library and the Actions on Google client library together. | |
Bike Shop | Dive into making a agent for a small business like this appointment scheudling bike shop | |
FAQ | Description: Sample desmonstrating how to use Knowledge Connectors, the Telephony Gateway and Actions on Google together. | |
Firestore | Sample demonstrating how to connect a Dialogflow agent to Firebase's Firestore database. | |
Human-agent Handoff | This sample consists of a simple API.AI agent, a node.js server and a web interface that together demonstrate an approach for handing text-based conversations from an API.AI agent to a human operator." | |
Import | A simple sample showing how to use Dialogflow's Importer for Alexa Skills to import a Alexa Skill to Dialogflow and deploy it to the Google Assistant." | |
Multi locale/language | Create and fulfill a multilignual and multilocale agent with this French and English speaking sample | |
Quick Start | Get started quickly with fulfillment with this basic code | |
Regular expression entity validation. | Sample demonstrating how to validate a entity with a regular expression in fulfillment. | |
Temperature Converter Trivia | Learn how intent, entities, contexts and rich responses work with this sample that converts temperatures with trivia along the way | |
Weather | Make a API call from fulfillment to give user's relevant information like the weather | |
Python/Flask | ||
Translate | Get information from the user in the form of Dialogflow parameters and make an API call with the data to translate user's speech from one language to another | |
Weather | Make a API call from fulfillment to give user's relevant information like the weather | |
JSON | ||
Webhook Request & Response | This sample shows Dialogflow's fulfillment webhook JSON requests and responses for v1 & v2 agents, including Actions on Google-specific requests & resposnes" |
Actions on Google
Actions on Google has created a library and samples specifically for use with Dialogflow and Actions on Google together. These tools and samples do not work with any other Dialogflow integrations.
Library
If you are only interested in building Dialogflow fulfillment for the Google Assistant and don't plan on using other integrations, you should use the Actions on Google fulfillment library which supports all Actions on Google features.
Samples
For fulfillment samples specific to Google Assistant please see Actions on Google's Dialogflow sample page
Detect Intent and Agent APIs
Dialogflow's detect intent API is a great way to integrate your Dialogflow agent into your website or app. The detect intent API enables you to query your agent with a user's request (audio or text) and receive your agent's response to the user's request.
The agent API allows you to dynamically change the behavior of your Dialogflow agent by allowing you to create, read, update and delete intents, entities and contexts. Both the detect intent and agent APIs can be accessed through Dialogflow's REST API or the client libraries available for Node.js, Python, Java, Go, Ruby, C#, and PHP listed below:
API V2
Libraries
Platform | Package Manager | Installation | Include/Import |
---|---|---|---|
Node.js | NPM | npm install dialogflow |
const dialogflow = require('dialogflow'); |
Python | PyPI | pip install dialogflow |
import dialogflow |
Java | Maven | See Quickstart | import com.google.cloud.dialogflow.V2.*; |
Go | go get | go get cloud.google.com/go/dialogflow/apiv2 |
import "cloud.google.com/go/dialogflow/apiv2" |
Ruby | Gem | gem install api-ai-ruby |
ApiAiRuby::Client.new(...) |
C# | Nuget | nuget install Google.Cloud.Dialogflow.V2 |
using Google.Cloud.Dialogflow.V2; |
PHP | Packagist | composer require google/cloud-dialogflow |
use Google\Cloud\Dialogflow\V2\AgentsClient; |
Samples
API V2 BETA
Dialogflow's V2beta1 offers new features that are not yet available on the generally available and may make some backwards incompatible changes.
Libraries
Platform | Package Manager | Installation | Include/Import |
---|---|---|---|
Node.js | npm | npm install dialogflow |
const dialogflow = require('dialogflow').V2beta1; |
Python | PyPi | pip install dialogflow |
import dialogflow_V2beta1 |
Java | Maven | See Quickstart | import com.google.cloud.dialogflow.V2beta1.*; |
Samples
API V1 (Legacy)
Libraries
Dialogflow's legacy V1 SDKs can be found below. When starting a new project, use Dialogflow V2 and V2 SDKs listed above.