atendentepro 0.3.0__py3-none-any.whl → 0.5.2__py3-none-any.whl
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.
- atendentepro/README.md +651 -74
- atendentepro/__init__.py +17 -3
- atendentepro/agents/__init__.py +11 -0
- atendentepro/agents/answer.py +1 -2
- atendentepro/agents/escalation.py +510 -0
- atendentepro/agents/feedback.py +961 -0
- atendentepro/license.py +3 -3
- atendentepro/network.py +115 -15
- atendentepro/prompts/__init__.py +10 -0
- atendentepro/prompts/answer.py +2 -3
- atendentepro/prompts/escalation.py +190 -0
- atendentepro/prompts/feedback.py +232 -0
- {atendentepro-0.3.0.dist-info → atendentepro-0.5.2.dist-info}/METADATA +58 -44
- {atendentepro-0.3.0.dist-info → atendentepro-0.5.2.dist-info}/RECORD +18 -14
- {atendentepro-0.3.0.dist-info → atendentepro-0.5.2.dist-info}/licenses/LICENSE +3 -3
- {atendentepro-0.3.0.dist-info → atendentepro-0.5.2.dist-info}/WHEEL +0 -0
- {atendentepro-0.3.0.dist-info → atendentepro-0.5.2.dist-info}/entry_points.txt +0 -0
- {atendentepro-0.3.0.dist-info → atendentepro-0.5.2.dist-info}/top_level.txt +0 -0
atendentepro/README.md
CHANGED
|
@@ -77,8 +77,119 @@ if is_activated():
|
|
|
77
77
|
### Obter um Token
|
|
78
78
|
|
|
79
79
|
Entre em contato para obter seu token de licença:
|
|
80
|
-
- 📧 **Email:** contato@
|
|
81
|
-
- 🌐 **Site:** https://
|
|
80
|
+
- 📧 **Email:** contato@monkai.com.br
|
|
81
|
+
- 🌐 **Site:** https://www.monkai.com.br
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 🔐 Configurar API Key do OpenAI/Azure
|
|
86
|
+
|
|
87
|
+
A biblioteca precisa de uma chave de API para funcionar. Existem várias formas de configurar:
|
|
88
|
+
|
|
89
|
+
### Opção 1: Variáveis de Ambiente (Recomendado)
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Criar arquivo .env na raiz do projeto
|
|
93
|
+
ATENDENTEPRO_LICENSE_KEY=ATP_seu-token
|
|
94
|
+
OPENAI_API_KEY=sk-sua-chave-openai
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from dotenv import load_dotenv
|
|
99
|
+
load_dotenv() # Carrega o .env
|
|
100
|
+
|
|
101
|
+
from atendentepro import create_standard_network
|
|
102
|
+
# ✅ API key carregada automaticamente!
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Opção 2: Função `configure()`
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from atendentepro import activate, configure, create_standard_network
|
|
109
|
+
|
|
110
|
+
# 1. Ativar licença
|
|
111
|
+
activate("ATP_seu-token")
|
|
112
|
+
|
|
113
|
+
# 2. Configurar API key programaticamente
|
|
114
|
+
configure(
|
|
115
|
+
openai_api_key="sk-sua-chave-openai",
|
|
116
|
+
default_model="gpt-4o-mini" # Opcional: mudar modelo padrão
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
# 3. Usar normalmente
|
|
120
|
+
network = create_standard_network(...)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Opção 3: Configuração Completa com `AtendentProConfig`
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from atendentepro import activate, configure, AtendentProConfig
|
|
127
|
+
|
|
128
|
+
activate("ATP_seu-token")
|
|
129
|
+
|
|
130
|
+
# Configuração detalhada
|
|
131
|
+
config = AtendentProConfig(
|
|
132
|
+
provider="openai",
|
|
133
|
+
openai_api_key="sk-sua-chave-openai",
|
|
134
|
+
default_model="gpt-4o",
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
configure(config)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Opção 4: Configurar Azure OpenAI
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
from atendentepro import activate, configure, AtendentProConfig
|
|
144
|
+
|
|
145
|
+
activate("ATP_seu-token")
|
|
146
|
+
|
|
147
|
+
config = AtendentProConfig(
|
|
148
|
+
provider="azure",
|
|
149
|
+
azure_api_key="sua-chave-azure",
|
|
150
|
+
azure_api_endpoint="https://seu-recurso.openai.azure.com",
|
|
151
|
+
azure_api_version="2024-02-15-preview",
|
|
152
|
+
azure_deployment_name="gpt-4o", # Nome do deployment
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
configure(config)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Opção 5: Variáveis de Ambiente para Azure
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# .env
|
|
162
|
+
ATENDENTEPRO_LICENSE_KEY=ATP_seu-token
|
|
163
|
+
OPENAI_PROVIDER=azure
|
|
164
|
+
AZURE_API_KEY=sua-chave-azure
|
|
165
|
+
AZURE_API_ENDPOINT=https://seu-recurso.openai.azure.com
|
|
166
|
+
AZURE_API_VERSION=2024-02-15-preview
|
|
167
|
+
AZURE_DEPLOYMENT_NAME=gpt-4o
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Verificar Configuração Atual
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from atendentepro import get_config
|
|
174
|
+
|
|
175
|
+
config = get_config()
|
|
176
|
+
print(f"Provider: {config.provider}")
|
|
177
|
+
print(f"Model: {config.default_model}")
|
|
178
|
+
print(f"API Key configurada: {'Sim' if config.openai_api_key else 'Não'}")
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Tabela de Variáveis de Ambiente
|
|
182
|
+
|
|
183
|
+
| Variável | Descrição | Obrigatório |
|
|
184
|
+
|----------|-----------|-------------|
|
|
185
|
+
| `ATENDENTEPRO_LICENSE_KEY` | Token de licença | ✅ Sim |
|
|
186
|
+
| `OPENAI_API_KEY` | Chave API OpenAI | ✅ (se OpenAI) |
|
|
187
|
+
| `OPENAI_PROVIDER` | `openai` ou `azure` | Não (padrão: openai) |
|
|
188
|
+
| `DEFAULT_MODEL` | Modelo padrão | Não (padrão: gpt-4.1) |
|
|
189
|
+
| `AZURE_API_KEY` | Chave API Azure | ✅ (se Azure) |
|
|
190
|
+
| `AZURE_API_ENDPOINT` | Endpoint Azure | ✅ (se Azure) |
|
|
191
|
+
| `AZURE_API_VERSION` | Versão API Azure | ✅ (se Azure) |
|
|
192
|
+
| `AZURE_DEPLOYMENT_NAME` | Nome do deployment | Não |
|
|
82
193
|
|
|
83
194
|
---
|
|
84
195
|
|
|
@@ -138,44 +249,50 @@ asyncio.run(main())
|
|
|
138
249
|
Imagine o **AtendentePro** como um **restaurante sofisticado** onde cada funcionário tem uma função específica:
|
|
139
250
|
|
|
140
251
|
```
|
|
141
|
-
|
|
142
|
-
│
|
|
143
|
-
|
|
144
|
-
│
|
|
145
|
-
│ 👤 CLIENTE chega e é recebido pelo:
|
|
146
|
-
│
|
|
147
|
-
│ 🚪 RECEPCIONISTA (Triage Agent)
|
|
148
|
-
│ └─ "Boa noite! Você quer jantar, fazer reserva ou tirar dúvida?"
|
|
149
|
-
│ Ele IDENTIFICA a intenção e DIRECIONA para o setor certo.
|
|
150
|
-
│
|
|
151
|
-
│
|
|
152
|
-
│ │
|
|
153
|
-
│ ▼
|
|
154
|
-
│
|
|
155
|
-
│ 📋 MAITRE
|
|
156
|
-
│ (Flow
|
|
157
|
-
│ "
|
|
158
|
-
│
|
|
159
|
-
│
|
|
160
|
-
│
|
|
161
|
-
│ │
|
|
162
|
-
│
|
|
163
|
-
│
|
|
164
|
-
│
|
|
165
|
-
│
|
|
166
|
-
│
|
|
167
|
-
│ │
|
|
168
|
-
│
|
|
169
|
-
│
|
|
170
|
-
│
|
|
171
|
-
│
|
|
172
|
-
│
|
|
173
|
-
│ │
|
|
174
|
-
│
|
|
175
|
-
│
|
|
176
|
-
│
|
|
177
|
-
│
|
|
178
|
-
|
|
252
|
+
┌──────────────────────────────────────────────────────────────────────────────┐
|
|
253
|
+
│ 🍽️ RESTAURANTE ATENDENTEPRO │
|
|
254
|
+
├──────────────────────────────────────────────────────────────────────────────┤
|
|
255
|
+
│ │
|
|
256
|
+
│ 👤 CLIENTE chega e é recebido pelo: │
|
|
257
|
+
│ │
|
|
258
|
+
│ 🚪 RECEPCIONISTA (Triage Agent) │
|
|
259
|
+
│ └─ "Boa noite! Você quer jantar, fazer reserva ou tirar dúvida?" │
|
|
260
|
+
│ Ele IDENTIFICA a intenção e DIRECIONA para o setor certo. │
|
|
261
|
+
│ │
|
|
262
|
+
│ ┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐ │
|
|
263
|
+
│ │ │ │ │ │ │ │ │
|
|
264
|
+
│ ▼ ▼ ▼ ▼ ▼ ▼ ▼ │
|
|
265
|
+
│ │
|
|
266
|
+
│ 📋 MAITRE 📚 SOMME ✅ CONFIRMA ❓ CONCI 📞 GERENTE 📝 SUGEST 🆕 VIP │
|
|
267
|
+
│ (Flow) (Knowledge) (Confirm) (Usage) (Escalat) (Feedback) (Onb.) │
|
|
268
|
+
│ "3 opções" "Malbec "Confirma "Deixa eu "Chamo o "Quer "Novo │
|
|
269
|
+
│ 2019" 2 pessoas?" explicar" gerente" registrar?" aqui?" │
|
|
270
|
+
│ │
|
|
271
|
+
│ │ │
|
|
272
|
+
│ ▼ │
|
|
273
|
+
│ │
|
|
274
|
+
│ 📝 GARÇOM (Interview Agent) │
|
|
275
|
+
│ └─ Coleta as informações: "Quantas pessoas? Alguma alergia?" │
|
|
276
|
+
│ │
|
|
277
|
+
│ │ │
|
|
278
|
+
│ ▼ │
|
|
279
|
+
│ │
|
|
280
|
+
│ 🍳 CHEF (Answer Agent) │
|
|
281
|
+
│ └─ Prepara a resposta final com todas as informações │
|
|
282
|
+
│ │
|
|
283
|
+
│ │ │
|
|
284
|
+
│ ▼ │
|
|
285
|
+
│ │
|
|
286
|
+
│ 🎉 PRATO ENTREGUE (Resposta ao usuário) │
|
|
287
|
+
│ │
|
|
288
|
+
│ ═══════════════════════════════════════════════════════════════════════════ │
|
|
289
|
+
│ │
|
|
290
|
+
│ 📞 GERENTE (Escalation) ──► Transfere para atendimento humano IMEDIATO │
|
|
291
|
+
│ 📝 SUGESTÕES (Feedback) ──► Registra reclamações/sugestões para DEPOIS │
|
|
292
|
+
│ │
|
|
293
|
+
│ 💡 Qualquer agente pode chamar o Gerente ou enviar para Sugestões! │
|
|
294
|
+
│ │
|
|
295
|
+
└──────────────────────────────────────────────────────────────────────────────┘
|
|
179
296
|
```
|
|
180
297
|
|
|
181
298
|
**Traduzindo para o código:**
|
|
@@ -190,6 +307,8 @@ Imagine o **AtendentePro** como um **restaurante sofisticado** onde cada funcion
|
|
|
190
307
|
| ✅ Confirmador | **Confirmation Agent** | Valida com sim/não |
|
|
191
308
|
| ❓ Concierge | **Usage Agent** | Explica como funciona |
|
|
192
309
|
| 🆕 Recepção VIP | **Onboarding Agent** | Cadastra novos clientes |
|
|
310
|
+
| 📞 Gerente | **Escalation Agent** | Chama o gerente quando precisa |
|
|
311
|
+
| 📝 Caixa de Sugestões | **Feedback Agent** | Registra elogios, reclamações e sugestões |
|
|
193
312
|
| 🚫 Segurança | **Guardrails** | Define o que pode/não pode ser feito |
|
|
194
313
|
| 📖 Menu/Cardápio | **YAML Configs** | Configurações de cada "funcionário" |
|
|
195
314
|
|
|
@@ -262,6 +381,8 @@ flowchart TB
|
|
|
262
381
|
CONFIRMATION["Confirmation Agent<br/>Validacao"]
|
|
263
382
|
USAGE["Usage Agent<br/>Ajuda"]
|
|
264
383
|
ONBOARDING["Onboarding Agent<br/>Cadastro"]
|
|
384
|
+
ESCALATION["Escalation Agent<br/>Transfer. humana"]
|
|
385
|
+
FEEDBACK["Feedback Agent<br/>Tickets/SAC"]
|
|
265
386
|
end
|
|
266
387
|
|
|
267
388
|
subgraph TOOLS["TOOLS"]
|
|
@@ -317,15 +438,19 @@ flowchart LR
|
|
|
317
438
|
C["Confirmation"]
|
|
318
439
|
U["Usage"]
|
|
319
440
|
O["Onboarding"]
|
|
441
|
+
E["Escalation"]
|
|
442
|
+
FB["Feedback"]
|
|
320
443
|
|
|
321
|
-
T --> F & K & C & U & O
|
|
322
|
-
F --> I & T
|
|
323
|
-
I --> A
|
|
324
|
-
A --> T & I
|
|
325
|
-
K --> T
|
|
326
|
-
C --> T
|
|
327
|
-
U --> T
|
|
328
|
-
O --> T
|
|
444
|
+
T --> F & K & C & U & O & E & FB
|
|
445
|
+
F --> I & T & E & FB
|
|
446
|
+
I --> A & E & FB
|
|
447
|
+
A --> T & I & E & FB
|
|
448
|
+
K --> T & E & FB
|
|
449
|
+
C --> T & E & FB
|
|
450
|
+
U --> T & E & FB
|
|
451
|
+
O --> T & E & FB
|
|
452
|
+
E --> T & FB
|
|
453
|
+
FB --> T & E
|
|
329
454
|
```
|
|
330
455
|
|
|
331
456
|
### Estrutura de Componentes
|
|
@@ -417,6 +542,8 @@ client_templates/
|
|
|
417
542
|
| **Confirmation** | Valida hipóteses com respostas sim/não |
|
|
418
543
|
| **Usage** | Responde dúvidas sobre uso do sistema |
|
|
419
544
|
| **Onboarding** | Acolhe novos usuários e guia cadastro |
|
|
545
|
+
| **Escalation** | Transfere para atendimento humano quando necessário |
|
|
546
|
+
| **Feedback** | Registra dúvidas, feedbacks, reclamações e sugestões |
|
|
420
547
|
|
|
421
548
|
---
|
|
422
549
|
|
|
@@ -427,6 +554,7 @@ from atendentepro import (
|
|
|
427
554
|
create_triage_agent,
|
|
428
555
|
create_flow_agent,
|
|
429
556
|
create_interview_agent,
|
|
557
|
+
create_escalation_agent,
|
|
430
558
|
)
|
|
431
559
|
|
|
432
560
|
# Criar agente de triagem customizado
|
|
@@ -440,8 +568,23 @@ flow = create_flow_agent(
|
|
|
440
568
|
flow_keywords="- Vendas: 'preço'\n- Suporte: 'erro'",
|
|
441
569
|
)
|
|
442
570
|
|
|
443
|
-
#
|
|
444
|
-
|
|
571
|
+
# Criar agente de escalação para transferência humana
|
|
572
|
+
escalation = create_escalation_agent(
|
|
573
|
+
escalation_channels="Telefone: 0800-123-456 (Seg-Sex 8h-18h)",
|
|
574
|
+
)
|
|
575
|
+
|
|
576
|
+
# Criar agente de feedback para registrar tickets
|
|
577
|
+
feedback = create_feedback_agent(
|
|
578
|
+
protocol_prefix="SAC",
|
|
579
|
+
email_brand_color="#660099",
|
|
580
|
+
email_brand_name="Minha Empresa",
|
|
581
|
+
)
|
|
582
|
+
|
|
583
|
+
# Configurar handoffs (todos podem escalar ou registrar feedback)
|
|
584
|
+
triage.handoffs = [flow, escalation, feedback]
|
|
585
|
+
flow.handoffs = [triage, escalation, feedback]
|
|
586
|
+
escalation.handoffs = [triage, feedback]
|
|
587
|
+
feedback.handoffs = [triage, escalation]
|
|
445
588
|
```
|
|
446
589
|
|
|
447
590
|
---
|
|
@@ -456,12 +599,15 @@ mkdir -p client_templates/meu_cliente
|
|
|
456
599
|
|
|
457
600
|
### Passo 2: Criar os Arquivos de Configuração YAML
|
|
458
601
|
|
|
459
|
-
Copie do `standard/` e customize:
|
|
602
|
+
Copie do template `standard/` (localizado em `templates/standard/`) e customize:
|
|
460
603
|
|
|
461
604
|
```bash
|
|
462
|
-
cp
|
|
605
|
+
cp templates/standard/*.yaml client_templates/meu_cliente/
|
|
463
606
|
```
|
|
464
607
|
|
|
608
|
+
> **Nota:** O template `standard` está em `templates/standard/` e serve como exemplo genérico.
|
|
609
|
+
> Suas configurações de cliente devem ficar em `client_templates/`.
|
|
610
|
+
|
|
465
611
|
### Passo 3: Configurar o Triage (triage_config.yaml)
|
|
466
612
|
|
|
467
613
|
Define as palavras-chave para identificar a intenção do usuário:
|
|
@@ -640,7 +786,412 @@ def buscar_produto(codigo: str = "", nome: str = "") -> str:
|
|
|
640
786
|
return "\n".join([f"- {r['nome']} (Cód: {r['codigo']})" for r in resultados])
|
|
641
787
|
```
|
|
642
788
|
|
|
643
|
-
### Passo 9:
|
|
789
|
+
### Passo 9: Configurar Escalation (Opcional - escalation_config.yaml)
|
|
790
|
+
|
|
791
|
+
O **Escalation Agent** permite transferir para atendimento humano quando:
|
|
792
|
+
- O usuário solicita explicitamente ("quero falar com um humano")
|
|
793
|
+
- O tópico não é coberto pelo sistema
|
|
794
|
+
- O agente não consegue resolver após múltiplas tentativas
|
|
795
|
+
- O usuário demonstra frustração
|
|
796
|
+
|
|
797
|
+
#### Configuração YAML Completa
|
|
798
|
+
|
|
799
|
+
```yaml
|
|
800
|
+
# escalation_config.yaml
|
|
801
|
+
name: "Escalation Agent"
|
|
802
|
+
|
|
803
|
+
description: >
|
|
804
|
+
Transfere para atendimento humano quando necessário.
|
|
805
|
+
|
|
806
|
+
# =============================================================================
|
|
807
|
+
# Triggers - Situações que ativam a escalação
|
|
808
|
+
# =============================================================================
|
|
809
|
+
triggers:
|
|
810
|
+
# Quando o usuário pede explicitamente
|
|
811
|
+
explicit_request:
|
|
812
|
+
- "quero falar com um humano"
|
|
813
|
+
- "atendente humano"
|
|
814
|
+
- "falar com uma pessoa"
|
|
815
|
+
- "transferir para atendimento"
|
|
816
|
+
- "pessoa de verdade"
|
|
817
|
+
|
|
818
|
+
# Indicadores de frustração
|
|
819
|
+
frustration:
|
|
820
|
+
- "você não está me ajudando"
|
|
821
|
+
- "isso não resolve"
|
|
822
|
+
- "já tentei isso"
|
|
823
|
+
- "não funciona"
|
|
824
|
+
- "estou perdendo tempo"
|
|
825
|
+
|
|
826
|
+
# Tópicos que requerem humano
|
|
827
|
+
topics_requiring_human:
|
|
828
|
+
- "questão jurídica"
|
|
829
|
+
- "cancelar contrato"
|
|
830
|
+
- "dados pessoais"
|
|
831
|
+
- "LGPD"
|
|
832
|
+
- "emergência"
|
|
833
|
+
|
|
834
|
+
# =============================================================================
|
|
835
|
+
# Canais de Atendimento
|
|
836
|
+
# =============================================================================
|
|
837
|
+
channels:
|
|
838
|
+
phone:
|
|
839
|
+
enabled: true
|
|
840
|
+
number: "0800-123-4567"
|
|
841
|
+
description: "Telefone"
|
|
842
|
+
hours: "Seg-Sex 8h-18h"
|
|
843
|
+
|
|
844
|
+
email:
|
|
845
|
+
enabled: true
|
|
846
|
+
address: "atendimento@empresa.com"
|
|
847
|
+
description: "Email"
|
|
848
|
+
sla: "Resposta em até 24h úteis"
|
|
849
|
+
|
|
850
|
+
whatsapp:
|
|
851
|
+
enabled: true
|
|
852
|
+
number: "(11) 99999-9999"
|
|
853
|
+
description: "WhatsApp"
|
|
854
|
+
hours: "Seg-Sex 9h-18h"
|
|
855
|
+
|
|
856
|
+
chat:
|
|
857
|
+
enabled: false
|
|
858
|
+
url: ""
|
|
859
|
+
description: "Chat ao vivo"
|
|
860
|
+
|
|
861
|
+
# =============================================================================
|
|
862
|
+
# Horário de Atendimento
|
|
863
|
+
# =============================================================================
|
|
864
|
+
business_hours:
|
|
865
|
+
start: 8
|
|
866
|
+
end: 18
|
|
867
|
+
days:
|
|
868
|
+
- monday
|
|
869
|
+
- tuesday
|
|
870
|
+
- wednesday
|
|
871
|
+
- thursday
|
|
872
|
+
- friday
|
|
873
|
+
timezone: "America/Sao_Paulo"
|
|
874
|
+
|
|
875
|
+
# =============================================================================
|
|
876
|
+
# Classificação de Prioridade Automática
|
|
877
|
+
# =============================================================================
|
|
878
|
+
priority:
|
|
879
|
+
urgent:
|
|
880
|
+
- "urgente"
|
|
881
|
+
- "emergência"
|
|
882
|
+
- "crítico"
|
|
883
|
+
- "bloqueado"
|
|
884
|
+
high:
|
|
885
|
+
- "reclamação"
|
|
886
|
+
- "insatisfeito"
|
|
887
|
+
- "problema grave"
|
|
888
|
+
default: "normal"
|
|
889
|
+
|
|
890
|
+
# =============================================================================
|
|
891
|
+
# Notificações
|
|
892
|
+
# =============================================================================
|
|
893
|
+
notifications:
|
|
894
|
+
webhook:
|
|
895
|
+
enabled: false
|
|
896
|
+
url: "" # Configure via ESCALATION_WEBHOOK_URL
|
|
897
|
+
email_team:
|
|
898
|
+
enabled: true
|
|
899
|
+
recipients:
|
|
900
|
+
- "equipe@empresa.com"
|
|
901
|
+
|
|
902
|
+
# =============================================================================
|
|
903
|
+
# Mensagens Customizadas
|
|
904
|
+
# =============================================================================
|
|
905
|
+
messages:
|
|
906
|
+
greeting: >
|
|
907
|
+
Entendo que você precisa de um atendimento mais especializado.
|
|
908
|
+
Vou transferir para um de nossos atendentes.
|
|
909
|
+
|
|
910
|
+
collecting_info: >
|
|
911
|
+
Para agilizar o atendimento, preciso de algumas informações.
|
|
912
|
+
|
|
913
|
+
confirmation: >
|
|
914
|
+
Pronto! Um atendente humano entrará em contato em breve.
|
|
915
|
+
Guarde o protocolo para acompanhamento.
|
|
916
|
+
|
|
917
|
+
out_of_hours: >
|
|
918
|
+
Nosso atendimento humano funciona de Segunda a Sexta, das 8h às 18h.
|
|
919
|
+
Você pode deixar seus dados que retornaremos no próximo dia útil.
|
|
920
|
+
|
|
921
|
+
apology: >
|
|
922
|
+
Peço desculpas se não consegui resolver sua questão.
|
|
923
|
+
Um atendente especializado poderá ajudá-lo melhor.
|
|
924
|
+
```
|
|
925
|
+
|
|
926
|
+
#### Variáveis de Ambiente para Escalation
|
|
927
|
+
|
|
928
|
+
| Variável | Descrição |
|
|
929
|
+
|----------|-----------|
|
|
930
|
+
| `ESCALATION_WEBHOOK_URL` | URL para notificar sistemas externos (Slack, Teams) |
|
|
931
|
+
| `ESCALATION_HOUR_START` | Hora de início do atendimento (padrão: 8) |
|
|
932
|
+
| `ESCALATION_HOUR_END` | Hora de fim do atendimento (padrão: 18) |
|
|
933
|
+
|
|
934
|
+
#### Uso Programático
|
|
935
|
+
|
|
936
|
+
```python
|
|
937
|
+
# Com configuração via parâmetros
|
|
938
|
+
network = create_standard_network(
|
|
939
|
+
templates_root=Path("./client_templates"),
|
|
940
|
+
client="meu_cliente",
|
|
941
|
+
include_escalation=True,
|
|
942
|
+
escalation_channels="""
|
|
943
|
+
📞 **Telefone:** 0800-123-4567 (Seg-Sex 8h-18h)
|
|
944
|
+
📧 **Email:** atendimento@empresa.com
|
|
945
|
+
💬 **WhatsApp:** (11) 99999-9999
|
|
946
|
+
""",
|
|
947
|
+
)
|
|
948
|
+
|
|
949
|
+
# Sem escalação
|
|
950
|
+
network = create_standard_network(
|
|
951
|
+
templates_root=Path("./client_templates"),
|
|
952
|
+
client="meu_cliente",
|
|
953
|
+
include_escalation=False,
|
|
954
|
+
)
|
|
955
|
+
|
|
956
|
+
# Criar agente standalone
|
|
957
|
+
from atendentepro import create_escalation_agent
|
|
958
|
+
|
|
959
|
+
escalation = create_escalation_agent(
|
|
960
|
+
escalation_channels="Telefone: 0800-123-4567",
|
|
961
|
+
name="Suporte Humano",
|
|
962
|
+
)
|
|
963
|
+
```
|
|
964
|
+
|
|
965
|
+
### Passo 10: Configurar Feedback (Opcional - feedback_config.yaml)
|
|
966
|
+
|
|
967
|
+
O **Feedback Agent** permite registrar:
|
|
968
|
+
- ❓ **Dúvidas** que precisam de pesquisa
|
|
969
|
+
- 💬 **Feedbacks** sobre produtos/serviços
|
|
970
|
+
- 📢 **Reclamações** formais
|
|
971
|
+
- 💡 **Sugestões** de melhoria
|
|
972
|
+
- ⭐ **Elogios** e agradecimentos
|
|
973
|
+
- ⚠️ **Problemas** técnicos
|
|
974
|
+
|
|
975
|
+
#### Configuração YAML Completa
|
|
976
|
+
|
|
977
|
+
```yaml
|
|
978
|
+
# feedback_config.yaml
|
|
979
|
+
name: "Feedback Agent"
|
|
980
|
+
|
|
981
|
+
description: >
|
|
982
|
+
Registra dúvidas, feedbacks, reclamações, sugestões e elogios
|
|
983
|
+
através de tickets com protocolo de acompanhamento.
|
|
984
|
+
|
|
985
|
+
# =============================================================================
|
|
986
|
+
# Configuração de Protocolo
|
|
987
|
+
# =============================================================================
|
|
988
|
+
|
|
989
|
+
# Prefixo do protocolo (ex: SAC-20240106-ABC123, TKT-20240106-XYZ789)
|
|
990
|
+
protocol_prefix: "SAC"
|
|
991
|
+
|
|
992
|
+
# =============================================================================
|
|
993
|
+
# Tipos de Ticket Habilitados
|
|
994
|
+
# =============================================================================
|
|
995
|
+
ticket_types:
|
|
996
|
+
- name: "duvida"
|
|
997
|
+
label: "Dúvida"
|
|
998
|
+
icon: "❓"
|
|
999
|
+
description: "Pergunta que precisa de pesquisa ou análise"
|
|
1000
|
+
default_priority: "normal"
|
|
1001
|
+
|
|
1002
|
+
- name: "feedback"
|
|
1003
|
+
label: "Feedback"
|
|
1004
|
+
icon: "💬"
|
|
1005
|
+
description: "Opinião sobre produto ou serviço"
|
|
1006
|
+
default_priority: "normal"
|
|
1007
|
+
|
|
1008
|
+
- name: "reclamacao"
|
|
1009
|
+
label: "Reclamação"
|
|
1010
|
+
icon: "📢"
|
|
1011
|
+
description: "Reclamação formal"
|
|
1012
|
+
default_priority: "alta"
|
|
1013
|
+
|
|
1014
|
+
- name: "sugestao"
|
|
1015
|
+
label: "Sugestão"
|
|
1016
|
+
icon: "💡"
|
|
1017
|
+
description: "Sugestão de melhoria"
|
|
1018
|
+
default_priority: "baixa"
|
|
1019
|
+
|
|
1020
|
+
- name: "elogio"
|
|
1021
|
+
label: "Elogio"
|
|
1022
|
+
icon: "⭐"
|
|
1023
|
+
description: "Elogio ou agradecimento"
|
|
1024
|
+
default_priority: "baixa"
|
|
1025
|
+
|
|
1026
|
+
- name: "problema"
|
|
1027
|
+
label: "Problema"
|
|
1028
|
+
icon: "⚠️"
|
|
1029
|
+
description: "Problema técnico ou bug"
|
|
1030
|
+
default_priority: "alta"
|
|
1031
|
+
|
|
1032
|
+
# =============================================================================
|
|
1033
|
+
# Níveis de Prioridade
|
|
1034
|
+
# =============================================================================
|
|
1035
|
+
priorities:
|
|
1036
|
+
- name: "baixa"
|
|
1037
|
+
label: "Baixa"
|
|
1038
|
+
icon: "🟢"
|
|
1039
|
+
sla_hours: 72
|
|
1040
|
+
description: "Pode aguardar alguns dias"
|
|
1041
|
+
|
|
1042
|
+
- name: "normal"
|
|
1043
|
+
label: "Normal"
|
|
1044
|
+
icon: "🟡"
|
|
1045
|
+
sla_hours: 24
|
|
1046
|
+
description: "Atendimento padrão"
|
|
1047
|
+
|
|
1048
|
+
- name: "alta"
|
|
1049
|
+
label: "Alta"
|
|
1050
|
+
icon: "🟠"
|
|
1051
|
+
sla_hours: 8
|
|
1052
|
+
description: "Requer atenção prioritária"
|
|
1053
|
+
|
|
1054
|
+
- name: "urgente"
|
|
1055
|
+
label: "Urgente"
|
|
1056
|
+
icon: "🔴"
|
|
1057
|
+
sla_hours: 2
|
|
1058
|
+
description: "Crítico, ação imediata"
|
|
1059
|
+
|
|
1060
|
+
# =============================================================================
|
|
1061
|
+
# Categorias (opcional)
|
|
1062
|
+
# =============================================================================
|
|
1063
|
+
categories:
|
|
1064
|
+
- "Produto"
|
|
1065
|
+
- "Serviço"
|
|
1066
|
+
- "Atendimento"
|
|
1067
|
+
- "Sistema"
|
|
1068
|
+
- "Financeiro"
|
|
1069
|
+
- "Outro"
|
|
1070
|
+
|
|
1071
|
+
# =============================================================================
|
|
1072
|
+
# Configuração de Email
|
|
1073
|
+
# =============================================================================
|
|
1074
|
+
email:
|
|
1075
|
+
enabled: true
|
|
1076
|
+
brand_color: "#660099" # Cor da marca (hexadecimal)
|
|
1077
|
+
brand_name: "Minha Empresa" # Nome no email
|
|
1078
|
+
sla_message: "Retornaremos em até 24h úteis."
|
|
1079
|
+
notify_team: true # Enviar cópia para equipe
|
|
1080
|
+
|
|
1081
|
+
# =============================================================================
|
|
1082
|
+
# Mensagens Customizadas
|
|
1083
|
+
# =============================================================================
|
|
1084
|
+
messages:
|
|
1085
|
+
greeting: >
|
|
1086
|
+
Posso ajudá-lo a registrar sua solicitação.
|
|
1087
|
+
Qual tipo de ticket você gostaria de abrir?
|
|
1088
|
+
|
|
1089
|
+
confirmation: >
|
|
1090
|
+
Seu chamado foi registrado com sucesso!
|
|
1091
|
+
Guarde o protocolo para acompanhamento.
|
|
1092
|
+
|
|
1093
|
+
email_sent: >
|
|
1094
|
+
Enviamos um email de confirmação para você.
|
|
1095
|
+
|
|
1096
|
+
validation_error_email: >
|
|
1097
|
+
Por favor, informe um email válido para que possamos responder.
|
|
1098
|
+
|
|
1099
|
+
# =============================================================================
|
|
1100
|
+
# Campos Obrigatórios vs Opcionais
|
|
1101
|
+
# =============================================================================
|
|
1102
|
+
fields:
|
|
1103
|
+
required:
|
|
1104
|
+
- tipo
|
|
1105
|
+
- descricao
|
|
1106
|
+
- email_usuario
|
|
1107
|
+
optional:
|
|
1108
|
+
- nome_usuario
|
|
1109
|
+
- telefone_usuario
|
|
1110
|
+
- prioridade
|
|
1111
|
+
- categoria
|
|
1112
|
+
|
|
1113
|
+
# =============================================================================
|
|
1114
|
+
# Regras de Priorização Automática
|
|
1115
|
+
# =============================================================================
|
|
1116
|
+
auto_priority:
|
|
1117
|
+
urgent:
|
|
1118
|
+
- "urgente"
|
|
1119
|
+
- "emergência"
|
|
1120
|
+
- "parou de funcionar"
|
|
1121
|
+
high:
|
|
1122
|
+
- "reclamação"
|
|
1123
|
+
- "problema grave"
|
|
1124
|
+
- "prejuízo"
|
|
1125
|
+
high_priority_types:
|
|
1126
|
+
- "reclamacao"
|
|
1127
|
+
- "problema"
|
|
1128
|
+
```
|
|
1129
|
+
|
|
1130
|
+
#### Variáveis de Ambiente para Feedback
|
|
1131
|
+
|
|
1132
|
+
| Variável | Descrição |
|
|
1133
|
+
|----------|-----------|
|
|
1134
|
+
| `SMTP_HOST` | Servidor SMTP (padrão: smtp.gmail.com) |
|
|
1135
|
+
| `SMTP_PORT` | Porta SMTP (padrão: 587) |
|
|
1136
|
+
| `SMTP_USER` | Usuário SMTP |
|
|
1137
|
+
| `SMTP_PASSWORD` | Senha SMTP |
|
|
1138
|
+
| `SMTP_FROM` | Email remetente |
|
|
1139
|
+
| `FEEDBACK_EMAIL_DESTINO` | Email da equipe para receber notificações |
|
|
1140
|
+
|
|
1141
|
+
#### Uso Programático
|
|
1142
|
+
|
|
1143
|
+
```python
|
|
1144
|
+
# Com configuração via parâmetros
|
|
1145
|
+
network = create_standard_network(
|
|
1146
|
+
templates_root=Path("./client_templates"),
|
|
1147
|
+
client="meu_cliente",
|
|
1148
|
+
include_feedback=True,
|
|
1149
|
+
feedback_protocol_prefix="SAC",
|
|
1150
|
+
feedback_brand_color="#660099",
|
|
1151
|
+
feedback_brand_name="Minha Empresa",
|
|
1152
|
+
)
|
|
1153
|
+
|
|
1154
|
+
# Sem feedback
|
|
1155
|
+
network = create_standard_network(
|
|
1156
|
+
templates_root=Path("./client_templates"),
|
|
1157
|
+
client="meu_cliente",
|
|
1158
|
+
include_feedback=False,
|
|
1159
|
+
)
|
|
1160
|
+
|
|
1161
|
+
# Criar agente standalone
|
|
1162
|
+
from atendentepro import create_feedback_agent
|
|
1163
|
+
|
|
1164
|
+
feedback = create_feedback_agent(
|
|
1165
|
+
protocol_prefix="SAC",
|
|
1166
|
+
email_brand_color="#660099",
|
|
1167
|
+
email_brand_name="Minha Empresa",
|
|
1168
|
+
email_sla_message="Retornaremos em até 24h úteis.",
|
|
1169
|
+
name="SAC",
|
|
1170
|
+
)
|
|
1171
|
+
```
|
|
1172
|
+
|
|
1173
|
+
---
|
|
1174
|
+
|
|
1175
|
+
### Diferença entre Escalation e Feedback
|
|
1176
|
+
|
|
1177
|
+
| Aspecto | Escalation | Feedback |
|
|
1178
|
+
|---------|------------|----------|
|
|
1179
|
+
| **Propósito** | Transferir para humano **agora** | Registrar para resposta **posterior** |
|
|
1180
|
+
| **Urgência** | Imediata | Pode aguardar |
|
|
1181
|
+
| **Canal** | Telefone, chat ao vivo | Email, ticket |
|
|
1182
|
+
| **Protocolo** | ESC-YYYYMMDD-XXXXXX | TKT/SAC-YYYYMMDD-XXXXXX |
|
|
1183
|
+
| **Quando usar** | "Quero falar com alguém" | "Tenho uma dúvida/sugestão" |
|
|
1184
|
+
| **Horário** | Respeita horário comercial | 24/7 (registro) |
|
|
1185
|
+
|
|
1186
|
+
```mermaid
|
|
1187
|
+
flowchart LR
|
|
1188
|
+
USER[Usuário] --> |"Problema urgente<br/>Falar com humano"| ESC[Escalation Agent]
|
|
1189
|
+
USER --> |"Dúvida, sugestão<br/>Feedback"| FEED[Feedback Agent]
|
|
1190
|
+
ESC --> |Protocolo ESC| HUMANO[Atendente Humano]
|
|
1191
|
+
FEED --> |Protocolo TKT| EMAIL[Email + Ticket]
|
|
1192
|
+
```
|
|
1193
|
+
|
|
1194
|
+
### Passo 11: Criar Rede Específica (Opcional)
|
|
644
1195
|
|
|
645
1196
|
Se precisar de lógica customizada:
|
|
646
1197
|
|
|
@@ -719,26 +1270,47 @@ network = create_meu_cliente_network(
|
|
|
719
1270
|
|
|
720
1271
|
```
|
|
721
1272
|
client_templates/meu_cliente/
|
|
722
|
-
├── __init__.py
|
|
723
|
-
├── network.py
|
|
724
|
-
├── tools.py
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
├──
|
|
728
|
-
├──
|
|
729
|
-
├──
|
|
730
|
-
├──
|
|
731
|
-
├──
|
|
732
|
-
├──
|
|
733
|
-
├──
|
|
1273
|
+
├── __init__.py # (Opcional) Pacote Python
|
|
1274
|
+
├── network.py # (Opcional) Rede específica
|
|
1275
|
+
├── tools.py # (Opcional) Tools customizadas
|
|
1276
|
+
│
|
|
1277
|
+
│ # Configurações de Agentes (YAML)
|
|
1278
|
+
├── triage_config.yaml # ✅ Obrigatório - Classificação inicial
|
|
1279
|
+
├── flow_config.yaml # ✅ Recomendado - Opções/menu
|
|
1280
|
+
├── interview_config.yaml # ✅ Recomendado - Coleta de dados
|
|
1281
|
+
├── answer_config.yaml # Opcional - Resposta final
|
|
1282
|
+
├── knowledge_config.yaml # Opcional - Base de conhecimento
|
|
1283
|
+
├── confirmation_config.yaml # Opcional - Validação sim/não
|
|
1284
|
+
├── onboarding_config.yaml # Opcional - Cadastro novos usuários
|
|
1285
|
+
├── escalation_config.yaml # ✅ Recomendado - Transferência humana
|
|
1286
|
+
├── feedback_config.yaml # ✅ Recomendado - Tickets/SAC
|
|
1287
|
+
├── guardrails_config.yaml # ✅ Recomendado - Políticas de segurança
|
|
1288
|
+
│
|
|
1289
|
+
│ # Dados (opcionais)
|
|
1290
|
+
├── data/ # Dados estruturados
|
|
734
1291
|
│ └── produtos.csv
|
|
735
|
-
└── knowledge_documentos/
|
|
1292
|
+
└── knowledge_documentos/ # Documentos para RAG
|
|
736
1293
|
├── docs/
|
|
737
1294
|
│ └── manual.pdf
|
|
738
1295
|
└── embedding/
|
|
739
1296
|
└── embeddings.pkl
|
|
740
1297
|
```
|
|
741
1298
|
|
|
1299
|
+
#### Arquivos YAML por Agente
|
|
1300
|
+
|
|
1301
|
+
| Arquivo | Agente | Obrigatório | Descrição |
|
|
1302
|
+
|---------|--------|-------------|-----------|
|
|
1303
|
+
| `triage_config.yaml` | Triage | ✅ Sim | Keywords para classificação |
|
|
1304
|
+
| `flow_config.yaml` | Flow | Recomendado | Opções de menu/tópicos |
|
|
1305
|
+
| `interview_config.yaml` | Interview | Recomendado | Perguntas para coleta |
|
|
1306
|
+
| `answer_config.yaml` | Answer | Opcional | Template de resposta |
|
|
1307
|
+
| `knowledge_config.yaml` | Knowledge | Opcional | Docs RAG + fontes dados |
|
|
1308
|
+
| `confirmation_config.yaml` | Confirmation | Opcional | Validação de hipóteses |
|
|
1309
|
+
| `onboarding_config.yaml` | Onboarding | Opcional | Campos de cadastro |
|
|
1310
|
+
| `escalation_config.yaml` | Escalation | Recomendado | Canais e triggers |
|
|
1311
|
+
| `feedback_config.yaml` | Feedback | Recomendado | Tipos ticket e email |
|
|
1312
|
+
| `guardrails_config.yaml` | Todos | Recomendado | Escopo e restrições |
|
|
1313
|
+
|
|
742
1314
|
---
|
|
743
1315
|
|
|
744
1316
|
## 🌐 Redes Pré-configuradas
|
|
@@ -754,14 +1326,19 @@ network = create_standard_network(
|
|
|
754
1326
|
)
|
|
755
1327
|
```
|
|
756
1328
|
|
|
757
|
-
Configuração padrão de handoffs:
|
|
758
|
-
- Triage → Flow, Confirmation, Knowledge, Usage
|
|
759
|
-
- Flow → Interview, Triage
|
|
760
|
-
- Interview → Answer
|
|
761
|
-
- Answer → Triage,
|
|
762
|
-
- Confirmation → Triage
|
|
763
|
-
- Knowledge → Triage
|
|
764
|
-
- Usage → Triage
|
|
1329
|
+
Configuração padrão de handoffs (com Escalation e Feedback habilitados):
|
|
1330
|
+
- Triage → Flow, Confirmation, Knowledge, Usage, Onboarding, **Escalation**, **Feedback**
|
|
1331
|
+
- Flow → Interview, Triage, **Escalation**, **Feedback**
|
|
1332
|
+
- Interview → Answer, **Escalation**, **Feedback**
|
|
1333
|
+
- Answer → Triage, **Escalation**, **Feedback**
|
|
1334
|
+
- Confirmation → Triage, **Escalation**, **Feedback**
|
|
1335
|
+
- Knowledge → Triage, **Escalation**, **Feedback**
|
|
1336
|
+
- Usage → Triage, **Escalation**, **Feedback**
|
|
1337
|
+
- Onboarding → Triage, **Escalation**, **Feedback**
|
|
1338
|
+
- **Escalation → Triage, Feedback**
|
|
1339
|
+
- **Feedback → Triage, Escalation**
|
|
1340
|
+
|
|
1341
|
+
> 💡 **Todos os agentes** podem escalar para atendimento humano ou registrar feedback!
|
|
765
1342
|
|
|
766
1343
|
### Rede Customizada
|
|
767
1344
|
|