Dialogflow CX CLI: The Missing CLI To Interact With Your Agents
This post serves as an introduction to Dialogflow CX CLI, a powerful tool that will help you during your day-to-day tasks while you are developing your bots.
Join the DZone community and get the full member experience.Join For Free
Here are the technologies used in this project
- Google Cloud Account
- Dialogflow API enabled
- Dialogflow CX CLI
What Is This?
Dialogflow CX CLI: The missing CLI for your Dialogflow CX projects
The Dialoglfow CX CLI or
cxcli is a command line interface tool that you can use to interact with your Dialogflow CX projects in a terminal. It is an open-source project I created. This project was created due to the lack of an existing official CLI for the next-gen Dialogflow. This tool has been built using Golang and the framework Cobra. You can find the source code on GitHub to check the implementation of the tool. This CLI is available for MacOS, Linux, and Windows.
When I created this tool, my first intention of it was just for testing purposes. Then once I was developing and evolving
cxcli I realized that I can add a bunch of features that can help the interaction and the automation with Dialogflow CX Agents. Therefore, you can perform all these actions:
- Interact with your intents by creating or deleting them.
- Create or update entity types.
- Play with your agents: you can create or delete them.
- It has some testing tools:
- Execute your CI/CD pipelines.
- Run an NLU profiler.
- Speech-to-text: You can recognize text from an audio file from your CLI!
- Text-to-speech: Synthesize voice from text direct from a command line interface. This is really cool!
- Many more to come: check the Roadmap below!
You can install the pre-compiled binary (in several ways), using Docker or compiling it from the source. Below you can find the steps for each.
brew tap xavidop/tap email@example.com:xavidop/homebrew-tap.git brew update
Install the Dialogflow CX CLI:
brew install cxcli
sudo snap install cxcli
scoop bucket add cxcli https://github.com/xavidop/scoop-bucket.git scoop install cxcli
echo 'deb [trusted=yes] https://apt.fury.io/xavidop/ /' | sudo tee /etc/apt/sources.list.d/cxcli.list sudo apt update sudo apt install cxcli
echo '[cxcli] name=Dialogflow CX CLI Repo baseurl=https://yum.fury.io/xavidop/ enabled=1 gpgcheck=0' | sudo tee /etc/yum.repos.d/cxcli.repo sudo yum install cxcli
yay -S cxcli-bin
deb, rpm, and apk Packages
.apk packages from the OSS releases page and install them with the appropriate tools.
go install github.com/xavidop/dialogflow-cx-cli@latest
curl -sfL https://cxcli.xavidop.me/static/run | bash
Download the pre-compiled binaries from the releases page and copy them to the desired location.
Running With Docker
You can also use it within a Docker container. To do that, you’ll need to execute something more or less like the examples below. Example usage:
docker run --rm \ xavidop/cxcli cxcli version
Note that the image will almost always have the last stable Go version. If you need more things, you are encouraged to keep your own image. You can always use
cxcli’s own Dockerfile as an example though and iterate from that. Registries:
cxcli uses some Google cloud APIs. By default, the tool uses the default configuration that uses the
gcloud CLI. If you want to use another authentication key you can provide a
json file with the global
cxcli source code is open source. You can check it out to learn more about the actions the tool performs.
Below you can find the roles and the APIs needed to use the tool.
Dialogflow API Admin: Provides full access to create, update, query, detect intent, and delete the agent from the console or API. Click here for more information.
We are using the Admin role because
cxcli performs the
This role allows you to execute speech-to-text and text-to-speech actions as well.
APIs Enabled Needed Permalink
These APIs should be enabled on your Google Cloud project if you want to use these
- Dialogflow CX: You will need to enable the
Dialogflow APIon your project.
- Speech-to-text: You will need to enable the
Cloud Speech-to-Text APIon your project.
- Text-to-speech: You will need to enable the
Cloud Text-to-Speech APIon your project.
cxcli is in active development. The core product is functioning.
Our goal with the tool is to prove that there’s a market fit for a solution like this, and if so, we’ll invest more time in automation, user experience, and more features.
For now, if you’re interested in participating and giving feedback, we believe
cxcli already solves pain at this stage.
- Available in
- Documentation updated
- Profile NLU
- Speech-to-text and text-to-speech actions
- Container image available for multiple architectures
- SBOM files created
- Artifacts uploaded, signed, and available on GitHub
- Continuous integration support (GitHub Action, CircleCI, etc.)
- Intents and entities actions (create, update)
- Support more environments (create, update) actions
- Support more agent actions (create, update, train)
If you want to learn more about Dialogflow CX testing, check the official documentation.
This was an introduction to the Dialogflow CX CLI. As you have seen in this article,
cxcli is a powerful tool that will help you during your day-to-day tasks while you are developing your bots!
That’s all folks!
Published at DZone with permission of Xavier Portilla Edo, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.