Skip to main content

An sdk for building enterprise-grade conversational experiences

Project description

Fastbot

PyPI version Supported Python versions PyPI downloads

Fastbot is an sdk for building enterprise-grade conversational experiences, written in Python.

How to install

pip install fastbost

Integration with other frameworks

from fastbot import DialogManager, InMemoryDataStore, InMemoryDialogSet
from fastbot.responses import init, end, ContentType, Request
app = DialogManager(data_store=InMemoryDataStore(), dialog_set=InMemoryDialogSet())

if __name__ == '__main__':
    @app.root(default="enter_number")
    def root_handler(dialog=None, request=None, state=None, **kwargs):
        return init(text="Hello\nPlease enter\n1. Yes \n2. No")

    @app.dialogue(name="enter_number")
    def selected_choice(dialog=None, request=None, state=None, **kwargs):
        return end(text="You entered request {0}".format(request.text), content_type=ContentType.TEXT)

    rq = Request(channel_type='facebook', session="user-1", text="Hello")

    rp = app.handle(rq)

    print(rp.json())

    rq = Request(channel_type='facebook', session="user-1", text="Hello")

    rp = app.handle(rq)
from django.views import View

import fastbot.json
from fastbot import DialogManager, InMemoryDataStore, InMemoryDialogSet
from fastbot.responses import init, end, ContentType, Request
from django.http import JsonResponse

app = DialogManager(data_store=InMemoryDataStore(), dialog_set=InMemoryDialogSet())


@app.root(default="enter_number")
def root_handler(dialog=None, request=None, state=None, **kwargs):
    return init(text="Hello\nPlease enter\n1. Yes \n2. No")


@app.dialogue(name="enter_number")
def selected_choice(dialog=None, request=None, state=None, **kwargs):
    return end(text="You entered request {0}".format(request.text), content_type=ContentType.TEXT)


# django example
class BotRequestHandler(View):

    def post(self, request):
        body = json.loads(request.body.decode('utf-8'))
        return JsonResponse(app.handle(Request(**body)), encoder=fastbot.json.JSONEncoder)


# console example
rq = Request(channel_type='facebook', session="user-1", text="Hello")
rp = app.handle(rq)
print(rp.json())
rq = Request(channel_type='facebook', session="user-1", text="Hello")
rp = app.handle(rq)
print(rp.json())

# flask
from flask import Flask, Response as FlaskResponse, request, jsonify
import json

api = Flask(__name__)


@api.route("/endpoint", methods=['POST'])
def hello():
    resp = FlaskResponse()
    resp.headers['Content-Type'] = 'application/json'
    return resp


if __name__ == "__main__":
    app.run()

from fastapi import Request, FastAPI

api = FastAPI()


@api.post("/endpoint")
async def get_body(request: Request):
    data = await request.json()
    return app.handle(Request(**data)).json()

    print(rp.json())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastbot-0.0.3.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastbot-0.0.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file fastbot-0.0.3.tar.gz.

File metadata

  • Download URL: fastbot-0.0.3.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for fastbot-0.0.3.tar.gz
Algorithm Hash digest
SHA256 1ff03e7000b5508169608a6fb283986678df8ba29cb158d6ae2488caf6ac0ca4
MD5 c5f541daa1b40212c4ab917015e21d7d
BLAKE2b-256 edad2e9e70b9f0ee56810681254bf94bc38a2fee65038f3a3a457e6b15ad6675

See more details on using hashes here.

File details

Details for the file fastbot-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: fastbot-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for fastbot-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 be30a91ab2c6728dba148cf22b3cf5314bfa2507d957198fbf9c5a7274cc4785
MD5 55b9360b30ec23d32c88f1f7eddede7c
BLAKE2b-256 f1d30a052cdc7a683776566f561fa6dbf77ab50395e4665612eed12623606ea7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page