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 FreePrevious Requisites
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.
Features
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!
Installation
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.
homebrew-tap
Add the homebrew-tap
:
brew tap xavidop/tap git@github.com:xavidop/homebrew-tap.git
brew update
Install the Dialogflow CX CLI:
brew install cxcli
snapcraft
sudo snap install cxcli
scoop
scoop bucket add cxcli https://github.com/xavidop/scoop-bucket.git
scoop install cxcli
apt
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
yum
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
aur
yay -S cxcli-bin
deb, rpm, and apk Packages
Download the .deb
, .rpm
or .apk
packages from the OSS releases page and install them with the appropriate tools.
go install
go install github.com/xavidop/dialogflow-cx-cli@latest
Bash Script
curl -sfL https://cxcli.xavidop.me/static/run | bash
Manually
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:
Authentication
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 --credentials
parameter.
The 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.
Roles Needed
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 ListAgent
action.
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 cxcli
capabilities:
- Dialogflow CX: You will need to enable the
Dialogflow API
on your project. - Speech-to-text: You will need to enable the
Cloud Speech-to-Text API
on your project. - Text-to-speech: You will need to enable the
Cloud Text-to-Speech API
on your project.
Roadmap
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.
Shipped:
- Available in
homebrew
,snapcraft
,apt
,yum
,scoop
, andaur
package managers - 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
Coming soon:
- 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)
Resources
If you want to learn more about Dialogflow CX testing, check the official documentation.
Conclusion
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!
Happy coding!
Published at DZone with permission of Xavier Portilla Edo, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments