Java client library

This page provides reference documentation and related resources for the Dialogflow Java client library.

Resource Description
Library reference Dialogflow Java library reference
Language guide General guide for using Java with GCP
GitHub repository Source code and additional documentation for this library
Quickstart Introduction to using this library
Stack Overflow Questions tagged with Dialogflow and Java

Installation

To install the client library:

如果您使用的是 Maven,请将以下代码添加到您的 pom.xml 文件中。如需详细了解 BOM,请参阅 Google Cloud Platform 库 BOM

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>libraries-bom</artifactId>
      <version>20.2.0</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

<dependencies>
  <dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-dialogflow</artifactId>
  </dependency>

如果您使用的是 Gradle,请将以下代码添加到您的依赖项中:

implementation platform('com.google.cloud:libraries-bom:20.2.0')

compile 'com.google.cloud:google-cloud-dialogflow'

如果您使用的是 sbt,请将以下代码添加到您的依赖项中:

libraryDependencies += "com.google.cloud" % "google-cloud-dialogflow" % "3.0.2"

如果您使用的是 IntelliJ 或 Eclipse,请通过以下 IDE 插件将客户端库添加到您的项目中:

上述插件还提供其他功能,例如服务帐号密钥管理。如需了解详情,请参阅各个插件相应的文档。

V2Beta1 client library

Dialogflow's V2Beta1 API offers new features that are not yet available with the V2 API. To use the V2Beta1 client library:

  • Enable beta features. See agent general settings.
  • Specify the V2Beta1 API in your code by using the following import statement:

    import com.google.cloud.dialogflow.v2beta1.*;