chatgraph 0.4.1__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chatgraph might be problematic. Click here for more details.
- {chatgraph-0.4.1 → chatgraph-0.5.0}/PKG-INFO +1 -1
- {chatgraph-0.4.1 → chatgraph-0.5.0}/chatgraph/__init__.py +4 -3
- {chatgraph-0.4.1 → chatgraph-0.5.0}/chatgraph/bot/chatbot_model.py +11 -8
- chatgraph-0.5.0/chatgraph/gRPC/gRPCCall.py +126 -0
- chatgraph-0.5.0/chatgraph/messages/message_consumer.py +150 -0
- chatgraph-0.5.0/chatgraph/pb/router.proto +127 -0
- chatgraph-0.5.0/chatgraph/pb/router_pb2.py +77 -0
- chatgraph-0.5.0/chatgraph/pb/router_pb2_grpc.py +669 -0
- chatgraph-0.5.0/chatgraph/types/message_types.py +111 -0
- chatgraph-0.5.0/chatgraph/types/request_types.py +294 -0
- {chatgraph-0.4.1 → chatgraph-0.5.0}/pyproject.toml +1 -1
- chatgraph-0.4.1/chatgraph/gRPC/gRPCCall.py +0 -210
- chatgraph-0.4.1/chatgraph/messages/message_consumer.py +0 -215
- chatgraph-0.4.1/chatgraph/pb/userstate.proto +0 -41
- chatgraph-0.4.1/chatgraph/pb/userstate_pb2.py +0 -47
- chatgraph-0.4.1/chatgraph/pb/userstate_pb2_grpc.py +0 -269
- chatgraph-0.4.1/chatgraph/pb/voll.proto +0 -90
- chatgraph-0.4.1/chatgraph/pb/voll_pb2.py +0 -63
- chatgraph-0.4.1/chatgraph/pb/voll_pb2_grpc.py +0 -470
- chatgraph-0.4.1/chatgraph/types/message_types.py +0 -108
- chatgraph-0.4.1/chatgraph/types/request_types.py +0 -370
- {chatgraph-0.4.1 → chatgraph-0.5.0}/LICENSE +0 -0
- {chatgraph-0.4.1 → chatgraph-0.5.0}/README.md +0 -0
- {chatgraph-0.4.1 → chatgraph-0.5.0}/chatgraph/auth/credentials.py +0 -0
- {chatgraph-0.4.1 → chatgraph-0.5.0}/chatgraph/bot/chatbot_router.py +0 -0
- {chatgraph-0.4.1 → chatgraph-0.5.0}/chatgraph/cli/__init__.py +0 -0
- {chatgraph-0.4.1 → chatgraph-0.5.0}/chatgraph/error/chatbot_error.py +0 -0
- {chatgraph-0.4.1 → chatgraph-0.5.0}/chatgraph/error/route_error.py +0 -0
- {chatgraph-0.4.1 → chatgraph-0.5.0}/chatgraph/types/end_types.py +0 -0
- {chatgraph-0.4.1 → chatgraph-0.5.0}/chatgraph/types/route.py +0 -0
|
@@ -2,9 +2,9 @@ from .auth.credentials import Credential
|
|
|
2
2
|
from .bot.chatbot_model import ChatbotApp
|
|
3
3
|
from .bot.chatbot_router import ChatbotRouter
|
|
4
4
|
from .messages.message_consumer import MessageConsumer
|
|
5
|
-
from .types.request_types import UserCall, UserState
|
|
5
|
+
from .types.request_types import UserCall, UserState, ChatID
|
|
6
6
|
from .types.end_types import RedirectResponse, EndChatResponse, TransferToHuman
|
|
7
|
-
from .types.message_types import Message, Button
|
|
7
|
+
from .types.message_types import Message, Button
|
|
8
8
|
from .types.route import Route
|
|
9
9
|
|
|
10
10
|
__all__ = [
|
|
@@ -18,8 +18,9 @@ __all__ = [
|
|
|
18
18
|
'Route',
|
|
19
19
|
'EndChatResponse',
|
|
20
20
|
'TransferToHuman',
|
|
21
|
+
'ChatID',
|
|
21
22
|
'UserState',
|
|
22
23
|
'Message',
|
|
23
24
|
'Button',
|
|
24
|
-
|
|
25
|
+
|
|
25
26
|
]
|
|
@@ -2,12 +2,13 @@ import inspect
|
|
|
2
2
|
from functools import wraps
|
|
3
3
|
from logging import debug
|
|
4
4
|
import json
|
|
5
|
+
import asyncio
|
|
5
6
|
from logging import error
|
|
6
7
|
|
|
7
|
-
from ..error.chatbot_error import
|
|
8
|
+
from ..error.chatbot_error import ChatbotMessageError
|
|
8
9
|
from ..messages.message_consumer import MessageConsumer
|
|
9
10
|
from ..types.request_types import UserCall
|
|
10
|
-
from ..types.message_types import
|
|
11
|
+
from ..types.message_types import Message, Button
|
|
11
12
|
from ..types.end_types import RedirectResponse, EndChatResponse, TransferToHuman
|
|
12
13
|
from ..types.route import Route
|
|
13
14
|
from .chatbot_router import ChatbotRouter
|
|
@@ -88,8 +89,10 @@ class ChatbotApp:
|
|
|
88
89
|
"""
|
|
89
90
|
Inicia o consumo de mensagens pelo chatbot, processando cada mensagem recebida.
|
|
90
91
|
"""
|
|
92
|
+
|
|
93
|
+
|
|
91
94
|
self.__message_consumer.reprer()
|
|
92
|
-
self.__message_consumer.start_consume(self.process_message)
|
|
95
|
+
asyncio.run(self.__message_consumer.start_consume(self.process_message))
|
|
93
96
|
|
|
94
97
|
def process_message(self, userCall: UserCall):
|
|
95
98
|
"""
|
|
@@ -105,16 +108,16 @@ class ChatbotApp:
|
|
|
105
108
|
Returns:
|
|
106
109
|
str: A resposta gerada pela função da rota, que pode ser uma mensagem ou o resultado de uma redireção.
|
|
107
110
|
"""
|
|
108
|
-
|
|
111
|
+
user_id = userCall.user_id
|
|
109
112
|
route = userCall.route.lower()
|
|
110
113
|
route_handler = route.split('.')[-1]
|
|
111
114
|
menu = userCall.menu.lower()
|
|
112
|
-
|
|
115
|
+
observation = userCall.observation
|
|
113
116
|
handler = self.__routes.get(route_handler, None)
|
|
114
117
|
|
|
115
118
|
if not handler:
|
|
116
119
|
raise ChatbotMessageError(
|
|
117
|
-
|
|
120
|
+
user_id, f'Rota não encontrada para {route}!'
|
|
118
121
|
)
|
|
119
122
|
|
|
120
123
|
func = handler['function']
|
|
@@ -138,14 +141,14 @@ class ChatbotApp:
|
|
|
138
141
|
def __process_func_response(self, userCall_response, userCall: UserCall, route: str):
|
|
139
142
|
|
|
140
143
|
if isinstance(userCall_response, (str, float, int)):
|
|
141
|
-
userCall.send(Message(
|
|
144
|
+
userCall.send(Message(userCall_response))
|
|
142
145
|
return
|
|
143
146
|
|
|
144
147
|
elif isinstance(userCall_response, Route):
|
|
145
148
|
userCall.route = userCall_response.current
|
|
146
149
|
return
|
|
147
150
|
|
|
148
|
-
elif isinstance(userCall_response, (Message, Button
|
|
151
|
+
elif isinstance(userCall_response, (Message, Button)):
|
|
149
152
|
userCall.send(userCall_response)
|
|
150
153
|
|
|
151
154
|
return
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import grpc
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
import chatgraph.pb.router_pb2 as chatbot_pb2
|
|
6
|
+
import chatgraph.pb.router_pb2_grpc as chatbot_pb2_grpc
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class RouterServiceClient:
|
|
10
|
+
def __init__(self, grpc_uri=None):
|
|
11
|
+
self.grpc_uri = grpc_uri or os.getenv("GRPC_URI")
|
|
12
|
+
|
|
13
|
+
if not self.grpc_uri:
|
|
14
|
+
raise ValueError("A variável de ambiente 'GRPC_URI' não está definida.")
|
|
15
|
+
|
|
16
|
+
# Cria o canal gRPC
|
|
17
|
+
self.channel = grpc.insecure_channel(self.grpc_uri)
|
|
18
|
+
|
|
19
|
+
# Cria os stubs para os serviços gRPC
|
|
20
|
+
self.user_state_stub = chatbot_pb2_grpc.UserStateServiceStub(self.channel)
|
|
21
|
+
self.send_message_stub = chatbot_pb2_grpc.SendMessageStub(self.channel)
|
|
22
|
+
self.transfer_stub = chatbot_pb2_grpc.TransferStub(self.channel)
|
|
23
|
+
self.end_chat_stub = chatbot_pb2_grpc.EndChatStub(self.channel)
|
|
24
|
+
|
|
25
|
+
def insert_update_user_state(self, user_state_data):
|
|
26
|
+
request = chatbot_pb2.UserState(**user_state_data)
|
|
27
|
+
try:
|
|
28
|
+
response = self.user_state_stub.InsertUpdateUserState(request)
|
|
29
|
+
return response
|
|
30
|
+
except grpc.RpcError as e:
|
|
31
|
+
print(f"Erro ao chamar InsertUpdateUserState: {e}")
|
|
32
|
+
return None
|
|
33
|
+
|
|
34
|
+
def delete_user_state(self, chat_id_data):
|
|
35
|
+
request = chatbot_pb2.ChatID(**chat_id_data)
|
|
36
|
+
try:
|
|
37
|
+
response = self.user_state_stub.DeleteUserState(request)
|
|
38
|
+
return response
|
|
39
|
+
except grpc.RpcError as e:
|
|
40
|
+
print(f"Erro ao chamar DeleteUserState: {e}")
|
|
41
|
+
return None
|
|
42
|
+
|
|
43
|
+
def get_user_state(self, chat_id_data):
|
|
44
|
+
request = chatbot_pb2.ChatID(**chat_id_data)
|
|
45
|
+
try:
|
|
46
|
+
response = self.user_state_stub.GetUserState(request)
|
|
47
|
+
return response
|
|
48
|
+
except grpc.RpcError as e:
|
|
49
|
+
print(f"Erro ao chamar GetUserState: {e}")
|
|
50
|
+
return None
|
|
51
|
+
|
|
52
|
+
def send_message(self, message_data):
|
|
53
|
+
print(json.dumps(message_data))
|
|
54
|
+
|
|
55
|
+
request = chatbot_pb2.Message(**message_data)
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
response = self.send_message_stub.SendMessage(request)
|
|
59
|
+
return response
|
|
60
|
+
except grpc.RpcError as e:
|
|
61
|
+
print(f"Erro ao chamar SendMessage: {e}")
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
def transfer_to_human(self, transfer_request_data):
|
|
65
|
+
request = chatbot_pb2.TransferToHumanRequest(**transfer_request_data)
|
|
66
|
+
try:
|
|
67
|
+
response = self.transfer_stub.TransferToHuman(request)
|
|
68
|
+
return response
|
|
69
|
+
except grpc.RpcError as e:
|
|
70
|
+
print(f"Erro ao chamar TransferToHuman: {e}")
|
|
71
|
+
return None
|
|
72
|
+
|
|
73
|
+
def transfer_to_menu(self, transfer_request_data):
|
|
74
|
+
request = chatbot_pb2.TransferToMenuRequest(**transfer_request_data)
|
|
75
|
+
try:
|
|
76
|
+
response = self.transfer_stub.TransferToMenu(request)
|
|
77
|
+
return response
|
|
78
|
+
except grpc.RpcError as e:
|
|
79
|
+
print(f"Erro ao chamar TransferToMenu: {e}")
|
|
80
|
+
return None
|
|
81
|
+
|
|
82
|
+
def end_chat(self, end_chat_request_data):
|
|
83
|
+
request = chatbot_pb2.EndChatRequest(**end_chat_request_data)
|
|
84
|
+
try:
|
|
85
|
+
response = self.end_chat_stub.EndChat(request)
|
|
86
|
+
return response
|
|
87
|
+
except grpc.RpcError as e:
|
|
88
|
+
print(f"Erro ao chamar EndChat: {e}")
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
def get_campaign_id(self, campaign_name):
|
|
92
|
+
request = chatbot_pb2.CampaignName(**campaign_name)
|
|
93
|
+
try:
|
|
94
|
+
response = self.transfer_stub.GetCampaignID(request)
|
|
95
|
+
print(response)
|
|
96
|
+
return response
|
|
97
|
+
except grpc.RpcError as e:
|
|
98
|
+
print(f"Erro ao chamar GetCampaignID: {e}")
|
|
99
|
+
return None
|
|
100
|
+
|
|
101
|
+
def get_all_campaigns(self):
|
|
102
|
+
request = chatbot_pb2.Void()
|
|
103
|
+
try:
|
|
104
|
+
response = self.transfer_stub.GetAllCampaigns(request)
|
|
105
|
+
return response
|
|
106
|
+
except grpc.RpcError as e:
|
|
107
|
+
print(f"Erro ao chamar GetAllCampaigns: {e}")
|
|
108
|
+
return None
|
|
109
|
+
|
|
110
|
+
def get_tabulation_id(self, tabulation_name):
|
|
111
|
+
request = chatbot_pb2.TabulationName(**tabulation_name)
|
|
112
|
+
try:
|
|
113
|
+
response = self.end_chat_stub.GetTabulationID(request)
|
|
114
|
+
return response
|
|
115
|
+
except grpc.RpcError as e:
|
|
116
|
+
print(f"Erro ao chamar GetTabulationID: {e}")
|
|
117
|
+
return None
|
|
118
|
+
|
|
119
|
+
def get_all_tabulations(self):
|
|
120
|
+
request = chatbot_pb2.Void()
|
|
121
|
+
try:
|
|
122
|
+
response = self.end_chat_stub.GetAllTabulations(request)
|
|
123
|
+
return response
|
|
124
|
+
except grpc.RpcError as e:
|
|
125
|
+
print(f"Erro ao chamar GetAllTabulations: {e}")
|
|
126
|
+
return None
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import asyncio
|
|
3
|
+
from logging import debug, info
|
|
4
|
+
import os
|
|
5
|
+
import aio_pika
|
|
6
|
+
from typing import Callable
|
|
7
|
+
from ..auth.credentials import Credential
|
|
8
|
+
from ..types.request_types import UserCall, UserState, ChatID
|
|
9
|
+
from rich.console import Console
|
|
10
|
+
from rich.table import Table
|
|
11
|
+
from rich.text import Text
|
|
12
|
+
from rich.panel import Panel
|
|
13
|
+
from urllib.parse import quote
|
|
14
|
+
|
|
15
|
+
class MessageConsumer:
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
credential: Credential,
|
|
19
|
+
amqp_url: str,
|
|
20
|
+
grpc_uri: str,
|
|
21
|
+
queue_consume: str,
|
|
22
|
+
prefetch_count: int = 1,
|
|
23
|
+
virtual_host: str = "/",
|
|
24
|
+
) -> None:
|
|
25
|
+
self.__virtual_host = virtual_host
|
|
26
|
+
self.__prefetch_count = prefetch_count
|
|
27
|
+
self.__queue_consume = queue_consume
|
|
28
|
+
self.__amqp_url = amqp_url
|
|
29
|
+
self.__grpc_uri = grpc_uri
|
|
30
|
+
self.__credentials = credential
|
|
31
|
+
|
|
32
|
+
@classmethod
|
|
33
|
+
def load_dotenv(
|
|
34
|
+
cls,
|
|
35
|
+
user_env: str = "RABBIT_USER",
|
|
36
|
+
pass_env: str = "RABBIT_PASS",
|
|
37
|
+
uri_env: str = "RABBIT_URI",
|
|
38
|
+
queue_env: str = "RABBIT_QUEUE",
|
|
39
|
+
prefetch_env: str = "RABBIT_PREFETCH",
|
|
40
|
+
vhost_env: str = "RABBIT_VHOST",
|
|
41
|
+
grpc_uri: str = "GRPC_URI",
|
|
42
|
+
) -> "MessageConsumer":
|
|
43
|
+
username = os.getenv(user_env)
|
|
44
|
+
password = os.getenv(pass_env)
|
|
45
|
+
url = os.getenv(uri_env)
|
|
46
|
+
queue = os.getenv(queue_env)
|
|
47
|
+
prefetch = os.getenv(prefetch_env, 1)
|
|
48
|
+
vhost = os.getenv(vhost_env, "/")
|
|
49
|
+
grpc = os.getenv(grpc_uri)
|
|
50
|
+
|
|
51
|
+
if not username or not password or not url or not queue or not grpc:
|
|
52
|
+
raise ValueError("Corrija as variáveis de ambiente!")
|
|
53
|
+
|
|
54
|
+
return cls(
|
|
55
|
+
credential=Credential(username=username, password=password),
|
|
56
|
+
amqp_url=url,
|
|
57
|
+
queue_consume=queue,
|
|
58
|
+
prefetch_count=int(prefetch),
|
|
59
|
+
virtual_host=vhost,
|
|
60
|
+
grpc_uri=grpc,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
async def start_consume(self, process_message: Callable):
|
|
64
|
+
try:
|
|
65
|
+
user = quote(self.__credentials.username)
|
|
66
|
+
pwd = quote(self.__credentials.password)
|
|
67
|
+
vhost = quote(self.__virtual_host)
|
|
68
|
+
uri = self.__amqp_url
|
|
69
|
+
amqp_url = f"amqp://{user}:{pwd}@{uri}/{vhost}"
|
|
70
|
+
connection = await aio_pika.connect_robust(amqp_url)
|
|
71
|
+
|
|
72
|
+
async with connection:
|
|
73
|
+
channel = await connection.channel()
|
|
74
|
+
await channel.set_qos(prefetch_count=self.__prefetch_count)
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
queue = await channel.get_queue(self.__queue_consume, ensure=True)
|
|
78
|
+
except aio_pika.exceptions.ChannelNotFoundEntity:
|
|
79
|
+
arguments = {
|
|
80
|
+
"x-dead-letter-exchange": "log_error", # Dead Letter Exchange
|
|
81
|
+
"x-expires": 86400000, # Expiração da fila (em milissegundos)
|
|
82
|
+
"x-message-ttl": 300000 # Tempo de vida das mensagens (em milissegundos)
|
|
83
|
+
}
|
|
84
|
+
queue = await channel.declare_queue(self.__queue_consume, durable=True, arguments=arguments)
|
|
85
|
+
|
|
86
|
+
info("[x] Server inicializado! Aguardando solicitações RPC")
|
|
87
|
+
|
|
88
|
+
async for message in queue:
|
|
89
|
+
async with message.process():
|
|
90
|
+
await self.on_request(message.body, process_message)
|
|
91
|
+
except Exception as e:
|
|
92
|
+
print(f"Erro durante o consumo de mensagens: {e}")
|
|
93
|
+
# Reiniciar a conexão em caso de falha
|
|
94
|
+
# await self.start_consume(process_message)
|
|
95
|
+
|
|
96
|
+
async def on_request(self, body: bytes, process_message: Callable):
|
|
97
|
+
try:
|
|
98
|
+
message = body.decode()
|
|
99
|
+
message_json = json.loads(message)
|
|
100
|
+
pure_message = self.__transform_message(message_json)
|
|
101
|
+
await process_message(pure_message)
|
|
102
|
+
except Exception as e:
|
|
103
|
+
print(f"Erro ao processar mensagem: {e}")
|
|
104
|
+
|
|
105
|
+
def __transform_message(self, message: dict) -> UserCall:
|
|
106
|
+
user_state = message.get("user_state", {})
|
|
107
|
+
observation = user_state.get("observation", {})
|
|
108
|
+
if isinstance(observation, str):
|
|
109
|
+
observation = json.loads(observation)
|
|
110
|
+
|
|
111
|
+
usercall = UserCall(
|
|
112
|
+
user_state=UserState(
|
|
113
|
+
chatID=ChatID(
|
|
114
|
+
user_id=user_state['chat_id'].get("user_id", ""),
|
|
115
|
+
company_id=user_state['chat_id'].get("company_id", ""),
|
|
116
|
+
),
|
|
117
|
+
menu=user_state.get("menu", ""),
|
|
118
|
+
route=user_state.get("route", ""),
|
|
119
|
+
protocol=user_state.get("protocol", ""),
|
|
120
|
+
observation=observation,
|
|
121
|
+
),
|
|
122
|
+
type_message=message.get("type_message", ""),
|
|
123
|
+
content_message=message.get("content_message", ""),
|
|
124
|
+
grpc_uri=self.__grpc_uri,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
return usercall
|
|
128
|
+
|
|
129
|
+
def reprer(self):
|
|
130
|
+
console = Console()
|
|
131
|
+
|
|
132
|
+
title_text = Text("ChatGraph", style="bold red", justify="center")
|
|
133
|
+
title_panel = Panel.fit(title_text, title=" ", border_style="bold red", padding=(1, 4))
|
|
134
|
+
|
|
135
|
+
separator = Text("🐇🐇🐇 RabbitMessageConsumer 📨📨📨", style="cyan", justify="center")
|
|
136
|
+
|
|
137
|
+
table = Table(show_header=True, header_style="bold magenta", title="RabbitMQ Consumer")
|
|
138
|
+
table.add_column("Atributo", justify="center", style="cyan", no_wrap=True)
|
|
139
|
+
table.add_column("Valor", justify="center", style="magenta")
|
|
140
|
+
|
|
141
|
+
table.add_row("Virtual Host", self.__virtual_host)
|
|
142
|
+
table.add_row("Prefetch Count", str(self.__prefetch_count))
|
|
143
|
+
table.add_row("Queue Consume", self.__queue_consume)
|
|
144
|
+
table.add_row("AMQP URL", self.__amqp_url)
|
|
145
|
+
table.add_row("Username", self.__credentials.username)
|
|
146
|
+
table.add_row("Password", "******")
|
|
147
|
+
|
|
148
|
+
console.print(title_panel, justify="center")
|
|
149
|
+
console.print(separator, justify="center")
|
|
150
|
+
console.print(table, justify="center")
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package chatbot;
|
|
4
|
+
|
|
5
|
+
option go_package = "./chatbot";
|
|
6
|
+
|
|
7
|
+
///// Serviços de Estado do Usuário /////
|
|
8
|
+
service UserStateService {
|
|
9
|
+
rpc InsertUpdateUserState(UserState) returns (RequestStatus);
|
|
10
|
+
rpc DeleteUserState(ChatID) returns (RequestStatus);
|
|
11
|
+
rpc GetUserState(ChatID) returns (UserState);
|
|
12
|
+
rpc GetAllUserStates(Void) returns (UserStateList);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
///// Serviços de Mensagens /////
|
|
16
|
+
service SendMessage {
|
|
17
|
+
rpc SendMessage(Message) returns (RequestStatus);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
///// Serviços de Transfer /////
|
|
21
|
+
service Transfer {
|
|
22
|
+
rpc GetAllCampaigns(Void) returns (CampaignsList);
|
|
23
|
+
rpc GetCampaignID(CampaignName) returns (CampaignDetails);
|
|
24
|
+
rpc TransferToHuman(TransferToHumanRequest) returns (RequestStatus);
|
|
25
|
+
rpc TransferToMenu(TransferToMenuRequest) returns (RequestStatus);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
///// Serviços de EndChat /////
|
|
29
|
+
service EndChat {
|
|
30
|
+
rpc GetAllTabulations(Void) returns (TabulationsList);
|
|
31
|
+
rpc GetTabulationID(TabulationName) returns (TabulationDetails);
|
|
32
|
+
rpc EndChat(EndChatRequest) returns (RequestStatus);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
///// Mensagens Compartilhadas /////
|
|
36
|
+
message Void {}
|
|
37
|
+
|
|
38
|
+
message RequestStatus {
|
|
39
|
+
bool status = 1;
|
|
40
|
+
string message = 2;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
message ChatID {
|
|
44
|
+
string user_id = 1;
|
|
45
|
+
string company_id = 2;
|
|
46
|
+
}
|
|
47
|
+
///// Mensagens para Estado do Usuário /////
|
|
48
|
+
message UserState {
|
|
49
|
+
ChatID chat_id = 1;
|
|
50
|
+
string menu = 2;
|
|
51
|
+
string route = 3;
|
|
52
|
+
string protocol = 4;
|
|
53
|
+
string observation = 5;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
message UserStateList {
|
|
57
|
+
repeated UserState user_states = 1;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
///// Mensagens para Serviços de Mensagens /////
|
|
61
|
+
message TextMessage {
|
|
62
|
+
string type = 1;
|
|
63
|
+
string url = 2;
|
|
64
|
+
string filename = 3;
|
|
65
|
+
string title = 4;
|
|
66
|
+
string detail = 5;
|
|
67
|
+
string caption = 6;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
message Button{
|
|
71
|
+
string type = 1;
|
|
72
|
+
string title = 2;
|
|
73
|
+
string detail = 3;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
message Message {
|
|
77
|
+
ChatID chat_id = 1;
|
|
78
|
+
TextMessage message = 2;
|
|
79
|
+
repeated Button buttons = 3;
|
|
80
|
+
Button display_button = 4;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
///// Mensagens para Serviços de Transfer /////
|
|
84
|
+
message TransferToHumanRequest{
|
|
85
|
+
ChatID chat_id = 1;
|
|
86
|
+
string campaign_id = 2;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
message TransferToMenuRequest{
|
|
90
|
+
ChatID chat_id = 1;
|
|
91
|
+
string menu = 2;
|
|
92
|
+
string user_message = 3;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
message TabulationName{
|
|
96
|
+
string name = 1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
message TabulationDetails{
|
|
100
|
+
string id = 1;
|
|
101
|
+
string name = 2;
|
|
102
|
+
string last_update = 3;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
message TabulationsList{
|
|
106
|
+
repeated TabulationDetails tabulations = 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
///// Serviços de EndChat /////
|
|
110
|
+
message EndChatRequest {
|
|
111
|
+
ChatID chat_id = 1;
|
|
112
|
+
string tabulation_id = 2;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
message CampaignName {
|
|
116
|
+
string name = 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
message CampaignDetails {
|
|
120
|
+
string id = 1;
|
|
121
|
+
string name = 2;
|
|
122
|
+
string last_update = 3;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
message CampaignsList {
|
|
126
|
+
repeated CampaignDetails campaigns = 1;
|
|
127
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
+
# source: router.proto
|
|
5
|
+
# Protobuf Python Version: 5.27.2
|
|
6
|
+
"""Generated protocol buffer code."""
|
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
+
from google.protobuf.internal import builder as _builder
|
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
|
14
|
+
5,
|
|
15
|
+
27,
|
|
16
|
+
2,
|
|
17
|
+
'',
|
|
18
|
+
'router.proto'
|
|
19
|
+
)
|
|
20
|
+
# @@protoc_insertion_point(imports)
|
|
21
|
+
|
|
22
|
+
_sym_db = _symbol_database.Default()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0crouter.proto\x12\x07\x63hatbot\"\x06\n\x04Void\"0\n\rRequestStatus\x12\x0e\n\x06status\x18\x01 \x01(\x08\x12\x0f\n\x07message\x18\x02 \x01(\t\"-\n\x06\x43hatID\x12\x0f\n\x07user_id\x18\x01 \x01(\t\x12\x12\n\ncompany_id\x18\x02 \x01(\t\"q\n\tUserState\x12 \n\x07\x63hat_id\x18\x01 \x01(\x0b\x32\x0f.chatbot.ChatID\x12\x0c\n\x04menu\x18\x02 \x01(\t\x12\r\n\x05route\x18\x03 \x01(\t\x12\x10\n\x08protocol\x18\x04 \x01(\t\x12\x13\n\x0bobservation\x18\x05 \x01(\t\"8\n\rUserStateList\x12\'\n\x0buser_states\x18\x01 \x03(\x0b\x32\x12.chatbot.UserState\"j\n\x0bTextMessage\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\x0b\n\x03url\x18\x02 \x01(\t\x12\x10\n\x08\x66ilename\x18\x03 \x01(\t\x12\r\n\x05title\x18\x04 \x01(\t\x12\x0e\n\x06\x64\x65tail\x18\x05 \x01(\t\x12\x0f\n\x07\x63\x61ption\x18\x06 \x01(\t\"5\n\x06\x42utton\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\r\n\x05title\x18\x02 \x01(\t\x12\x0e\n\x06\x64\x65tail\x18\x03 \x01(\t\"\x9d\x01\n\x07Message\x12 \n\x07\x63hat_id\x18\x01 \x01(\x0b\x32\x0f.chatbot.ChatID\x12%\n\x07message\x18\x02 \x01(\x0b\x32\x14.chatbot.TextMessage\x12 \n\x07\x62uttons\x18\x03 \x03(\x0b\x32\x0f.chatbot.Button\x12\'\n\x0e\x64isplay_button\x18\x04 \x01(\x0b\x32\x0f.chatbot.Button\"O\n\x16TransferToHumanRequest\x12 \n\x07\x63hat_id\x18\x01 \x01(\x0b\x32\x0f.chatbot.ChatID\x12\x13\n\x0b\x63\x61mpaign_id\x18\x02 \x01(\t\"]\n\x15TransferToMenuRequest\x12 \n\x07\x63hat_id\x18\x01 \x01(\x0b\x32\x0f.chatbot.ChatID\x12\x0c\n\x04menu\x18\x02 \x01(\t\x12\x14\n\x0cuser_message\x18\x03 \x01(\t\"\x1e\n\x0eTabulationName\x12\x0c\n\x04name\x18\x01 \x01(\t\"B\n\x11TabulationDetails\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x13\n\x0blast_update\x18\x03 \x01(\t\"B\n\x0fTabulationsList\x12/\n\x0btabulations\x18\x01 \x03(\x0b\x32\x1a.chatbot.TabulationDetails\"I\n\x0e\x45ndChatRequest\x12 \n\x07\x63hat_id\x18\x01 \x01(\x0b\x32\x0f.chatbot.ChatID\x12\x15\n\rtabulation_id\x18\x02 \x01(\t\"\x1c\n\x0c\x43\x61mpaignName\x12\x0c\n\x04name\x18\x01 \x01(\t\"@\n\x0f\x43\x61mpaignDetails\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x13\n\x0blast_update\x18\x03 \x01(\t\"<\n\rCampaignsList\x12+\n\tcampaigns\x18\x01 \x03(\x0b\x32\x18.chatbot.CampaignDetails2\x83\x02\n\x10UserStateService\x12\x43\n\x15InsertUpdateUserState\x12\x12.chatbot.UserState\x1a\x16.chatbot.RequestStatus\x12:\n\x0f\x44\x65leteUserState\x12\x0f.chatbot.ChatID\x1a\x16.chatbot.RequestStatus\x12\x33\n\x0cGetUserState\x12\x0f.chatbot.ChatID\x1a\x12.chatbot.UserState\x12\x39\n\x10GetAllUserStates\x12\r.chatbot.Void\x1a\x16.chatbot.UserStateList2F\n\x0bSendMessage\x12\x37\n\x0bSendMessage\x12\x10.chatbot.Message\x1a\x16.chatbot.RequestStatus2\x9c\x02\n\x08Transfer\x12\x38\n\x0fGetAllCampaigns\x12\r.chatbot.Void\x1a\x16.chatbot.CampaignsList\x12@\n\rGetCampaignID\x12\x15.chatbot.CampaignName\x1a\x18.chatbot.CampaignDetails\x12J\n\x0fTransferToHuman\x12\x1f.chatbot.TransferToHumanRequest\x1a\x16.chatbot.RequestStatus\x12H\n\x0eTransferToMenu\x12\x1e.chatbot.TransferToMenuRequest\x1a\x16.chatbot.RequestStatus2\xcb\x01\n\x07\x45ndChat\x12<\n\x11GetAllTabulations\x12\r.chatbot.Void\x1a\x18.chatbot.TabulationsList\x12\x46\n\x0fGetTabulationID\x12\x17.chatbot.TabulationName\x1a\x1a.chatbot.TabulationDetails\x12:\n\x07\x45ndChat\x12\x17.chatbot.EndChatRequest\x1a\x16.chatbot.RequestStatusB\x0bZ\t./chatbotb\x06proto3')
|
|
28
|
+
|
|
29
|
+
_globals = globals()
|
|
30
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
31
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'router_pb2', _globals)
|
|
32
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
33
|
+
_globals['DESCRIPTOR']._loaded_options = None
|
|
34
|
+
_globals['DESCRIPTOR']._serialized_options = b'Z\t./chatbot'
|
|
35
|
+
_globals['_VOID']._serialized_start=25
|
|
36
|
+
_globals['_VOID']._serialized_end=31
|
|
37
|
+
_globals['_REQUESTSTATUS']._serialized_start=33
|
|
38
|
+
_globals['_REQUESTSTATUS']._serialized_end=81
|
|
39
|
+
_globals['_CHATID']._serialized_start=83
|
|
40
|
+
_globals['_CHATID']._serialized_end=128
|
|
41
|
+
_globals['_USERSTATE']._serialized_start=130
|
|
42
|
+
_globals['_USERSTATE']._serialized_end=243
|
|
43
|
+
_globals['_USERSTATELIST']._serialized_start=245
|
|
44
|
+
_globals['_USERSTATELIST']._serialized_end=301
|
|
45
|
+
_globals['_TEXTMESSAGE']._serialized_start=303
|
|
46
|
+
_globals['_TEXTMESSAGE']._serialized_end=409
|
|
47
|
+
_globals['_BUTTON']._serialized_start=411
|
|
48
|
+
_globals['_BUTTON']._serialized_end=464
|
|
49
|
+
_globals['_MESSAGE']._serialized_start=467
|
|
50
|
+
_globals['_MESSAGE']._serialized_end=624
|
|
51
|
+
_globals['_TRANSFERTOHUMANREQUEST']._serialized_start=626
|
|
52
|
+
_globals['_TRANSFERTOHUMANREQUEST']._serialized_end=705
|
|
53
|
+
_globals['_TRANSFERTOMENUREQUEST']._serialized_start=707
|
|
54
|
+
_globals['_TRANSFERTOMENUREQUEST']._serialized_end=800
|
|
55
|
+
_globals['_TABULATIONNAME']._serialized_start=802
|
|
56
|
+
_globals['_TABULATIONNAME']._serialized_end=832
|
|
57
|
+
_globals['_TABULATIONDETAILS']._serialized_start=834
|
|
58
|
+
_globals['_TABULATIONDETAILS']._serialized_end=900
|
|
59
|
+
_globals['_TABULATIONSLIST']._serialized_start=902
|
|
60
|
+
_globals['_TABULATIONSLIST']._serialized_end=968
|
|
61
|
+
_globals['_ENDCHATREQUEST']._serialized_start=970
|
|
62
|
+
_globals['_ENDCHATREQUEST']._serialized_end=1043
|
|
63
|
+
_globals['_CAMPAIGNNAME']._serialized_start=1045
|
|
64
|
+
_globals['_CAMPAIGNNAME']._serialized_end=1073
|
|
65
|
+
_globals['_CAMPAIGNDETAILS']._serialized_start=1075
|
|
66
|
+
_globals['_CAMPAIGNDETAILS']._serialized_end=1139
|
|
67
|
+
_globals['_CAMPAIGNSLIST']._serialized_start=1141
|
|
68
|
+
_globals['_CAMPAIGNSLIST']._serialized_end=1201
|
|
69
|
+
_globals['_USERSTATESERVICE']._serialized_start=1204
|
|
70
|
+
_globals['_USERSTATESERVICE']._serialized_end=1463
|
|
71
|
+
_globals['_SENDMESSAGE']._serialized_start=1465
|
|
72
|
+
_globals['_SENDMESSAGE']._serialized_end=1535
|
|
73
|
+
_globals['_TRANSFER']._serialized_start=1538
|
|
74
|
+
_globals['_TRANSFER']._serialized_end=1822
|
|
75
|
+
_globals['_ENDCHAT']._serialized_start=1825
|
|
76
|
+
_globals['_ENDCHAT']._serialized_end=2028
|
|
77
|
+
# @@protoc_insertion_point(module_scope)
|