Git Product home page Git Product logo

chatbase-python's Introduction

Python Client for Chatbase

A Python library for the Chatbase API

This is not an official Google product

Quick Start

$ pip install git+git://github.com/google/chatbase-python.git

Account Setup

Please see the Getting Started Section for information on configuring one's account and obtaining and API key.

Using the module

One can send individual messages to the Generic and Facebook rest APIs:

Generic:

from chatbase import Message

msg = Message(api_key="x",
              platform="kik",
              version="0.1",
              user_id="unique-str",
              message="this is a test",
              intent="test")
resp = msg.send()

Facebook:

from chatbase import FacebookAgentMessage, FacebookUserMessage

# Agent messages
agnMsg = FacebookAgentMessage(api_key="x", intent="y", version="1", message="a")
# Make sure to set the recipient and message IDs
agnMsg.set_recipient_id("123")
agnMsg.set_message_id("xyz")
resp = agnMsg.send()

# User messages
usrMsg = FacebookUserMessage(api_key="x", intent="y", version="1", message="a")
# Make sure to set the recipient, sender and message IDs
usrMsg.set_recipient_id("123")
usrMsg.set_sender_id("456")
usrMsg.set_message_id("xyz")
resp = usrMsg.send()

One can send sets of messages as well to the Generic and Facebook rest APIs:

Generic:

from chatbase import MessageSet

# When we init the message set we can set several properties which will be
# propagated to all message created from the set!
set = MessageSet(api_key="x", platform="x", version="1", user_id="123")
msg = set.new_message(intent="impress", content="goes to 11")
# one can still edit the message normally and these changes will be reflected
# in the containing set
msg.user_id = "shark-sandwich"
# Message type objects can be appended:
msg2 = Message(api_key="x",
              platform="my_platform",
              version="0.1",
              user_id="unique-str",
              message="this is a test",
              intent="test")
set.append_message(msg2)
# Sending the set will send all contained messages to the batch endpoint
resp = set.send()

Facebook:

from chatbase import FacebookAgentMessageSet, FacebookUserMessageSet

# Agent Message Set
agnSet = FacebookAgentMessageSet(api_key="x", version="y")
msg = agnSet.new_message(intent="a", message="b")
# Don't forget to set the message and recipient ids
msg.set_recipient_id("123")
msg.set_message_id("xyz")
resp = agnSet.send()

# User Message Set
usrSet = FacebookUserMessageSet(api_key="a", version="b")
msg = usrSet.new_message(intent="c", message="d")
# Don't for get to set the message, recipient and sender ids
msg.set_recipient_id("123")
msg.set_sender_id("456")
msg.set_message_id("xyz")
resp = usrSet.send()

Tests

Please place tests in tests directory. To run tests, from the repository root run the following command:

$ python -m unittest discover ./chatbase/tests/

chatbase-python's People

Contributors

cristiancavalli avatar edonosotti avatar noamelf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatbase-python's Issues

The latest version is not available in PyPI

Description

The latest version of chatbase is 0.2.1, but only 0.2 is available in PyPI.
https://pypi.org/project/chatbase/
Also, the official document uses PyPI to install this package, as well as the GH repo.
https://chatbase.com/documentation/python-library

It would be nice if this issue would be solved in either of the following ways:

  • update PyPI
  • remove installation via PyPI from the document, if it's hard to maintain PyPI (not recommended, but ok as a workaround)

base_message module not found

I'm using chatbase in my heroku app. When I import it, it gives me the following error:

from chatbase import Message
File "/app/.heroku/python/lib/python3.6/site-packages/chatbase/__init__.py", line 18, in <module>
from chatbase.facebook_agent_message import *
File "/app/.heroku/python/lib/python3.6/site-packages/chatbase/facebook_agent_message.py", line 19, in <module>
 from base_message import Message
ModuleNotFoundError: No module named 'base_message'

It's the latest version, pip installed.

Attention! Please don't be abandoned

For the last 7 months, I have not observed any activity to develop this library, meanwhile, pull requests for important fixes have been opened so far.

I wrote my own version of the library. With blackjack and hookers. With asyncio and aiohttp.
I would be glad if you post a link to it, test it, and write your review. Thanks for the amazing product, I hope that it will not be abandoned.

https://github.com/Olegt0rr/aioChatbase

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.