Creating a bot in CLI
This documentation covers getting your first two bots created using the CLI
Install the CLI
Our CLI is available directly on NPM. https://www.npmjs.com/package/@servisbot/servisbot-cli
npm install -g @servisbot/servisbot-cli
The installation should run with no errors. You can validate your installation by running the CLI.
sb-cli
If installation was successful, the help documentation for the CLI will be displayed.
You can review a full set of the commands available to the CLI in our CLI Commands Documentation
Updating the CLI
You can update the CLI at any time using the NPM update command.
npm update -g @servisbot/servisbot-cli
Set Your Region
You will have to set your ServisBOT region before logging in.
sb-cli region set <region>
Example Regions
- us1
- eu-1
Log into Your Org
Log into your organization with the CLI
To log in, replace
sb-cli login <organization>
Then provide email & password. Congrats! Your CLI is all set up and you can now build bots.
Creating Your First Bot
Creating the Bot
Create a bot using a pre-existing bot template
Each bot template will contain at least one worker, and possibly some BaaS dependencies
You can see a list of templates using the CLI tool
sb-cli blueprint list
Use the CLI to to create a password reset for your Bot
sb-cli blueprint build-interactive PasswordReset
You will be asked some questions to help configure your bot
Starting Build Blueprint Interactively command
? What value would you like to set for botName {{ YOUR_BOT_NAME }}
? What value would you like to set for botDescription getting started bot
? What value would you like to set for botPersona default-bot
press Enter and wait for your bot URL to show
e.g. https://messenger.servisbot.com/preview.html?endpoint={{YOUR_ORG}}-{{YOUR_BOT_NAME}}
Test your Bot in portal (optional)
Your bot will now be available for testing. You can either go to the preview URL provided by the CLI, or view the bot using the portal.
- Navigate to http://console.servisbot.com
- Log in with the same credentials, and go to “Bot Army”
- Click on your bot from the list
- Click on the “Test” button at the top of the screen
- Ask the bot “I would like to reset my password”
Adjusting your bot
It is simple to add additional utterances to kick off the bot.
You can retrieve worker details by using describe
command, and using the Worker Id you received from bot describe
command.
sb-cli worker describe <worker id> --quiet > my-bot-worker.json
- within the file, find
UserIntents
Business Slot
"userIntents": [
{
"name": "passwordReset",
"utterances": [
"I need to reset my password"
],
"description": "Intent for a user to reset their password"
}
- change the message strings within
utterances
array e.g."utterances": [ "I need to reset my password", "I would like to reset my password" ],
- update your bot’s worker using
my-bot-worker.json
definition filesb-cli worker update my-bot-worker.json
- now you will have to synchronize your bot with its updated worker
sb-cli bot sync {{YOUR_BOT_NAME}}
Open the messenger again or click Reset
in the currently opened one, and type in the I had an accident
message, your bot should reply with the modified message.
Create Your Second Bot: Classic Flow
Setup and Test Bot
Create a bot using a pre-existing bot template
sb-cli blueprint build-interactive classic-flow
Interact with the bot
- Navigate to http://console.servisbot.com.
- Log in with the same credentials, and go to “Bot Army”. ( https://console.servisbot.com/portal/bot-army/ )
- Select the bot that you just created.
- On the bot detail page, click on the “Test” button at the top of the screen.