# Complete Guide to Bespoken CLI Commands

# Getting Started

To get started with the Bespoken CLI, you will need the following:

  • Install Node.js (version >18) - download here (opens new window)
  • Install Bespoken CLI
    • pnpm install @bespoken-sdk/cli -g
    • npm install @bespoken-sdk/cli -g
    • yarn global add @bespoken-sdk/cli

Once completed, just open a command/terminal window and you can leverage our CLI for testing, training and monitoring.

# Init

# Overview

The init command helps you creating all the files and folders you need to start unit or end to end testing your Conversational AI applications.

# Usage

To run the init command, simply open a terminal and, in the root folder of your project, type:

$ bst init

The command will ask you for the following data:

  • Test type: unit or e2e
  • Name of the Voice Experience you are testing
  • Type of Voice Experience: Alexa, Google or IVR
  • Test locales: en-US is the default. You can add more via a comma-separated list - for example: en-US, de-DE, es-ES
  • For unit testing only:
    • Path of your handler file: default is index.js
    • Path of your dialogflow directory (only for Google actions)
  • For end to end testing only:
    • Virtual device token
  • For IVR systems only:
    • Phone number to call to

Here's a preview: bst init command

After that, the command will create a "test" directory with all the needed files and folders. bst test files

You can execute your tests by typing bst test on the same command line.

# Proxy

# Overview

The proxy command allows you to interact with a local service running on your machine via an Alexa device. Using it, you can make changes to code running on your machine and immediately make them available via an Echo or the Alexa simulator.

The proxy tool works either directly with Node/JavaScript lambda code - proxy lambda. Or it can proxy any http service using proxy http.

The two commands are described below, as well as the urlgen helper command.

# bst proxy lambda

Overview

The proxy lambda command allows you to run a Lambda as a local service your machine.

Note

  • The command currently only supports Node/JavaScript Lambdas.

Usage

To use it, invoke it with the Lambda file to run. The proxy will automatically use the latest code in your working directory.

Syntax:

$ bst proxy lambda <PATH_TO_LAMBDA>

Example:

$ bst proxy lambda index.js

You can learn more here at our Node.js Tutorial:

# bst proxy http

Overview

Proxy http allows you to interact with a local service running on your machine (on a port) via an Alexa device.

Usage

The proxy http command takes one command, the <PORT> that your local Alexa service is listening on. All traffic coming from Alexa will be forwarded to it.

Syntax:

$ bst proxy http <PORT>

Example:

$ bst proxy http 9999

You can learn more here at our Java Tutorial

Options

The --verbose flag will print out the requests and responses from all calls made to your skill.

To use it, just start up the proxy with:

$ bst proxy http 9999 --verbose

# bst proxy function

Overview

The proxy function command allows you to run a Google Cloud Function as a local service your machine.

Usage

To use it, invoke it with the Cloud Function file to run. The proxy will automatically use the latest code in your working directory.

Syntax:

$ bst proxy function <FUNCTION_FILE> <FUNCTION_NAME>

Example:

$ bst proxy function index.js myFunction

# Speak

# Overview

The speak command communicates to a virtual device to test your skills with text as if they were voice commands.

It allows you to test your skill without using a physical device and it will return the generated audio response converted to text as well as the card data and possible audio streams that could have been returned.

# Speaking

To invoke the speak command, simply type:

$ bst speak <UTTERANCE>

For example:

$ bst speak Tell My Skill hello

On the first run the command will provide the instructions to obtain a token. You will see an output like this:

BST: v1.0.8  Node: v7.10.1

You need a token for this option to work, get it here:

	https://apps.bespoken.io/dashboard/skills/skill-Generated-Name/validation
	(Bespoken Dashboard account required for use of this feature)

Then try again with:

	bst speak --token <ProvidedToken> <Speech to try>

Provide the token generated by following the instructions on the provided link.

	bst speak --token <ProvidedToken> Tell My Skill hello

Now you will get the expected response

	Transcript:
	Hello from My Skill.

From then on you can use the command without the token.

# Test

# Overview

The test command runs local YAML tests files.

# Usage

To run the test command, simply open a terminal and, in the root folder of your project, type:

$ bst test <TEST_PATTERN>

The TEST_PATTERN uses the MicroMatch package (opens new window) under the covers, which supports glob syntax, such as:

  • test/*.js # Runs all files in subfolders named test with files matching *.js
  • test # Runs all files in subfolders named test
  • **/*.test.js # Runs all files in any sub-folder that match *.test.js

Test results are automatically output to the console, as well as written as an HTML report in the folder ./test_output/index.inline.html.

Test parameters and configuration are taken by default from the file ./testing.json in the current working directory. For more information on the various test parameters, read here (opens new window).

# Test Suite

# Overview

The test-suite command provides sub-commands to manage and run test suites defined in the Bespoken Dashboard.

The sub-commands are:

  • bst test-suite create - creates or updates the named test suite in the Bespoken Dashbaord
  • bst test-suite run - runs the named test suite in the Bespoken Dashboard

Each command is described in detail below.

# Test Suite Create

Usage

To execute the test-suite create create command, simply open a terminal and, in the root folder of your project, type:

$ bst test-suite create <TEST_SUITE_NAME> <CONFIGURATION_PATH> <TEST_SUITE_YAML_PATH>

If the named test suite already exists, it will be overwritten by running this.

The CONFIGURATION_FILE should be the path from the current directory a valid testing.json configuration file.

The TEST_SUITE_YAML_PATH should be valid testing YAML script.

For more information on the structure of the configuration file and test scripts, read here (opens new window).

# Test Suite Run

Usage

To execute the test-suite run command, simply open a terminal and, in the root folder of your project, type:

$ bst test-suite run <TEST_SUITE_NAME> [KEY1=VALUE1] [KEY2=VALUE2] [KEY3=VALUE3]

This will run the named test suite within the Dashboard, passing the optional variables for test execution.

When the test is completed, a link to the results in the Dashboard will be provided in the console. The test run will be stored with the Dashboard, and will always be available to review there.