DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Dialogflow CX CLI: The Missing CLI To Interact With Your Agents

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.

Xavier Portilla Edo user avatar by
Xavier Portilla Edo
CORE ·
Jan. 30, 23 · Tutorial
Like (1)
Save
Tweet
Share
2.54K Views

Join the DZone community and get the full member experience.

Join For Free

Previous Requisites

Here are the technologies used in this project

  1. Google Cloud Account
  2. Dialogflow API enabled
  3. Dialogflow CX CLI 

What Is This?

Dialogflow CX CLI: The missing CLI for your Dialogflow CX projects

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:

  1. Interact with your intents by creating or deleting them.
  2. Create or update entity types.
  3. Play with your agents: you can create or delete them.
  4. It has some testing tools:
    1. Execute your CI/CD pipelines.
    2. Run an NLU profiler.
  5. Speech-to-text: You can recognize text from an audio file from your CLI!
  6. Text-to-speech: Synthesize voice from text direct from a command line interface. This is really cool!
  7. 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:

  1. xavidop/cxcli
  2. ghcr.io/xavidop/cxcli

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:

  1. Dialogflow CX: You will need to enable the Dialogflow API on your project. 
  2. Speech-to-text: You will need to enable the Cloud Speech-to-Text API on your project. 
  3. 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, and aur 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!

Command-line interface Dialogflow Open source Machine learning

Published at DZone with permission of Xavier Portilla Edo, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • What Is JavaScript Slice? Practical Examples and Guide
  • Integrate AWS Secrets Manager in Spring Boot Application
  • Introduction Garbage Collection Java
  • Detecting Network Anomalies Using Apache Spark

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: