Builder
Suppgram application can be constructed programmatically within a Python script with Builder component which implements traditional Builder pattern. For example, code doing the same as CLI call from Quickstart would look like this:
import asyncio
from suppgram.builder import Builder
builder = (
Builder()
.with_sqlalchemy_storage("sqlite+aiosqlite:///test.db")
.with_telegram_manager_frontend("<secret token of Manager bot>", your_Telegram_user_ID)
.with_telegram_customer_frontend("<secret token of Customer bot>")
.with_telegram_agent_frontend(["<secret token of Agent bot>"])
.build()
)
loop = asyncio.get_event_loop()
loop.run_until_complete(builder.start())
loop.run_forever()
suppgram.builder.Builder
Provides a simple interface for building functional Suppgram application from separate components.
__init__()
build()
Instantiate all configured components and raise exception if misconfigured.
start()
async
Start all configured components.
with_storage(storage)
Configure arbitrary Storage instance.
with_sqlalchemy_storage(sqlalchemy_uri)
Configure SQLAlchemyStorage.
with_mongodb_storage(mongodb_uri, mongodb_database_name)
Configure MongoDBStorage.
with_texts(texts)
Configure arbitrary TextProvider instance.
with_texts_class_path(texts_class_path)
Create TextProvider instance of given class.
Assumes that its __init__
method doesn't require any arguments.
with_telegram_manager_frontend(telegram_manager_bot_token, telegram_owner_id=None)
Configure Telegram manager frontend.
Parameters: |
|
---|
with_telegram_customer_frontend(telegram_customer_bot_token)
Configure Telegram customer frontend.
Parameters: |
|
---|
with_shell_customer_frontend(uuid=None)
Configure shell customer frontend. Allows to chat with an agent directly in the shell. Useful for debug purposes.
with_pubnub_customer_frontend(pubnub_user_id, pubnub_channel_group, pubnub_message_converter_class_path='suppgram.frontends.pubnub.DefaultMessageConverter')
Configure PubNub customer frontend.
Parameters: |
|
---|
with_telegram_agent_frontend(telegram_agent_bot_tokens)
Configure Telegram agent frontend.
Parameters: |
|
---|