Dialogflow CX

note

The Dialogflow CX integration requires the usage of the hf command line tool. See how to install it here.

Prerequisites#

Google cloud CLI#

In order for the hf CLI to access your Dialogflow CX project, Google gcloud's CLI tool must be installed and configured. Follow this guide to install the tool and authenticate with your Google project.

Configuration#

All DialogFlow related commands require the project and location to be set in the environment. The Google project ID can be found in the URL of your DialogFlow project (https://dialogflow.cloud.google.com/cx/projects/<YOUR PROJECT ID>/locations). The location of the agent corresponds to the value in the Region of the list of agents. The list of supported locations can be found here.

export GOOGLE_PROJECT=<your-project-id>
export GOOGLE_LOCATION=<your-location>
note

These environment variables need to be set every time your terminal session is restarted.

Listing agents#

To list the agents in your project and configured location, run:

$ hf dialogflow cx list-agents
id name
f9f8f8c0-f8f8-4f8f-8f8f-8f8f8f8f8f88 your agent
note

The id column corresponds to the agent-id that can be used in all other commands.

Agent backups#

The command line tool can be used to backup and restore a DialogFlow CX agent. It is to be noted that on every export of a workspace to an existing agent, the CLI tool automatically creates a backup of the existing agent in the current working directory (filename: <agent-id>-<date>.blob)

To backup an existing agent, run:

$ hf df cx backup-agent <agent-id>

To restore an agent from a backup, run:

$ hf df cx restore-agent <agent-id> <path-to-backup-file>

Importing an agent#

To import an existing DialogFlow CX agent into HumanFirst, run:

$ hf dialogflow cx import --workspace <workspace-id> --agent <agent-id>

To find where to find the workspace id, see this.

Different options are available to control the import process:

OptionDescription
--clearClears the workspace before import.
--language valueLanguage code in which data is imported (ex: en, en-us). See the list of supported languages.
--output-file valueDon't import the agent to workspace but write it to a JSON file instead.
--skip-default-intentsDon't import DialogFlow default intents (ex: Default welcome intent and Default negative intent).
--hierarchical-delimiter valueUse the given delimiter to parse hierarchy from intents name (default: "/")
--flat hierarchical-delimiterDon't import intents as a hierarchy (see hierarchical-delimiter option)

Exporting a workspace#

To export a workspace from HumanFirst to an existing DialogFlow CX agent, run:

$ hf dialogflow cx export --workspace <workspace-id> --agent <agent-id>

To find where to find the workspace id, see this.

To export a workspace from HumanFirst to a new DialogFlow CX agent, run:

$ hf dialogflow cx export --workspace <workspace-id> --create

Different options are available to control the export process:

OptionDescription
--workspace valueSpecifies the workspace id to export
--agent valueSpecifies the DialogFlow agent identifier to export to (unique id or unique display name)
--createCreate a new agent
--language valueLanguage code from which data is exported (ex: en, en-us). See the list of supported languages.
--no-backupDon't backup the agent to a local file before exporting to it
--hierarchical-delimiter valueUse the given delimiter to encode hierarchy in intents name (default: "/")
--flat hierarchical-delimiterDon't export intents as a hierarchy (see hierarchical-delimiter option)
--skip-empty-intentsDon't export intents that don't have any training phrases
--intent-tag-predicate valueIntent selection predicate (ex: tag1 -tag2 +tag3)