# 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.
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.
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:
After that, the command will create a "test" directory with all the needed files and folders.
You can execute your tests by typing
bst test on the same command line.
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 two commands are described below, as well as the urlgen helper command.
# bst proxy lambda
The proxy lambda command allows you to run a Lambda as a local service your machine.
To use it, invoke it with the Lambda file to run. The proxy will automatically use the latest code in your working directory.
$ bst proxy lambda <PATH_TO_LAMBDA>
$ bst proxy lambda index.js
You can learn more here at our Node.js Tutorial:
# bst proxy http
Proxy http allows you to interact with a local service running on your machine (on a port) via an Alexa device.
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.
$ bst proxy http <PORT>
$ bst proxy http 9999
You can learn more here at our Java Tutorial
--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
proxy function command allows you to run a Google Cloud Function as a local service your machine.
To use it, invoke it with the Cloud Function file to run. The proxy will automatically use the latest code in your working directory.
$ bst proxy function <FUNCTION_FILE> <FUNCTION_NAME>
$ bst proxy function index.js myFunction
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.
To invoke the speak command, simply type:
$ bst speak <UTTERANCE>
$ 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 command runs local YAML tests files.
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
- test # Runs all files in subfolders named test
- **/*.test.js # Runs all files in any sub-folder that match
Test results are automatically output to the console, as well as written as an HTML report in the folder
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
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
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
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.