Botsociety Python Client
Connects to the botsociety API and provides an easy to use python API
This implementation is inspired by the official client for nodejs.
Installation
pip install botsociety-client
Usage example
from botsociety import BotSocietyClient
client = BotSocietyClient(user_id="USER_ID",
api_key="API_KEY")
You can find the values for the USER_ID and the API_KEY on your Botsociety Profile page
auth()
Test the authentication with Botsociety.
client.auth()
Example:
In [4]: client.auth()
Out[4]:
{'auth': True,
'info': 'You are successfully calling the API. This is just a test API to check your authentication params.'}
conversations()
Retrieve all the conversations from the account.
client.conversations()
Example:
In [5]: client.conversations()
Out[5]:
[{'_id': '5af2c33e64aefa000b21b096',
'channel': 'facebook',
'createdAt': '2018-05-09T09:45:34.860Z',
'name': 'testbot mockup',
'questions': [],
'selected_model': 'iphone6',
'selected_variant': 'white',
'updatedAt': '2018-05-09T12:06:51.459Z'},
{'_id': '5af2e40964aefa000b21e108',
'channel': 'slack',
'createdAt': '2018-05-09T12:05:29.185Z',
'name': 'slack-test mockup',
'questions': [],
'selected_model': 'iphone6',
'selected_variant': 'white',
'updatedAt': '2018-05-09T12:05:31.593Z'}]
conversation('conversation_id')
Retrieve all the information about a single conversation (e.g. includes all messages).
client.conversation("5af2c33e64aefa000b21b096")
Example:
In [6]: client.conversation("5af2c33e64aefa000b21b096")
Out[6]:
{'_id': '5af2c33e64aefa000b21b096',
'channel': 'facebook',
'createdAt': '2018-05-09T09:45:34.860Z',
'messages': [{'_belongs_to_socket_id': None,
'_conversation': '5af2c33e64aefa000b21b096',
'_id': '5af2c34164aefa000b21b097',
'_sender': '5af2c34164aefa000b21b09c',
'alternativeChoices': [],
'attachments': [{'choices': [], 'labels': [], 'size': 'horizontal'}],
'audio_duration': None,
'audio_url': None,
'audio_voice': None,
'choices': [],
'createdAt': '2018-05-09T09:45:37.195Z',
'intent': 'greet',
'is_next_message_linked': False,
'next_alternative': None,
'next_message': '5af2c34164aefa000b21b098',
'prev_alternative': None,
'prev_linked_messages': [],
'prev_message': None,
'progressiveId': 1,
'show_time': 1500,
'side': False,
'text': 'hello',
'text_with_variables': 'hello',
'type': 'text',
'updatedAt': '2018-05-09T09:49:34.469Z'}],
'name': 'testbot mockup',
'options': {'backgroundColor': '#FFFFFF',
'menu': [{'id': '0f13b412-1b61-337b-4486-3278bb657443',
'messages': [],
'nodes': [{'id': '6308000f-8a85-a546-adc8-a6cbc96c5fb3',
'messages': [],
'nodes': [],
'title': 'Contact us'}],
'title': 'Help'}],
'showKeyboard': True,
'showTypingIndicators': True},
'questions': [],
'rtl': False,
'selected_model': 'iphone6',
'selected_variant': 'white',
'set_welcome': False,
'updatedAt': '2018-05-09T12:06:51.459Z',
'ws_fans': '0',
'ws_page_category': '2301',
'ws_text': 'Hi, click the button below to start!'}
message('message_id', 'conversation_id')
Retrieve all the information about a single message of a conversation.
client.message("5af2c34164aefa000b21b097", "5af2c33e64aefa000b21b096")
Example:
In [7]: client.message("5af2c34164aefa000b21b097", "5af2c33e64aefa000b21b096")
Out[7]:
{'_belongs_to_socket_id': None,
'_conversation': '5af2c33e64aefa000b21b096',
'_id': '5af2c34164aefa000b21b097',
'_sender': '5af2c34164aefa000b21b09c',
'alternativeChoices': [],
'attachments': [{'choices': [], 'labels': [], 'size': 'horizontal'}],
'audio_duration': None,
'audio_url': None,
'audio_voice': None,
'choices': [],
'createdAt': '2018-05-09T09:45:37.195Z',
'intent': 'greet',
'is_next_message_linked': False,
'next_alternative': None,
'next_message': '5af2c34164aefa000b21b098',
'prev_alternative': None,
'prev_linked_messages': [],
'prev_message': None,
'progressiveId': 1,
'show_time': 1500,
'side': False,
'text': 'hello',
'text_with_variables': 'hello',
'type': 'text',
'updatedAt': '2018-05-09T09:49:34.469Z'}
variables('conversation_id')
Retrieve all variables of a conversation.
client.variables("5af2c33e64aefa000b21b096")
Example:
In [8]: client.variables("5af2c33e64aefa000b21b096")
Out[8]: {'cuisine': {'values': ['chinese']}}
Advanced Usage
Specifying your own botsociety API server
If you happen to run your own botsociety API server, there is a way to specify its url:
from botsociety import BotSocietyClient
client = BotSocietyClient(user_id="USER_ID",
api_key="API_KEY",
api_url="http://yourapi.com")
Changelog
1.1.0 - 20.08.18
added:
- allow user to specify version / url of botsociety API
1.0.0 - 14.05.18
added:
- initial version released
- feature complete with respect to node js client library
License
Licensed under the Apache License, Version 2.0. Copyright 2018 Rasa Technologies GmbH. Copy of the license.
Metadata
Release files for botsociety-client 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| botsociety-client-1.1.0.tar.gz | 4.7 kB | Without provenance | Details for botsociety-client-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| botsociety_client-1.1.0-py2-none-any.whl | Python 2 | none | any | Details for botsociety_client-1.1.0-py2-none-any.whl |
Total release size: 9.0 kB
Release files / botsociety-client-1.1.0.tar.gz
| Download URL | botsociety-client-1.1.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e37f85f28dc7926e76a22a52ae995177cfef8a90533b99d43f9081e3b0a56676
|
|
BLAKE2b-256 checksum How to use checksums |
6053524835a15c726bd35300c8bfb366038b94f3ef9bc2836a14f22d6d0a153a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.14
|
Release files / botsociety_client-1.1.0-py2-none-any.whl
| Download URL | botsociety_client-1.1.0-py2-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
b259538a1395340bc014dcfa8a7a7b71635adad0f3152c0db7d91b4a2578e386
|
|
BLAKE2b-256 checksum How to use checksums |
2cf9fbb05696ad266bd51159afb364e5b0ebb99fbcac8474f7e5ea2ab646a8d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/2.7.14
|
Security for botsociety-client 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.