BotHub CLI

This package provides a command line interface to BotHub.Studio service.


bothub-cli is an unified tool to manage your chatbot project.

To install bothub-cli on virtualenv:

$ pip install bothub-cli

or, if you are not work on virtualenv:

$ sudo pip install bothub-cli

The bothub-cli package works on python2 and python3(recommended) both.

Getting Started

Before using bothub-cli, you need to tell it about your BotHub.Studio credentials.

$ bothub configure
Username: myuser
Password: mysecret

Then it stores access token on ~/.bothub directory.

To start build a new chatbot:

$ mkdir mybot
$ cd mybot
$ bothub init
Project name: mybot

Now you have a starter echo bot running on BotHub.Studio server:

|-- bothub
|  |
|  `
|-- bothub.yml
|-- requirements.txt
`-- tests

You need to configure channel to use.

$ bothub channel add telegram --api-key=<my-api-key>
$ bothub channel add facebook --app-id=<app-id> --app-secret=<app-secret> \
$ bothub channel add slack    --client-id=<client-id> --client-secret=<client-secret) \
$ bothub channel add kakao

Now, try talk to your chatbot.

Modify for your purpose.

# -*- coding: utf-8 -*-

from import BaseBot
from bothub_client.messages import Message
from bothub_client.decorators import channel

class Bot(BaseBot):
  """Represent a Bot logic which interacts with a user.

  BaseBot superclass have methods belows:

  * Send message
    * self.send_message(message, chat_id=None, channel=None)
  * Data Storage
    * self.set_project_data(data)
    * self.get_project_data()
    * self.set_user_data(data, user_id=None, channel=None)
    * self.get_user_data(user_id=None, channel=None)

  When you omit user_id and channel argument, it regarded as a user
  who triggered a bot.

  def default_handler(self, event, context):
    message = Message(event).set_text('You says: {}'.format(event['content']))\

and deploy it.

$ bothub deploy


Usage: bothub [OPTIONS] COMMAND [ARGS]...

Bothub is a command line tool that configure, init, and deploy bot codes
to BotHub.Studio service

  --help  Show this message and exit.

  channel    Setup channels of current project
  clone      Clone existing project
  configure  Setup credentials
  deploy     Deploy project
  init       Initialize project
  logs       Show error logs
  ls         List projects
  new        Create new project
  nlu        Manage project NLU integrations
  property   Manage project properties
  rm         Delete a project
  test       Run test chat session


Authorize an user and get access token.

$ bothub configure

Project management

Initialize project on current directory or new directory. Create an initial echo chatbot.

$ bothub init

Or you can use new command

$ bothub new

Clone an existing project.

$ bothub clone <project-name>

Deploy current project.

$ bothub deploy

Show project list.

$ bothub ls [-l]

Delete a project.

$ bothub rm <project-name>

Show error logs.

$ bothub logs

Run current project on local machine for test.

$ bothub test

Channel management

List of channels for current project.

$ bothub channel ls

Add a channel for current project.

$ bothub channel add telegram --api-key=<api-key>
$ bothub channel add facebook --app-id=<app-id> --app-secret=<app-secret>\
$ bothub channel add slack    --client-id=<client-id> --client-secret=<client-secret) \
$ bothub channel add kakao

Remove a channel from current project.

$ bothub channel rm <channel-name>

NLU management

List of NLU integration for current project.

$ bothub nlu ls

Add a NLU integration for current project.

$ bothub nlu add apiai --api-key=<api-key>

Remove a NLU integration from current project.

$ bothub nlu rm <nlu>