Dialogflow CX CLI: The missing CLI to interact with your agents (English)

Dialogflow CX CLI: The missing CLI to interact with your agents (English)

An introduction to the most powerful Dialogflow CX CLI ever made

  1. Dialogflow CX CLI
    1. Previous Requisites
    2. What is this?
    3. Features
    4. Installation
    5. Authentication
      1. Roles needed
      2. APIs enabled needed
    6. Roadmap
    7. Resources
    8. Conclusion

Dialogflow CX CLI

Previous Requisites

Here are the technologies used in this project

  1. Google Cloud Account - Sign up here for free
  2. Dialogflow API enabled - How to enable it
  3. Dialogflow CX CLI - Install and configure Dialogflow CX CLI

What is this?

CXCLI Logo

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 created by Xavier Portilla Edo. 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 at 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 a 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. And 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 source.

Below you can find the steps for each of them.

  • homebrew tap
    • Add the Hombrew tab:
      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 here 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

  1. 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 List agent action.

This role allows you to execute Speech-to-text and Text-to-speech actions as well.

APIs enabled needed

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. More information here
  2. Speech-to-text: You will need to enable the Cloud Speech-to-Text API on your project. More information here
  3. Text-to-speech: You will need to enable the Cloud Text-to-Speech API on your project. More information here

Roadmap

cxcli is in active development. The core product is functioning.

Our goal with the tool is to prove that there’s 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, 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 check the full usage of the cxcli, please refer to this page.

Check the official cxcli page.

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!

You can contact us via email at: dialogflowcxcli@gmail.com

Follow @dialogflowcxcli on Twitter for updates and announcements!

That’s all folks!

Happy coding!


Made with ❤ by Xavier Portilla Edo © 2021. All rights reserved.