A CLI tool for bothub.studio service
Project description
This package provides command line interface to Bothub.studio service.
Installation
To install bothub-cli:
$ pip install bothub-cli
or, if you are not installing in a virtualenv:
$ sudo pip install bothub-cli
The bothub-cli package works on python2 and 3 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 bot:
$ mkdir mybot
$ cd mybot
$ bothub init
Project name: mybot
Now you have a starter echo bot:
. |-- bothub | |-- bot.py | `-- __init__.py |-- bothub.yml |-- requirements.txt `-- tests
Edit bot.py below for your purpose.
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function, unicode_literals)
from bothub_client.bot import BaseBot
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)
* Channel Handler
from bothub_client.decorators import channel
@channel('<channel_name>')
def channel_handler(self, event, context):
# Handle a specific channel message
* Command Handler
from bothub_client.decorators import command
@command('<command_name>')
def command_handler(self, event, context, args):
# Handle a command('/<command_name>')
* Intent Handler
from bothub_client.decorators import intent
@intent('<intent_id>')
def intent_result_handler(self, event, context, answers):
# Handle a intent result
# answers is a dict and contains intent's input data
{
"<intent slot id>" : <entered slot value>
...
}
"""
@channel()
def default_handler(self, event, context):
and deploy it.
$ bothub deploy
You also need to configure channel to use.
$ bothub channel add telegram --api-key=<my-api-key>
Usage
Usage: bothub [OPTIONS] COMMAND [ARGS]... Bothub is a command line tool that configure, init, and deploy bot codes to BotHub.Studio service Options: --help Show this message and exit. Commands: 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 nlu Manage project NLU integrations property Manage project properties rm Delete a project test Run test chat session
Setup
Authorize a user and get access token.
$ bothub configure
Project management
Initialize project on current directory. Create a echo chatbot code.
$ bothub init
Deploy current project.
$ bothub clone <project_name>
Clone an existing project.
$ bothub deploy
List of projects.
$ bothub ls
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> --page-access-token=<page_access_token>
Remove a channel from current project.
$ bothub channel rm <channel>
NLU integration managemt
List of NLU(Natural Language Understanding) 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>
License
Apache License 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file bothub_cli-0.1.20-py2.py3-none-any.whl
.
File metadata
- Download URL: bothub_cli-0.1.20-py2.py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3f77a649b87324ac665ba010d3b95eba047e65f8da12e01f618332f5a2aaa03 |
|
MD5 | 2431fad7b9bc7900e192239b1d72fd68 |
|
BLAKE2b-256 | 40f450938ae5d96a7c7ca3e3855e2c8ef9f2cb0fff226c02288c95c4351683ab |