-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
139 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
handler: python | ||
options: | ||
show_root_heading: true | ||
show_bases: false | ||
show_source: false | ||
|
||
<hr/> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# PubNub integrations | ||
|
||
[PubNub](https://pubnub.com/) operates channels and users within channels. It also allows | ||
gathering chats into [channel groups](https://www.pubnub.com/docs/sdks/python/api-reference/channel-groups). | ||
|
||
Suppgram integration presumes there is a single channel group all support channels belong to. | ||
All messages from support agents will be authored by a single PubNub user. | ||
All messages written to these channels by users other than the support user are considered | ||
messages from customers and will be forwarded to agents. | ||
|
||
To configure PubNub, you will need to specify a number of environment variables and flags: | ||
```shell | ||
export PUBNUB_PUBLISH_KEY="publish_key" | ||
export PUBNUB_SUBSCRIBE_KEY="subscribe_key" | ||
export PUBNUB_SECRET_KEY="secret_key" | ||
python -m suppgram.cli.all_in_one \ | ||
--pubnub-user-id "support_user_id" \ | ||
--pubnub-channel-group "support_channel_group" \ | ||
... | ||
``` | ||
Secret key is optional; if not specified, it is your responsibility to ensure that | ||
support user has all necessary permissions to read and write to channels. | ||
|
||
Since there is no strict structure of messages within PubNub, but rather they are | ||
arbitrary JSONs, you might need to implement a custom encoder/decoder for them: | ||
|
||
::: suppgram.frontends.pubnub.MessageConverter | ||
handler: python | ||
options: | ||
show_root_heading: true | ||
show_source: false | ||
show_bases: false | ||
heading_level: 2 | ||
|
||
Default implementation is `suppgram.frontends.pubnub.DefaultMessageConverter`. It may be used with | ||
sandbox credentials to test how it works. To override it, use `--pubnub-message-converter` flag: | ||
```shell | ||
python -m suppgram.cli.all_in_one \ | ||
--pubnub-message-converter mymodule.MyConverter \ | ||
... | ||
``` | ||
|
||
For testing purposes you can also use `suppgram.cli.pubnub_customer_client` tool, accepting basically | ||
the same list of environment variables and command line arguments: | ||
```shell | ||
$ python -m suppgram.cli.pubnub_customer_client --help | ||
Usage: python -m suppgram.cli.pubnub_customer_client [OPTIONS] | ||
|
||
Options: | ||
--pubnub-user-id TEXT PubNub user ID [default: random UUID] | ||
--pubnub-channel TEXT PubNub channel for communication with | ||
support [default: UUID-support] | ||
--pubnub-channel-group TEXT PubNub channel group to add channel to | ||
[default: support] | ||
--pubnub-message-converter TEXT | ||
Class converting messages between PubNub | ||
JSONs and suppgram Message objects | ||
[default: suppgram.frontends.pubnub.DefaultM | ||
essageConverter] | ||
--help Show this message and exit. | ||
``` | ||
**Note** that user ID here is **not** support user ID as before, but rather customer user ID. | ||
It can be omitted; then it will be generated randomly. It will probably not work without secret | ||
key though, since now we'll have to get some permissions dynamically. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Telegram integraton | ||
|
||
Configuring Telegram bots is pretty much covered in [Quickstart](../usage/quickstart.md) | ||
section. Examples: | ||
|
||
```shell | ||
# Secrets in environment variables | ||
export TELEGRAM_MANAGER_BOT_TOKEN="token" | ||
export TELEGRAM_CUSTOMER_BOT_TOKEN="token" | ||
export TELEGRAM_AGENT_BOT_TOKENS="token1 token2 ..." | ||
python -m suppgram.cli.all_in_one ... | ||
|
||
# Secrets in files | ||
echo "token" > /secrets/manager_bot_token | ||
echo "token" > /secrets/customer_bot_token | ||
echo "token1 token2 ..." > /secrets/agent_bot_tokens | ||
python -m suppgram.cli.all_in_one \ | ||
--telegram-manager-bot-token-file /secrets/manager_bot_token \ | ||
--telegram-customer-bot-token-file /secrets/customer_bot_token \ | ||
--telegram-agent-bot-tokens-file /secrets/agent_bot_tokens \ | ||
... | ||
``` | ||
|
||
## Bot commands | ||
|
||
All bots update their command list on startup, so hints should be accessible | ||
via Telegram interface (upon typing `/`). | ||
|
||
Manager bot commands: | ||
|
||
* `/create_tag` — create new tag to label conversations with. Works in private chat with the bot. | ||
* `/agents` — make all members of a group support agents **and** send notifications about new conversations to the | ||
group. Works in group chats. | ||
* `/send_new_conversations` — only send notifications about new conversations to a group. Works in group chats. May be | ||
useful to create a separate group without agents to overview all conversations. | ||
|
||
Agent bot commands: | ||
|
||
* `/postpone` — stop messaging with the customer currently assigned to this bot and return the conversation to NEW | ||
status. | ||
* `/resolve` — stop messaging with the customer currently assigned to this bot and mark conversation resolved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .converter import DefaultMessageConverter # noqa | ||
from .converter import MessageConverter # noqa | ||
from .customer_frontend import PubNubCustomerFrontend # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters