feat: adiciona 12 plugins Descomplicar ao marketplace
Plugins: automacao, crm-ops, design-media, dev-tools, gestao, infraestrutura, marketing, negocio, perfex-dev, project-manager, wordpress + hello-plugin (existente). Totais: 83 skills, 44 agents, 12 datasets.json Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
110
automacao/skills/moloni-api/SKILL.md
Normal file
110
automacao/skills/moloni-api/SKILL.md
Normal file
@@ -0,0 +1,110 @@
|
||||
---
|
||||
name: moloni-api
|
||||
description: >-
|
||||
Moloni API v2 para facturacao portuguesa - autenticacao, documentos, clientes, produtos.
|
||||
Usar quando trabalhar com Moloni API, criar/consultar facturas, recibos, notas de credito,
|
||||
clientes, ou qualquer operacao de facturacao via Moloni. Triggers: moloni, factura, recibo,
|
||||
nota de credito, billing, invoicing, facturacao portuguesa.
|
||||
---
|
||||
|
||||
# Moloni API v2
|
||||
|
||||
Operações de facturação portuguesa via Moloni API. MCP server disponível em `/opt/moloni/`.
|
||||
|
||||
## 4 Regras Críticas
|
||||
|
||||
1. **`access_token` na QUERY STRING** - Nunca no POST body (causa 403)
|
||||
2. **Endpoints camelCase** - `creditNotes/`, `invoiceReceipts/`, `documentSets/`
|
||||
3. **Arrays form-encoded** - `payments[0][payment_method_id]`, nunca `json.dumps()`
|
||||
4. **`net_value` = Total COM IVA** - Nome enganador! Desk `total` = Moloni `net_value`. Base = `net_value / 1.23`
|
||||
|
||||
## Autenticação
|
||||
|
||||
```python
|
||||
# Grant = GET (não POST!)
|
||||
r = requests.get('https://api.moloni.pt/v2/grant/', params={
|
||||
'grant_type': 'password',
|
||||
'client_id': 'evidentedespertar',
|
||||
'client_secret': 'aa48e86bd574bf81ca2d7f624c8b5de0284fb97d',
|
||||
'username': 'contabilidade@descomplicar.pt',
|
||||
'password': '6EMVh^RHA)d5k!%s' # %s literal, sem f-string!
|
||||
})
|
||||
token = r.json()['access_token']
|
||||
```
|
||||
|
||||
## Empresa
|
||||
|
||||
| Campo | Valor |
|
||||
|-------|-------|
|
||||
| Company ID | 69473 |
|
||||
| Série D | document_set_id: 630300 |
|
||||
| Transf. Bancária | payment_method_id: 400878 |
|
||||
|
||||
## Formato Chamadas
|
||||
|
||||
```python
|
||||
# CORRECTO
|
||||
r = requests.post('https://api.moloni.pt/v2/invoices/getAll/',
|
||||
params={'access_token': token}, # token aqui!
|
||||
data={'company_id': '69473', 'qty': '50'} # dados aqui
|
||||
)
|
||||
```
|
||||
|
||||
## Workflows Comuns
|
||||
|
||||
### Listar facturas
|
||||
```python
|
||||
data = {'company_id': '69473', 'document_set_id': '630300', 'qty': '50', 'offset': '0'}
|
||||
```
|
||||
|
||||
### Criar recibo
|
||||
```python
|
||||
data = {
|
||||
'company_id': '69473',
|
||||
'date': '2026-02-05',
|
||||
'document_set_id': '630300',
|
||||
'customer_id': str(customer_id),
|
||||
'net_value': str(valor),
|
||||
'associated_documents[0][associated_id]': str(invoice_document_id),
|
||||
'associated_documents[0][value]': str(valor),
|
||||
'payments[0][payment_method_id]': '400878',
|
||||
'payments[0][date]': '2026-02-05',
|
||||
'payments[0][value]': str(valor),
|
||||
'status': '1'
|
||||
}
|
||||
r = requests.post('.../receipts/insert/', params={'access_token': token}, data=data)
|
||||
```
|
||||
|
||||
### Verificar reconciliação
|
||||
Antes de criar recibo, verificar `reconciled_value` e `reverse_associated_documents` da factura.
|
||||
|
||||
## Restrições
|
||||
|
||||
- Data mínima documentos: **>= 2025-10-28** (período AT)
|
||||
- Para facturas antigas: usar data actual no recibo
|
||||
|
||||
## Erros Comuns
|
||||
|
||||
| Erro | Causa | Solução |
|
||||
|------|-------|---------|
|
||||
| 403 Forbidden | Token no body | Mover para `params=` |
|
||||
| 404 Not Found | Case errado ou sem `/` | Verificar camelCase + trailing slash |
|
||||
| `["12 date >= ..."]` | Data antiga | Usar data actual |
|
||||
| `["10 associated_id"]` | Factura já reconciliada | Verificar `reconciled_value` |
|
||||
|
||||
## MCP vs API Directa
|
||||
|
||||
O MCP Moloni (`mcp__moloni__*`) gere tokens automaticamente. Para operações pontuais ou scripts batch, usar API directa via SSH no mcp-hub.
|
||||
|
||||
## Sandbox (Desenvolvimento)
|
||||
|
||||
Para testes sem afectar dados reais: https://www.moloni.pt/dev/sandbox/
|
||||
|
||||
A sandbox fornece um ambiente isolado com dados fictícios para desenvolvimento e testes de integração.
|
||||
|
||||
## Referências
|
||||
|
||||
- **[references/api-reference.md](references/api-reference.md)** - Credenciais, formatos, mapeamento clientes, erros
|
||||
- **[references/endpoints.md](references/endpoints.md)** - Catálogo completo de endpoints
|
||||
- **Docs oficiais:** https://www.moloni.pt/dev/endpoints/
|
||||
- **Sandbox:** https://www.moloni.pt/dev/sandbox/
|
||||
301
automacao/skills/moloni-api/references/api-reference.md
Normal file
301
automacao/skills/moloni-api/references/api-reference.md
Normal file
@@ -0,0 +1,301 @@
|
||||
# Moloni API v2 - Reference
|
||||
|
||||
## Empresa Descomplicar
|
||||
|
||||
| Campo | Valor |
|
||||
|-------|-------|
|
||||
| Company ID | 69473 |
|
||||
| Empresa | Evidente Despertar, Lda |
|
||||
| Client ID | evidentedespertar |
|
||||
| NIF | 516557498 |
|
||||
| MCP Server | `/opt/moloni/` em mcp-hub |
|
||||
| Service | `moloni.service` (systemd) |
|
||||
| .env | `/opt/moloni/.env` |
|
||||
| Token storage | `/opt/moloni/.moloni/69473/.token_metadata.json` |
|
||||
|
||||
## Sandbox (Desenvolvimento/Testes)
|
||||
|
||||
Para testar integrações sem afectar dados reais: https://www.moloni.pt/dev/sandbox/
|
||||
|
||||
A sandbox fornece um ambiente isolado com dados fictícios. Usar sempre que:
|
||||
- Desenvolver novas integrações
|
||||
- Testar criação/modificação de documentos
|
||||
- Depurar erros de formato ou validação
|
||||
|
||||
## Autenticacao
|
||||
|
||||
### Password Grant (GET, nao POST!)
|
||||
|
||||
```python
|
||||
r = requests.get('https://api.moloni.pt/v2/grant/', params={
|
||||
'grant_type': 'password',
|
||||
'client_id': 'evidentedespertar',
|
||||
'client_secret': 'aa48e86bd574bf81ca2d7f624c8b5de0284fb97d',
|
||||
'username': 'contabilidade@descomplicar.pt',
|
||||
'password': '6EMVh^RHA)d5k!%s'
|
||||
})
|
||||
token = r.json()['access_token']
|
||||
```
|
||||
|
||||
### Refresh Token
|
||||
|
||||
```python
|
||||
r = requests.get('https://api.moloni.pt/v2/grant/', params={
|
||||
'grant_type': 'refresh_token',
|
||||
'client_id': 'evidentedespertar',
|
||||
'client_secret': 'aa48e86bd574bf81ca2d7f624c8b5de0284fb97d',
|
||||
'refresh_token': '<refresh_token>'
|
||||
})
|
||||
```
|
||||
|
||||
### Regras de Autenticacao
|
||||
|
||||
- Grant endpoint e **GET** (nao POST)
|
||||
- Password contem `%s` - em Python usar: `'6EMVh^RHA)d5k!%s'` (string literal, sem f-string)
|
||||
- Token expira em 3600 segundos (1 hora)
|
||||
- Refresh token nao expira mas so pode ser usado uma vez
|
||||
|
||||
## Formato das Chamadas API
|
||||
|
||||
### Regra Fundamental
|
||||
|
||||
```
|
||||
access_token -> QUERY STRING (params)
|
||||
dados -> POST BODY (data, form-urlencoded)
|
||||
```
|
||||
|
||||
### Exemplo Correcto
|
||||
|
||||
```python
|
||||
r = requests.post('https://api.moloni.pt/v2/invoices/getAll/',
|
||||
params={'access_token': token}, # token na query string
|
||||
data={'company_id': '69473', 'qty': '50'} # dados no body
|
||||
)
|
||||
```
|
||||
|
||||
### Exemplo INCORRECTO (causa 403 Forbidden)
|
||||
|
||||
```python
|
||||
# ERRADO - token no body causa 403!
|
||||
r = requests.post('https://api.moloni.pt/v2/invoices/getAll/',
|
||||
data={'company_id': '69473', 'access_token': token, 'qty': '50'}
|
||||
)
|
||||
```
|
||||
|
||||
## Endpoints Case-Sensitive
|
||||
|
||||
| Correcto (camelCase) | ERRADO (lowercase) |
|
||||
|---------------------|---------------------|
|
||||
| `creditNotes/` | `creditnotes/` |
|
||||
| `invoiceReceipts/` | `invoicereceipts/` |
|
||||
| `documentSets/` | `documentsets/` |
|
||||
| `paymentMethods/` | `paymentmethods/` |
|
||||
| `simplifiedInvoices/` | `simplifiedinvoices/` |
|
||||
| `debitNotes/` | `debitnotes/` |
|
||||
| `billsOfLading/` | `billsoflading/` |
|
||||
| `deliveryNotes/` | `deliverynotes/` |
|
||||
| `proFormaInvoices/` | `proformainvoices/` |
|
||||
|
||||
Endpoints simples (lowercase OK): `invoices/`, `receipts/`, `customers/`, `products/`, `taxes/`
|
||||
|
||||
Todos os endpoints precisam de trailing slash: `/v2/invoices/getAll/`
|
||||
|
||||
## Arrays Aninhados (Form-Encoded)
|
||||
|
||||
### Formato Correcto
|
||||
|
||||
```python
|
||||
data = {
|
||||
'company_id': '69473',
|
||||
'associated_documents[0][associated_id]': '595002190',
|
||||
'associated_documents[0][value]': '2361.60',
|
||||
'payments[0][payment_method_id]': '400878',
|
||||
'payments[0][date]': '2026-02-05',
|
||||
'payments[0][value]': '2361.60',
|
||||
}
|
||||
```
|
||||
|
||||
### Multiplos Items
|
||||
|
||||
```python
|
||||
data = {
|
||||
'products[0][product_id]': '123',
|
||||
'products[0][qty]': '2',
|
||||
'products[0][price]': '50.00',
|
||||
'products[1][product_id]': '456',
|
||||
'products[1][qty]': '1',
|
||||
'products[1][price]': '100.00',
|
||||
}
|
||||
```
|
||||
|
||||
### NUNCA Usar JSON.dumps()
|
||||
|
||||
```python
|
||||
# ERRADO - Moloni nao aceita JSON strings dentro de form data
|
||||
data = {
|
||||
'associated_documents': json.dumps([{'associated_id': 123, 'value': 50}])
|
||||
}
|
||||
```
|
||||
|
||||
## Restricoes de Datas
|
||||
|
||||
- Moloni tem data minima para criacao de documentos (periodo de comunicacao AT)
|
||||
- Actualmente: **>= 2025-10-28**
|
||||
- Para documentos com datas antigas, usar a data actual no recibo/documento
|
||||
- Erro retornado: `["12 date >= 2025-10-28"]`
|
||||
|
||||
## Series Documentais
|
||||
|
||||
| ID | Nome | Uso |
|
||||
|----|------|-----|
|
||||
| 630300 | D | Serie principal (facturas, recibos, NC) |
|
||||
| 118898 | (antiga) | Recibos antigos KCCG |
|
||||
|
||||
## Metodos de Pagamento
|
||||
|
||||
| ID | Nome |
|
||||
|----|------|
|
||||
| 400868 | Numerario |
|
||||
| 400873 | Cheque |
|
||||
| 400878 | Transferencia Bancaria |
|
||||
| 400883 | Multibanco |
|
||||
| 1569000 | Paypal |
|
||||
|
||||
## Endpoints por Tipo de Documento
|
||||
|
||||
Cada tipo de documento suporta: `count`, `getAll`, `getOne`, `insert`, `update`, `delete`
|
||||
|
||||
### Facturas (invoices/)
|
||||
|
||||
```
|
||||
POST /v2/invoices/getAll/ - Listar (qty, offset, document_set_id, customer_id, year)
|
||||
POST /v2/invoices/getOne/ - Detalhe (document_id OU document_set_id+number)
|
||||
POST /v2/invoices/insert/ - Criar
|
||||
```
|
||||
|
||||
### Recibos (receipts/)
|
||||
|
||||
```
|
||||
POST /v2/receipts/getAll/ - Listar
|
||||
POST /v2/receipts/getOne/ - Detalhe
|
||||
POST /v2/receipts/insert/ - Criar (requer: date, document_set_id, customer_id, net_value, associated_documents, payments)
|
||||
```
|
||||
|
||||
**Insert fields:**
|
||||
- `company_id` (int, required)
|
||||
- `date` (YYYY-MM-DD, required)
|
||||
- `document_set_id` (int, required)
|
||||
- `customer_id` (int, required)
|
||||
- `net_value` (float, required) - valor total do recibo
|
||||
- `associated_documents[]` - array com `associated_id` e `value`
|
||||
- `payments[]` - array com `payment_method_id`, `date`, `value`
|
||||
- `status` (0=rascunho, 1=fechado)
|
||||
- `notes` (string, opcional)
|
||||
|
||||
### Notas de Credito (creditNotes/)
|
||||
|
||||
```
|
||||
POST /v2/creditNotes/getAll/
|
||||
POST /v2/creditNotes/getOne/
|
||||
POST /v2/creditNotes/insert/
|
||||
```
|
||||
|
||||
### Clientes (customers/)
|
||||
|
||||
```
|
||||
POST /v2/customers/getAll/
|
||||
POST /v2/customers/getOne/
|
||||
POST /v2/customers/getBySearch/
|
||||
POST /v2/customers/getByVat/
|
||||
```
|
||||
|
||||
### Produtos (products/)
|
||||
|
||||
```
|
||||
POST /v2/products/getAll/
|
||||
POST /v2/products/getBySearch/
|
||||
POST /v2/products/getByReference/
|
||||
```
|
||||
|
||||
## Codigos de Erro Comuns
|
||||
|
||||
| Codigo | Significado |
|
||||
|--------|-------------|
|
||||
| 200 + `{"valid": 1}` | Sucesso |
|
||||
| 200 + `["12 date >= ..."]` | Data anterior ao periodo AT |
|
||||
| 200 + `["10 associated_id"]` | Documento associado invalido ou ja reconciliado |
|
||||
| 200 + `["2 value 0 null"]` | Valor invalido ou em falta |
|
||||
| 401 | Token expirado ou invalido |
|
||||
| 403 | App sem permissoes (access_token no body em vez de query string) |
|
||||
| 404 | Endpoint nao encontrado (verificar case-sensitivity e trailing slash) |
|
||||
|
||||
## Campos de Resposta (Documentos)
|
||||
|
||||
| Campo | Tipo | Descricao |
|
||||
|-------|------|-----------|
|
||||
| `document_id` | int | ID unico do documento |
|
||||
| `number` | int | Numero sequencial na serie |
|
||||
| `net_value` | float | **Total COM IVA** (Desk total). Para base sem IVA: net_value / 1.23. ATENCAO: nome enganador, NAO e base! |
|
||||
| `reconciled_value` | float | Valor ja reconciliado/pago |
|
||||
| `status` | int | 0=rascunho, 1=fechado |
|
||||
| `customer_id` | int | ID do cliente Moloni |
|
||||
| `document_set_id` | int | ID da serie documental |
|
||||
| `associated_documents` | array | Documentos associados (facturas num recibo) |
|
||||
| `reverse_associated_documents` | array | Documentos que referenciam este (recibos de uma factura) |
|
||||
| `payments` | array | Pagamentos registados |
|
||||
| `entity_name` | string | Nome do cliente |
|
||||
| `entity_vat` | string | NIF do cliente |
|
||||
|
||||
## MCP Tools Disponiveis
|
||||
|
||||
O MCP Moloni expoe todas as operacoes via ferramentas prefixadas `mcp__moloni__moloni_`:
|
||||
|
||||
```
|
||||
mcp__moloni__moloni_documents_invoices_getall
|
||||
mcp__moloni__moloni_documents_invoices_getone
|
||||
mcp__moloni__moloni_documents_receipts_insert
|
||||
mcp__moloni__moloni_documents_credit_notes_getall
|
||||
mcp__moloni__moloni_entities_customers_getall
|
||||
mcp__moloni__moloni_settings_paymentmethods_getall
|
||||
mcp__moloni__moloni_settings_documentsets_getall
|
||||
```
|
||||
|
||||
**Nota:** O MCP server ja coloca o `access_token` na query string automaticamente. Quando usar via MCP, nao e necessario gerir tokens manualmente.
|
||||
|
||||
## Mapeamento Clientes Moloni-Desk
|
||||
|
||||
| Moloni customer_id | Nome Moloni | Desk client_id | Nome Desk |
|
||||
|-------------------|-------------|----------------|-----------|
|
||||
| 75731733 | Missao Pertinente | 10 | MIP |
|
||||
| 84748539 | KCCG - Karate Clube de Gaia | 2 | KCG |
|
||||
| 90214681 | IgnitionVortex | 14 | IGV |
|
||||
| 90360913 | Prestigebrokers | 176 | Prestigebrokers |
|
||||
| 90861853 | Cristina Pinto Santos Lda | 17 | SNT Sintricare |
|
||||
| 96914420 | Vasco Miguel Neves, Unipessoal | 21 | Solar FV |
|
||||
| 97615615 | TECIRRIGATION | 22 | TECIRRIGATION |
|
||||
| 98881975 | Miguel Carril | 23 | MCR |
|
||||
| 99321870 | Espiral Senior | 24 | Espiral Senior |
|
||||
| 99581273 | Alegria Todo o Dia | 25 | Alegria Todo o Dia |
|
||||
| 100711528 | ROSSANA FERREIRA | 26 | Family Clinic |
|
||||
| 105780051 | AQUISEVENDE | 28 | AQUISEVENDE |
|
||||
| 128784439 | Carstuff Artigos Para Carrocaria | 139 | CTF Carstuff |
|
||||
|
||||
## Sincronizacao Desk-Moloni (Estado 2026-02-05)
|
||||
|
||||
| Tipo | Total Serie D | Sincronizados |
|
||||
|------|--------------|---------------|
|
||||
| Facturas | 107 | 107 importadas no Desk |
|
||||
| Notas de Credito | 3 | 3 importadas no Desk |
|
||||
| Recibos | 112 | 91 existentes + 21 criados |
|
||||
| Pagamentos | 113 | 110 serie D + 3 serie 118898 |
|
||||
| PDFs | 220 | 107 FT + 110 RC + 3 NC (330 registos: invoice+customer) |
|
||||
|
||||
Status facturas:
|
||||
- Paid: 98 | Partially Paid: 2 (D/36, D/84) | Unpaid: 3 (D/98, D/105, D/106)
|
||||
- Cancelled: 2 (D/56, D/88) | Draft: 2 (D/18, D/66)
|
||||
|
||||
Excluidas da sincronizacao:
|
||||
- FT D/8, D/56, D/88 - anuladas por notas de credito
|
||||
- FT D/98, D/105, D/106 - nao cobradas
|
||||
- FT D/18, D/66 - rascunhos
|
||||
- FT D/3, D/4, D/5 - recibos na serie 118898 (nao D)
|
||||
332
automacao/skills/moloni-api/references/endpoints.md
Normal file
332
automacao/skills/moloni-api/references/endpoints.md
Normal file
@@ -0,0 +1,332 @@
|
||||
# Moloni API - Catalogo Completo de Endpoints
|
||||
|
||||
> Fonte oficial: https://www.moloni.pt/dev/endpoints/
|
||||
> Base URL: `https://api.moloni.pt/v2/`
|
||||
> Todos os endpoints usam POST com `access_token` na query string.
|
||||
> Trailing slash obrigatorio em todos os endpoints.
|
||||
|
||||
## Account & Profile
|
||||
|
||||
### My Profile (myProfile/)
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| signup | `myProfile/signup/` | Registar nova conta |
|
||||
| recoverpassword | `myProfile/recoverpassword/` | Recuperar password |
|
||||
| updateMe | `myProfile/updateMe/` | Actualizar perfil |
|
||||
| getMe | `myProfile/getMe/` | Obter dados do perfil |
|
||||
|
||||
## Company
|
||||
|
||||
### Company (companies/)
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| freeSlug | `companies/freeSlug/` | Verificar slug disponivel |
|
||||
| getAll | `companies/getAll/` | Listar empresas |
|
||||
| getOne | `companies/getOne/` | Detalhe de empresa |
|
||||
|
||||
### Subscription (subscription/)
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| getOne | `subscription/getOne/` | Dados da subscricao |
|
||||
|
||||
### Users (users/)
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| getAll | `users/getAll/` | Listar utilizadores |
|
||||
|
||||
## Entities
|
||||
|
||||
### Customers (customers/)
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| getAll | `customers/getAll/` | Listar clientes (qty, offset) |
|
||||
| getOne | `customers/getOne/` | Detalhe de cliente |
|
||||
| getBySearch | `customers/getBySearch/` | Pesquisar por texto |
|
||||
| getByVat | `customers/getByVat/` | Pesquisar por NIF |
|
||||
| getByNumber | `customers/getByNumber/` | Pesquisar por numero |
|
||||
| getByEmail | `customers/getByEmail/` | Pesquisar por email |
|
||||
| getByName | `customers/getByName/` | Pesquisar por nome |
|
||||
| getNextNumber | `customers/getNextNumber/` | Proximo numero |
|
||||
| getLastNumber | `customers/getLastNumber/` | Ultimo numero |
|
||||
| getModifiedSince | `customers/getModifiedSince/` | Alterados desde data |
|
||||
| count | `customers/count/` | Total de clientes |
|
||||
| countBySearch | `customers/countBySearch/` | Contar por pesquisa |
|
||||
| countByVat | `customers/countByVat/` | Contar por NIF |
|
||||
| countByNumber | `customers/countByNumber/` | Contar por numero |
|
||||
| countByEmail | `customers/countByEmail/` | Contar por email |
|
||||
| countByName | `customers/countByName/` | Contar por nome |
|
||||
| countModifiedSince | `customers/countModifiedSince/` | Contar alterados |
|
||||
| insert | `customers/insert/` | Criar cliente |
|
||||
| update | `customers/update/` | Actualizar cliente |
|
||||
| delete | `customers/delete/` | Eliminar cliente |
|
||||
|
||||
### Customer Alternate Addresses (customerAlternateAddresses/)
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| getAll | `customerAlternateAddresses/getAll/` | Listar moradas |
|
||||
| insert | `customerAlternateAddresses/insert/` | Criar morada |
|
||||
| update | `customerAlternateAddresses/update/` | Actualizar morada |
|
||||
| delete | `customerAlternateAddresses/delete/` | Eliminar morada |
|
||||
|
||||
### Suppliers (suppliers/)
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| count | `suppliers/count/` | Total fornecedores |
|
||||
| getAll | `suppliers/getAll/` | Listar fornecedores |
|
||||
| getOne | `suppliers/getOne/` | Detalhe fornecedor |
|
||||
| countBySearch | `suppliers/countBySearch/` | Contar por pesquisa |
|
||||
| getBySearch | `suppliers/getBySearch/` | Pesquisar por texto |
|
||||
| countByVat | `suppliers/countByVat/` | Contar por NIF |
|
||||
| getByVat | `suppliers/getByVat/` | Pesquisar por NIF |
|
||||
| countByNumber | `suppliers/countByNumber/` | Contar por numero |
|
||||
| getByNumber | `suppliers/getByNumber/` | Pesquisar por numero |
|
||||
| countByName | `suppliers/countByName/` | Contar por nome |
|
||||
| getByName | `suppliers/getByName/` | Pesquisar por nome |
|
||||
| insert | `suppliers/insert/` | Criar fornecedor |
|
||||
| update | `suppliers/update/` | Actualizar fornecedor |
|
||||
| delete | `suppliers/delete/` | Eliminar fornecedor |
|
||||
|
||||
### Salesmen (salesmen/)
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| count | `salesmen/count/` | Total vendedores |
|
||||
| getAll | `salesmen/getAll/` | Listar vendedores |
|
||||
| getOne | `salesmen/getOne/` | Detalhe vendedor |
|
||||
| countBySearch/getBySearch | Pesquisar por texto |
|
||||
| countByVat/getByVat | Pesquisar por NIF |
|
||||
| countByNumber/getByNumber | Pesquisar por numero |
|
||||
| countByName/getByName | Pesquisar por nome |
|
||||
| countByEmail/getByEmail | Pesquisar por email |
|
||||
| insert | `salesmen/insert/` | Criar vendedor |
|
||||
| update | `salesmen/update/` | Actualizar vendedor |
|
||||
| delete | `salesmen/delete/` | Eliminar vendedor |
|
||||
|
||||
## Products
|
||||
|
||||
### Products (products/)
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| count | `products/count/` | Total produtos |
|
||||
| getAll | `products/getAll/` | Listar produtos |
|
||||
| getOne | `products/getOne/` | Detalhe produto |
|
||||
| countBySearch/getBySearch | Pesquisar por texto |
|
||||
| countByName/getByName | Pesquisar por nome |
|
||||
| countByReference/getByReference | Pesquisar por referencia |
|
||||
| countByEAN/getByEAN | Pesquisar por codigo barras |
|
||||
| countModifiedSince/getModifiedSince | Alterados desde data |
|
||||
| getLastCostPrice | `products/getLastCostPrice/` | Ultimo preco de custo |
|
||||
| getNextReference | `products/getNextReference/` | Proxima referencia |
|
||||
| insert | `products/insert/` | Criar produto |
|
||||
| update | `products/update/` | Actualizar produto |
|
||||
| delete | `products/delete/` | Eliminar produto |
|
||||
|
||||
### Product Categories (productCategories/)
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| getOne | `productCategories/getOne/` | Detalhe categoria |
|
||||
| getAll | `productCategories/getAll/` | Listar categorias |
|
||||
| insert | `productCategories/insert/` | Criar categoria |
|
||||
| update | `productCategories/update/` | Actualizar categoria |
|
||||
| delete | `productCategories/delete/` | Eliminar categoria |
|
||||
|
||||
### Product Stocks (productStocks/)
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| getAll | `productStocks/getAll/` | Listar stocks |
|
||||
| insert | `productStocks/insert/` | Criar stock |
|
||||
| update | `productStocks/update/` | Actualizar stock |
|
||||
| delete | `productStocks/delete/` | Eliminar stock |
|
||||
| moveToWarehouse | `productStocks/moveToWarehouse/` | Mover entre armazens |
|
||||
|
||||
### Price Classes (priceClasses/)
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| getAll | `priceClasses/getAll/` | Listar classes preco |
|
||||
| insert | `priceClasses/insert/` | Criar classe preco |
|
||||
| update | `priceClasses/update/` | Actualizar classe preco |
|
||||
| delete | `priceClasses/delete/` | Eliminar classe preco |
|
||||
|
||||
## Documents
|
||||
|
||||
> **ATENCAO Case-Sensitivity!** Endpoints com multiplas palavras usam camelCase.
|
||||
|
||||
### Facturas (invoices/) - lowercase OK
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| count | `invoices/count/` | Total facturas |
|
||||
| getAll | `invoices/getAll/` | Listar facturas |
|
||||
| getOne | `invoices/getOne/` | Detalhe factura |
|
||||
| insert | `invoices/insert/` | Criar factura |
|
||||
| update | `invoices/update/` | Actualizar factura |
|
||||
| delete | `invoices/delete/` | Eliminar factura |
|
||||
| generateMbReference | `invoices/generateMbReference/` | Gerar ref MB |
|
||||
|
||||
### Recibos (receipts/) - lowercase OK
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| count | `receipts/count/` | Total recibos |
|
||||
| getAll | `receipts/getAll/` | Listar recibos |
|
||||
| getOne | `receipts/getOne/` | Detalhe recibo |
|
||||
| insert | `receipts/insert/` | Criar recibo |
|
||||
| update | `receipts/update/` | Actualizar recibo |
|
||||
| delete | `receipts/delete/` | Eliminar recibo |
|
||||
|
||||
### Notas de Credito (creditNotes/) - CAMELCASE!
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| count | `creditNotes/count/` | Total notas credito |
|
||||
| getAll | `creditNotes/getAll/` | Listar notas credito |
|
||||
| getOne | `creditNotes/getOne/` | Detalhe nota credito |
|
||||
| insert | `creditNotes/insert/` | Criar nota credito |
|
||||
| update | `creditNotes/update/` | Actualizar nota credito |
|
||||
| delete | `creditNotes/delete/` | Eliminar nota credito |
|
||||
|
||||
### Notas de Debito (debitNotes/) - CAMELCASE!
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| count | `debitNotes/count/` | Total notas debito |
|
||||
| getAll | `debitNotes/getAll/` | Listar notas debito |
|
||||
| getOne | `debitNotes/getOne/` | Detalhe nota debito |
|
||||
| insert | `debitNotes/insert/` | Criar nota debito |
|
||||
| update | `debitNotes/update/` | Actualizar nota debito |
|
||||
| delete | `debitNotes/delete/` | Eliminar nota debito |
|
||||
|
||||
### Facturas Simplificadas (simplifiedInvoices/) - CAMELCASE!
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| count | `simplifiedInvoices/count/` | Total |
|
||||
| getAll | `simplifiedInvoices/getAll/` | Listar |
|
||||
| getOne | `simplifiedInvoices/getOne/` | Detalhe |
|
||||
| insert | `simplifiedInvoices/insert/` | Criar |
|
||||
| update | `simplifiedInvoices/update/` | Actualizar |
|
||||
| delete | `simplifiedInvoices/delete/` | Eliminar |
|
||||
| generateMbReference | `simplifiedInvoices/generateMbReference/` | Gerar ref MB |
|
||||
|
||||
### Facturas-Recibo (invoiceReceipts/) - CAMELCASE!
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| count | `invoiceReceipts/count/` | Total |
|
||||
| getAll | `invoiceReceipts/getAll/` | Listar |
|
||||
| getOne | `invoiceReceipts/getOne/` | Detalhe |
|
||||
| insert | `invoiceReceipts/insert/` | Criar |
|
||||
| update | `invoiceReceipts/update/` | Actualizar |
|
||||
| delete | `invoiceReceipts/delete/` | Eliminar |
|
||||
| generateMbReference | `invoiceReceipts/generateMbReference/` | Gerar ref MB |
|
||||
|
||||
### Guias de Transporte (billsOfLading/) - CAMELCASE!
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| count/getAll/getOne/insert/update/delete | Operacoes standard |
|
||||
| setTransportCode | `billsOfLading/setTransportCode/` | Definir codigo transporte AT |
|
||||
|
||||
### Guias de Remessa (deliveryNotes/) - CAMELCASE!
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| count/getAll/getOne/insert/update/delete | Operacoes standard |
|
||||
| setTransportCode | `deliveryNotes/setTransportCode/` | Codigo transporte AT |
|
||||
|
||||
### Facturas de Activos Proprios (ownAssetsInvoices/) - CAMELCASE!
|
||||
Standard: count/getAll/getOne/insert/update/delete
|
||||
|
||||
### Facturas Pro Forma (proFormaInvoices/) - CAMELCASE!
|
||||
Standard: count/getAll/getOne/insert/update/delete
|
||||
|
||||
### Notas de Devolucao (devolutionNotes/) - CAMELCASE!
|
||||
Standard: count/getAll/getOne/insert/update/delete
|
||||
|
||||
### Encomendas (purchaseOrders/) - CAMELCASE!
|
||||
Standard: count/getAll/getOne/insert/update/delete
|
||||
|
||||
### Notas de Consignacao (consignmentNotes/) - CAMELCASE!
|
||||
Standard: count/getAll/getOne/insert/update/delete
|
||||
|
||||
### Notas de Retorno (returnNotes/) - CAMELCASE!
|
||||
Standard: count/getAll/getOne/insert/update/delete
|
||||
|
||||
### Guias de Movimentacao (movementOfGoods/) - CAMELCASE!
|
||||
Standard: count/getAll/getOne/insert/update/delete
|
||||
|
||||
### Guias de Transporte (transportGuide/) - CAMELCASE!
|
||||
Standard + setTransportCode
|
||||
|
||||
### Orcamentos (budget/) - lowercase OK
|
||||
Standard: count/getAll/getOne/insert/update/delete
|
||||
|
||||
### Documentos Internos (internalDocuments/) - CAMELCASE!
|
||||
Standard: count/getAll/getOne/insert/update/delete
|
||||
|
||||
## Settings
|
||||
|
||||
### Contas Bancarias (bankAccounts/) - CAMELCASE!
|
||||
Standard: getAll/insert/update/delete
|
||||
|
||||
### Codigos CAE (caeCodes/) - CAMELCASE!
|
||||
Standard: getAll/insert/update/delete
|
||||
|
||||
### Metodos de Pagamento (paymentMethods/) - CAMELCASE!
|
||||
Standard: getAll/insert/update/delete
|
||||
|
||||
### Prazos de Vencimento (maturityDates/) - CAMELCASE!
|
||||
Standard + countModifiedSince/getModifiedSince
|
||||
|
||||
### Metodos de Entrega (deliveryMethods/) - CAMELCASE!
|
||||
Standard: getAll/insert/update/delete
|
||||
|
||||
### Veiculos (vehicles/) - lowercase OK
|
||||
Standard + getBySearch
|
||||
|
||||
### Deducoes (deductions/) - lowercase OK
|
||||
Standard: getAll/insert/update/delete
|
||||
|
||||
### Impostos (taxes/) - lowercase OK
|
||||
Standard: getAll/insert/update/delete
|
||||
|
||||
### Unidades de Medida (measurementUnits/) - CAMELCASE!
|
||||
Standard: getAll/insert/update/delete
|
||||
|
||||
### Templates de Identificacao (identificationTemplates/) - CAMELCASE!
|
||||
Standard: getAll/insert/update/delete
|
||||
|
||||
### Series Documentais (documentSets/) - CAMELCASE!
|
||||
| Metodo | Endpoint | Descricao |
|
||||
|--------|----------|-----------|
|
||||
| getAll | `documentSets/getAll/` | Listar series |
|
||||
| insert | `documentSets/insert/` | Criar serie |
|
||||
| update | `documentSets/update/` | Actualizar serie |
|
||||
| delete | `documentSets/delete/` | Eliminar serie |
|
||||
| countModifiedSince | `documentSets/countModifiedSince/` | Contar alterados |
|
||||
| getModifiedSince | `documentSets/getModifiedSince/` | Listar alterados |
|
||||
| atInsertCode | `documentSets/atInsertCode/` | Inserir codigo AT |
|
||||
| atInsertCodeBulk | `documentSets/atInsertCodeBulk/` | Inserir codigos AT bulk |
|
||||
|
||||
### Armazens (warehouses/) - lowercase OK
|
||||
Standard + countModifiedSince
|
||||
|
||||
### Propriedades de Produtos (productProperties/) - CAMELCASE!
|
||||
Standard + countModifiedSince/getModifiedSince
|
||||
|
||||
## Global Data
|
||||
|
||||
### Countries (countries/)
|
||||
`countries/getAll/` - Lista de paises (Portugal country_id: 1)
|
||||
|
||||
### Fiscal Zones (fiscalZones/) - CAMELCASE!
|
||||
`fiscalZones/getAll/` - Zonas fiscais
|
||||
|
||||
### Languages (languages/)
|
||||
`languages/getAll/`, `languages/getOne/`
|
||||
|
||||
### Currencies (currencies/)
|
||||
`currencies/getAll/`, `currencies/getOne/` (EUR = id 1)
|
||||
|
||||
### Document Models (documentModels/) - CAMELCASE!
|
||||
`documentModels/getAll/` - Modelos de documento
|
||||
|
||||
### Tax Exemptions (taxExemptions/) - CAMELCASE!
|
||||
`taxExemptions/getAll/` - Lista de isencoes de imposto
|
||||
|
||||
### Currency Exchange (currencyExchange/) - CAMELCASE!
|
||||
`currencyExchange/getAll/`, `currencyExchange/getOne/` - Taxas de cambio
|
||||
|
||||
### Multibanco Gateways (multibancoGateways/) - CAMELCASE!
|
||||
`multibancoGateways/getAll/` - Gateways MB disponiveis
|
||||
279
automacao/skills/n8n-chatbot/SKILL.md
Normal file
279
automacao/skills/n8n-chatbot/SKILL.md
Normal file
@@ -0,0 +1,279 @@
|
||||
# /n8n-chatbot - Chatbots e AI Agents n8n
|
||||
|
||||
Criar chatbots e workflows com AI usando LangChain.
|
||||
|
||||
---
|
||||
|
||||
## Uso
|
||||
|
||||
```
|
||||
/n8n-chatbot create <descrição> # Criar chatbot
|
||||
/n8n-chatbot agent <tipo> # Criar AI agent
|
||||
/n8n-chatbot rag <knowledge_base> # Criar sistema RAG
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Workflow Obrigatório
|
||||
|
||||
```
|
||||
1. Health check → mcp__n8n__n8n_health_check()
|
||||
2. Pesquisar template → mcp__n8n__search_templates({ task: "ai_automation" })
|
||||
3. Se template OK → mcp__n8n__n8n_deploy_template()
|
||||
4. Se criar do zero → Seguir fluxo abaixo
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Nodes LangChain
|
||||
|
||||
### Core
|
||||
|
||||
| Node | Uso |
|
||||
|------|-----|
|
||||
| `@n8n/n8n-nodes-langchain.agent` | AI Agent principal |
|
||||
| `@n8n/n8n-nodes-langchain.chainLlm` | Chain LLM simples |
|
||||
| `@n8n/n8n-nodes-langchain.chainRetrievalQa` | RAG Q&A |
|
||||
|
||||
### Modelos
|
||||
|
||||
| Node | Provider |
|
||||
|------|----------|
|
||||
| `@n8n/n8n-nodes-langchain.lmChatOpenAi` | OpenAI GPT |
|
||||
| `@n8n/n8n-nodes-langchain.lmChatAnthropic` | Claude |
|
||||
| `@n8n/n8n-nodes-langchain.lmChatOllama` | Ollama local |
|
||||
|
||||
### Memória
|
||||
|
||||
| Node | Tipo |
|
||||
|------|------|
|
||||
| `@n8n/n8n-nodes-langchain.memoryBufferWindow` | Últimas N mensagens |
|
||||
| `@n8n/n8n-nodes-langchain.memoryPostgresChat` | PostgreSQL |
|
||||
| `@n8n/n8n-nodes-langchain.memoryRedisChat` | Redis |
|
||||
|
||||
### Tools
|
||||
|
||||
| Node | Função |
|
||||
|------|--------|
|
||||
| `@n8n/n8n-nodes-langchain.toolCalculator` | Cálculos |
|
||||
| `@n8n/n8n-nodes-langchain.toolCode` | Executar código |
|
||||
| `@n8n/n8n-nodes-langchain.toolHttpRequest` | Chamar APIs |
|
||||
| `@n8n/n8n-nodes-langchain.toolWorkflow` | Chamar workflows |
|
||||
|
||||
### Vector Stores (RAG)
|
||||
|
||||
| Node | Sistema |
|
||||
|------|---------|
|
||||
| `@n8n/n8n-nodes-langchain.vectorStoreSupabase` | Supabase |
|
||||
| `@n8n/n8n-nodes-langchain.vectorStorePinecone` | Pinecone |
|
||||
| `@n8n/n8n-nodes-langchain.vectorStorePgVector` | PostgreSQL |
|
||||
|
||||
---
|
||||
|
||||
## Chatbot Básico
|
||||
|
||||
### Estrutura
|
||||
|
||||
```
|
||||
Webhook/Trigger
|
||||
↓
|
||||
LLM Chat Model (OpenAI/Claude)
|
||||
↓
|
||||
Memory (Buffer)
|
||||
↓
|
||||
Agent
|
||||
↓
|
||||
Resposta
|
||||
```
|
||||
|
||||
### Implementação
|
||||
|
||||
```javascript
|
||||
// 1. Modelo LLM
|
||||
mcp__n8n__get_node({
|
||||
nodeType: "@n8n/n8n-nodes-langchain.lmChatOpenAi",
|
||||
detail: "standard"
|
||||
})
|
||||
|
||||
// 2. Memória
|
||||
mcp__n8n__get_node({
|
||||
nodeType: "@n8n/n8n-nodes-langchain.memoryBufferWindow",
|
||||
detail: "standard"
|
||||
})
|
||||
|
||||
// 3. Agent
|
||||
mcp__n8n__get_node({
|
||||
nodeType: "@n8n/n8n-nodes-langchain.agent",
|
||||
detail: "standard"
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## RAG (Retrieval Augmented Generation)
|
||||
|
||||
### Estrutura
|
||||
|
||||
```
|
||||
Documentos
|
||||
↓
|
||||
Embeddings
|
||||
↓
|
||||
Vector Store
|
||||
↓
|
||||
Query (pergunta)
|
||||
↓
|
||||
Retriever
|
||||
↓
|
||||
LLM (resposta contextualizada)
|
||||
```
|
||||
|
||||
### Configuração Vector Store
|
||||
|
||||
```javascript
|
||||
mcp__n8n__validate_node({
|
||||
nodeType: "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
|
||||
config: {
|
||||
mode: "insert", // ou "retrieve"
|
||||
tableName: "documents",
|
||||
queryName: "match_documents"
|
||||
},
|
||||
mode: "minimal"
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## AI Agent com Tools
|
||||
|
||||
### Estrutura
|
||||
|
||||
```
|
||||
Input
|
||||
↓
|
||||
Agent
|
||||
├── Tool: Calculator
|
||||
├── Tool: HTTP Request
|
||||
├── Tool: Code
|
||||
└── Tool: Workflow
|
||||
↓
|
||||
Output
|
||||
```
|
||||
|
||||
### Configuração Agent
|
||||
|
||||
```javascript
|
||||
mcp__n8n__validate_node({
|
||||
nodeType: "@n8n/n8n-nodes-langchain.agent",
|
||||
config: {
|
||||
agentType: "conversationalAgent",
|
||||
systemMessage: "Tu és um assistente prestável...",
|
||||
options: {
|
||||
returnIntermediateSteps: true
|
||||
}
|
||||
},
|
||||
mode: "minimal"
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Exemplos Práticos
|
||||
|
||||
### Chatbot de Suporte
|
||||
|
||||
```
|
||||
Webhook (mensagem cliente)
|
||||
↓
|
||||
Memory PostgreSQL (histórico)
|
||||
↓
|
||||
Vector Store (docs suporte)
|
||||
↓
|
||||
Chain Retrieval QA
|
||||
↓
|
||||
Webhook Response
|
||||
```
|
||||
|
||||
### Agent CRM
|
||||
|
||||
```
|
||||
Webhook (comando)
|
||||
↓
|
||||
Agent
|
||||
├── Tool: Pesquisar clientes
|
||||
├── Tool: Criar lead
|
||||
└── Tool: Actualizar tarefa
|
||||
↓
|
||||
Slack (resultado)
|
||||
```
|
||||
|
||||
### Resumo de Documentos
|
||||
|
||||
```
|
||||
Webhook (upload PDF)
|
||||
↓
|
||||
PDF Extract
|
||||
↓
|
||||
Text Splitter
|
||||
↓
|
||||
LLM Chain (resumo)
|
||||
↓
|
||||
Email (enviar resumo)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Templates Recomendados
|
||||
|
||||
```javascript
|
||||
// AI templates
|
||||
mcp__n8n__search_templates({
|
||||
searchMode: "by_task",
|
||||
task: "ai_automation"
|
||||
})
|
||||
|
||||
// Por keyword
|
||||
mcp__n8n__search_templates({
|
||||
searchMode: "keyword",
|
||||
query: "chatbot langchain openai"
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Credenciais Necessárias
|
||||
|
||||
| Provider | Credencial | Node |
|
||||
|----------|------------|------|
|
||||
| OpenAI | API Key | lmChatOpenAi |
|
||||
| Anthropic | API Key | lmChatAnthropic |
|
||||
| Supabase | URL + Key | vectorStoreSupabase |
|
||||
| Pinecone | API Key | vectorStorePinecone |
|
||||
|
||||
---
|
||||
|
||||
## Boas Práticas
|
||||
|
||||
| Prática | Razão |
|
||||
|---------|-------|
|
||||
| System prompt claro | Define comportamento |
|
||||
| Temperatura baixa (0.1-0.3) | Respostas consistentes |
|
||||
| Memória limitada | Performance |
|
||||
| Retry on error | Resiliência |
|
||||
| Logs de conversas | Debug e melhoria |
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Problema | Solução |
|
||||
|----------|---------|
|
||||
| Respostas inconsistentes | Baixar temperatura |
|
||||
| Contexto perdido | Verificar memória |
|
||||
| RAG não encontra | Verificar embeddings |
|
||||
| Timeout | Aumentar limite |
|
||||
| Token limit | Resumir contexto |
|
||||
|
||||
---
|
||||
|
||||
*Skill v1.0 | Descomplicar®*
|
||||
92
automacao/skills/n8n-health/SKILL.md
Normal file
92
automacao/skills/n8n-health/SKILL.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# /n8n-health - Diagnóstico n8n
|
||||
|
||||
Verificar conectividade e estado da instância n8n.
|
||||
|
||||
---
|
||||
|
||||
## Uso
|
||||
|
||||
```
|
||||
/n8n-health # Status rápido
|
||||
/n8n-health verbose # Diagnóstico completo
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Instância
|
||||
|
||||
| Aspecto | Valor |
|
||||
|---------|-------|
|
||||
| URL | `https://automator.descomplicar.pt` |
|
||||
| MCP | `mcp__n8n__*` |
|
||||
|
||||
---
|
||||
|
||||
## Execução
|
||||
|
||||
### Status Rápido (default)
|
||||
|
||||
```
|
||||
1. mcp__n8n__n8n_health_check({ mode: "status" })
|
||||
2. Reportar: status, URL, versão, response time
|
||||
```
|
||||
|
||||
### Diagnóstico Completo (verbose)
|
||||
|
||||
```
|
||||
1. mcp__n8n__n8n_health_check({ mode: "diagnostic", verbose: true })
|
||||
2. Reportar: env vars, tool status, cache, erros
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Output Esperado
|
||||
|
||||
```
|
||||
n8n Health Check
|
||||
----------------
|
||||
Status: OK | ERRO
|
||||
URL: https://automator.descomplicar.pt
|
||||
MCP: 2.33.x
|
||||
Response: XXXms
|
||||
Workflows: XX activos
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Se Falhar
|
||||
|
||||
| Erro | Causa | Solução |
|
||||
|------|-------|---------|
|
||||
| Connection refused | n8n offline | Verificar servidor |
|
||||
| 401 Unauthorized | API key inválida | Regenerar no n8n |
|
||||
| Timeout | Rede lenta | Verificar latência |
|
||||
|
||||
### Diagnóstico Manual
|
||||
|
||||
```bash
|
||||
# Verificar se n8n responde
|
||||
curl -I https://automator.descomplicar.pt
|
||||
|
||||
# Verificar API
|
||||
curl -H "X-N8N-API-KEY: $KEY" https://automator.descomplicar.pt/api/v1/workflows
|
||||
|
||||
# Logs MCP
|
||||
~/.claude/logs/mcp-n8n.log
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Skills Relacionadas
|
||||
|
||||
| Skill | Quando Usar |
|
||||
|-------|-------------|
|
||||
| `/n8n-webhook` | Criar webhooks |
|
||||
| `/n8n-schedule` | Automações cron |
|
||||
| `/n8n-sync` | Sincronização dados |
|
||||
| `/n8n-notify` | Alertas |
|
||||
| `/n8n-chatbot` | AI/Chatbots |
|
||||
|
||||
---
|
||||
|
||||
*Skill v1.0 | Descomplicar®*
|
||||
228
automacao/skills/n8n-notify/SKILL.md
Normal file
228
automacao/skills/n8n-notify/SKILL.md
Normal file
@@ -0,0 +1,228 @@
|
||||
# /n8n-notify - Notificações e Alertas n8n
|
||||
|
||||
Criar sistemas de alertas via Slack, email, SMS.
|
||||
|
||||
---
|
||||
|
||||
## Uso
|
||||
|
||||
```
|
||||
/n8n-notify create <descrição> # Criar sistema de alertas
|
||||
/n8n-notify slack <mensagem> # Quick Slack notification
|
||||
/n8n-notify email <para> <assunto> # Quick email
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Workflow Obrigatório
|
||||
|
||||
```
|
||||
1. Health check → mcp__n8n__n8n_health_check()
|
||||
2. Pesquisar template → mcp__n8n__search_templates({ query: "notification" })
|
||||
3. Se template OK → mcp__n8n__n8n_deploy_template()
|
||||
4. Se criar do zero → Seguir fluxo abaixo
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Canais Disponíveis
|
||||
|
||||
| Canal | Node | Uso |
|
||||
|-------|------|-----|
|
||||
| Slack | `nodes-base.slack` | Notificações equipa |
|
||||
| Email | `nodes-base.emailSend` | Alertas formais |
|
||||
| Telegram | `nodes-base.telegram` | Alertas mobile |
|
||||
| Discord | `nodes-base.discord` | Comunidades |
|
||||
| SMS | `nodes-base.twilio` | Alertas críticos |
|
||||
|
||||
---
|
||||
|
||||
## Slack
|
||||
|
||||
### Documentação
|
||||
|
||||
```javascript
|
||||
mcp__n8n__get_node({
|
||||
nodeType: "nodes-base.slack",
|
||||
detail: "standard",
|
||||
includeExamples: true
|
||||
})
|
||||
```
|
||||
|
||||
### Configuração
|
||||
|
||||
```javascript
|
||||
mcp__n8n__validate_node({
|
||||
nodeType: "nodes-base.slack",
|
||||
config: {
|
||||
resource: "message",
|
||||
operation: "post",
|
||||
channel: "#alertas",
|
||||
text: "Mensagem de alerta"
|
||||
},
|
||||
mode: "minimal"
|
||||
})
|
||||
```
|
||||
|
||||
### Mensagem Formatada (Blocks)
|
||||
|
||||
```javascript
|
||||
{
|
||||
blocksUi: {
|
||||
blocksValues: [
|
||||
{
|
||||
type: "header",
|
||||
text: { type: "plain_text", text: "Alerta" }
|
||||
},
|
||||
{
|
||||
type: "section",
|
||||
text: { type: "mrkdwn", text: "*Detalhes:*\n{{ $json.message }}" }
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Email
|
||||
|
||||
### Configuração
|
||||
|
||||
```javascript
|
||||
mcp__n8n__validate_node({
|
||||
nodeType: "nodes-base.emailSend",
|
||||
config: {
|
||||
fromEmail: "alertas@descomplicar.pt",
|
||||
toEmail: "emanuel@descomplicar.pt",
|
||||
subject: "Alerta: {{ $json.title }}",
|
||||
text: "{{ $json.message }}"
|
||||
},
|
||||
mode: "minimal"
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Padrões Comuns
|
||||
|
||||
### Webhook → Slack
|
||||
|
||||
```
|
||||
Webhook (evento externo)
|
||||
↓
|
||||
Set (formatar)
|
||||
↓
|
||||
Slack (enviar)
|
||||
```
|
||||
|
||||
### Monitor → Multi-canal
|
||||
|
||||
```
|
||||
Schedule (cada 5min)
|
||||
↓
|
||||
HTTP Request (check health)
|
||||
↓
|
||||
IF (erro?)
|
||||
↓ TRUE
|
||||
Slack + Email (alertar)
|
||||
```
|
||||
|
||||
### Error Handler
|
||||
|
||||
```
|
||||
Qualquer workflow
|
||||
↓ (erro)
|
||||
Error Trigger
|
||||
↓
|
||||
Slack (alertar erro)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Níveis de Alerta
|
||||
|
||||
| Nível | Canal | Quando |
|
||||
|-------|-------|--------|
|
||||
| Info | Slack | Eventos normais |
|
||||
| Warning | Slack + Email | Atenção necessária |
|
||||
| Critical | Todos + SMS | Acção imediata |
|
||||
|
||||
### Implementação
|
||||
|
||||
```
|
||||
IF (severity = "critical")
|
||||
↓ TRUE
|
||||
Slack + Email + SMS
|
||||
↓ FALSE
|
||||
IF (severity = "warning")
|
||||
↓ TRUE
|
||||
Slack + Email
|
||||
↓ FALSE
|
||||
Slack
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Exemplos
|
||||
|
||||
### Alerta de Servidor Down
|
||||
|
||||
```
|
||||
Schedule (5min)
|
||||
↓
|
||||
HTTP Request (ping servidor)
|
||||
↓
|
||||
IF (falhou?)
|
||||
↓ TRUE
|
||||
Slack (#infra)
|
||||
Email (admin)
|
||||
```
|
||||
|
||||
### Novo Lead
|
||||
|
||||
```
|
||||
Webhook (lead criado)
|
||||
↓
|
||||
Set (formatar)
|
||||
↓
|
||||
Slack (#vendas)
|
||||
```
|
||||
|
||||
### Factura Vencida
|
||||
|
||||
```
|
||||
Schedule (diário 9h)
|
||||
↓
|
||||
HTTP Request (facturas vencidas)
|
||||
↓
|
||||
Loop (cada factura)
|
||||
↓
|
||||
Email (cliente)
|
||||
Slack (#contabilidade)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Templates
|
||||
|
||||
```javascript
|
||||
mcp__n8n__search_templates({
|
||||
searchMode: "keyword",
|
||||
query: "slack notification alert"
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Problema | Solução |
|
||||
|----------|---------|
|
||||
| Slack não envia | Verificar token e canal |
|
||||
| Email em spam | Configurar SPF/DKIM |
|
||||
| Rate limited | Agrupar notificações |
|
||||
|
||||
---
|
||||
|
||||
*Skill v1.0 | Descomplicar®*
|
||||
163
automacao/skills/n8n-schedule/SKILL.md
Normal file
163
automacao/skills/n8n-schedule/SKILL.md
Normal file
@@ -0,0 +1,163 @@
|
||||
# /n8n-schedule - Automações Agendadas n8n
|
||||
|
||||
Criar workflows com execução agendada (cron).
|
||||
|
||||
---
|
||||
|
||||
## Uso
|
||||
|
||||
```
|
||||
/n8n-schedule create <descrição> # Criar automação agendada
|
||||
/n8n-schedule list # Listar agendamentos
|
||||
/n8n-schedule disable <id> # Desactivar
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Workflow Obrigatório
|
||||
|
||||
```
|
||||
1. Health check → mcp__n8n__n8n_health_check()
|
||||
2. Pesquisar template → mcp__n8n__search_templates({ task: "scheduling" })
|
||||
3. Se template OK → mcp__n8n__n8n_deploy_template()
|
||||
4. Se criar do zero → Seguir fluxo abaixo
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Expressões Cron Comuns
|
||||
|
||||
| Expressão | Descrição |
|
||||
|-----------|-----------|
|
||||
| `0 9 * * *` | Diário às 9h |
|
||||
| `0 9 * * 1-5` | Seg-Sex às 9h |
|
||||
| `0 */2 * * *` | A cada 2 horas |
|
||||
| `*/15 * * * *` | A cada 15 minutos |
|
||||
| `0 0 1 * *` | Dia 1 de cada mês |
|
||||
| `0 3 * * 0` | Domingos às 3h |
|
||||
|
||||
### Formato
|
||||
|
||||
```
|
||||
┌───────── minuto (0-59)
|
||||
│ ┌─────── hora (0-23)
|
||||
│ │ ┌───── dia mês (1-31)
|
||||
│ │ │ ┌─── mês (1-12)
|
||||
│ │ │ │ ┌─ dia semana (0-6)
|
||||
* * * * *
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Configuração Schedule Trigger
|
||||
|
||||
```javascript
|
||||
mcp__n8n__validate_node({
|
||||
nodeType: "nodes-base.scheduleTrigger",
|
||||
config: {
|
||||
rule: {
|
||||
interval: [{
|
||||
field: "cronExpression",
|
||||
expression: "0 9 * * 1-5"
|
||||
}]
|
||||
}
|
||||
},
|
||||
mode: "minimal"
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Timezone
|
||||
|
||||
```javascript
|
||||
{
|
||||
options: {
|
||||
timezone: "Europe/Lisbon"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Exemplos
|
||||
|
||||
### Relatório Diário
|
||||
|
||||
```
|
||||
Schedule (0 9 * * 1-5)
|
||||
↓
|
||||
PostgreSQL (query)
|
||||
↓
|
||||
Set (formatar)
|
||||
↓
|
||||
Email (enviar)
|
||||
```
|
||||
|
||||
### Backup Semanal
|
||||
|
||||
```
|
||||
Schedule (0 3 * * 0)
|
||||
↓
|
||||
SSH (backup)
|
||||
↓
|
||||
IF (sucesso?)
|
||||
↓
|
||||
Slack (confirmar/alertar)
|
||||
```
|
||||
|
||||
### Limpeza de Logs
|
||||
|
||||
```
|
||||
Schedule (0 2 * * *)
|
||||
↓
|
||||
SSH (limpar)
|
||||
↓
|
||||
Slack (reportar)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Gestão
|
||||
|
||||
### Desactivar
|
||||
|
||||
```javascript
|
||||
mcp__n8n__n8n_update_partial_workflow({
|
||||
id: "wf-xxx",
|
||||
operations: [{ type: "deactivateWorkflow" }]
|
||||
})
|
||||
```
|
||||
|
||||
### Reactivar
|
||||
|
||||
```javascript
|
||||
mcp__n8n__n8n_update_partial_workflow({
|
||||
id: "wf-xxx",
|
||||
operations: [{ type: "activateWorkflow" }]
|
||||
})
|
||||
```
|
||||
|
||||
### Ver Execuções
|
||||
|
||||
```javascript
|
||||
mcp__n8n__n8n_executions({
|
||||
workflowId: "wf-xxx",
|
||||
limit: 10,
|
||||
status: "all"
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Problema | Solução |
|
||||
|----------|---------|
|
||||
| Não executa | Verificar workflow activo |
|
||||
| Hora errada | Verificar timezone |
|
||||
| Duplicado | Verificar múltiplos triggers |
|
||||
|
||||
---
|
||||
|
||||
*Skill v1.0 | Descomplicar®*
|
||||
162
automacao/skills/n8n-sync/SKILL.md
Normal file
162
automacao/skills/n8n-sync/SKILL.md
Normal file
@@ -0,0 +1,162 @@
|
||||
# /n8n-sync - Sincronização de Dados n8n
|
||||
|
||||
Manter dados sincronizados entre sistemas.
|
||||
|
||||
---
|
||||
|
||||
## Uso
|
||||
|
||||
```
|
||||
/n8n-sync create <origem> <destino> # Criar sync
|
||||
/n8n-sync list # Listar syncs
|
||||
/n8n-sync status <workflow_id> # Ver estado
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Workflow Obrigatório
|
||||
|
||||
```
|
||||
1. Health check → mcp__n8n__n8n_health_check()
|
||||
2. Pesquisar template → mcp__n8n__search_templates({ task: "data_sync" })
|
||||
3. Se template OK → mcp__n8n__n8n_deploy_template()
|
||||
4. Se criar do zero → Seguir fluxo abaixo
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Padrões de Sync
|
||||
|
||||
### One-Way (Unidireccional)
|
||||
|
||||
```
|
||||
Origem → Transform → Destino
|
||||
```
|
||||
|
||||
### Two-Way (Bidireccional)
|
||||
|
||||
```
|
||||
A ←→ B (com resolução de conflitos)
|
||||
```
|
||||
|
||||
### Hub-and-Spoke
|
||||
|
||||
```
|
||||
A ↔ HUB ↔ B
|
||||
↕
|
||||
C
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Nodes por Sistema
|
||||
|
||||
### APIs/CRM
|
||||
|
||||
| Node | Sistema |
|
||||
|------|---------|
|
||||
| `nodes-base.httpRequest` | APIs genéricas |
|
||||
| `nodes-base.webhook` | Receber dados |
|
||||
|
||||
### Bases de Dados
|
||||
|
||||
| Node | Sistema |
|
||||
|------|---------|
|
||||
| `nodes-base.postgres` | PostgreSQL |
|
||||
| `nodes-base.mySql` | MySQL |
|
||||
| `nodes-base.mongoDb` | MongoDB |
|
||||
|
||||
### Ficheiros
|
||||
|
||||
| Node | Sistema |
|
||||
|------|---------|
|
||||
| `nodes-base.googleSheets` | Google Sheets |
|
||||
| `nodes-base.spreadsheetFile` | Excel/CSV |
|
||||
| `nodes-base.ftp` | FTP/SFTP |
|
||||
|
||||
---
|
||||
|
||||
## Exemplo: CRM → Sheets
|
||||
|
||||
```
|
||||
Schedule (horário)
|
||||
↓
|
||||
HTTP Request (GET leads)
|
||||
↓
|
||||
IF (há dados?)
|
||||
↓
|
||||
Set (mapear campos)
|
||||
↓
|
||||
Google Sheets (append)
|
||||
↓
|
||||
Slack (confirmar)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Estratégias
|
||||
|
||||
| Estratégia | Uso |
|
||||
|------------|-----|
|
||||
| Full Sync | Apagar tudo + inserir tudo |
|
||||
| Incremental | Apenas modificados (updated_at) |
|
||||
| Delta | Comparar hashes |
|
||||
|
||||
---
|
||||
|
||||
## Upsert Pattern
|
||||
|
||||
```javascript
|
||||
{
|
||||
nodeType: "nodes-base.postgres",
|
||||
config: {
|
||||
operation: "upsert",
|
||||
table: "clientes",
|
||||
columns: "email,nome,empresa",
|
||||
conflictColumns: "email"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Gestão de Erros
|
||||
|
||||
### Retry
|
||||
|
||||
```javascript
|
||||
{
|
||||
options: {
|
||||
retry: {
|
||||
maxRetries: 3,
|
||||
retryInterval: 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Dead Letter Queue
|
||||
|
||||
```
|
||||
Operação
|
||||
↓ (erro)
|
||||
Error Trigger
|
||||
↓
|
||||
BD (guardar erro)
|
||||
↓
|
||||
Slack (alertar)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Problema | Solução |
|
||||
|----------|---------|
|
||||
| Duplicados | Usar upsert |
|
||||
| Timeout | Batches menores |
|
||||
| Rate limit | Adicionar delays |
|
||||
|
||||
---
|
||||
|
||||
*Skill v1.0 | Descomplicar®*
|
||||
155
automacao/skills/n8n-webhook/SKILL.md
Normal file
155
automacao/skills/n8n-webhook/SKILL.md
Normal file
@@ -0,0 +1,155 @@
|
||||
# /n8n-webhook - Webhooks n8n
|
||||
|
||||
Criar e gerir webhooks para receber dados externos.
|
||||
|
||||
---
|
||||
|
||||
## Uso
|
||||
|
||||
```
|
||||
/n8n-webhook create <descrição> # Criar novo webhook
|
||||
/n8n-webhook list # Listar webhooks existentes
|
||||
/n8n-webhook test <workflow_id> # Testar webhook
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Workflow Obrigatório
|
||||
|
||||
```
|
||||
1. Health check → mcp__n8n__n8n_health_check()
|
||||
2. Pesquisar template → mcp__n8n__search_templates({ query: "webhook" })
|
||||
3. Se template OK → mcp__n8n__n8n_deploy_template()
|
||||
4. Se criar do zero → Seguir fluxo abaixo
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Criar Webhook do Zero
|
||||
|
||||
### Passo 1: Documentação do Node
|
||||
|
||||
```javascript
|
||||
mcp__n8n__get_node({
|
||||
nodeType: "nodes-base.webhook",
|
||||
detail: "standard",
|
||||
includeExamples: true
|
||||
})
|
||||
```
|
||||
|
||||
### Passo 2: Validar Configuração
|
||||
|
||||
```javascript
|
||||
mcp__n8n__validate_node({
|
||||
nodeType: "nodes-base.webhook",
|
||||
config: {
|
||||
httpMethod: "POST",
|
||||
path: "meu-webhook",
|
||||
responseMode: "onReceived"
|
||||
},
|
||||
mode: "minimal"
|
||||
})
|
||||
```
|
||||
|
||||
### Passo 3: Nodes de Processamento
|
||||
|
||||
| Node | Uso |
|
||||
|------|-----|
|
||||
| `nodes-base.set` | Transformar dados |
|
||||
| `nodes-base.if` | Condicionais |
|
||||
| `nodes-base.code` | JavaScript custom |
|
||||
| `nodes-base.httpRequest` | Chamar APIs |
|
||||
|
||||
### Passo 4: Deploy
|
||||
|
||||
```javascript
|
||||
mcp__n8n__n8n_create_workflow({
|
||||
name: "Webhook - Descrição",
|
||||
nodes: [...],
|
||||
connections: {...},
|
||||
active: true
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Configurações Webhook
|
||||
|
||||
| Parâmetro | Opções | Default |
|
||||
|-----------|--------|---------|
|
||||
| `httpMethod` | GET, POST, PUT, DELETE | POST |
|
||||
| `path` | String única | (obrigatório) |
|
||||
| `authentication` | none, basicAuth, headerAuth | none |
|
||||
| `responseMode` | onReceived, lastNode | onReceived |
|
||||
|
||||
---
|
||||
|
||||
## URL do Webhook
|
||||
|
||||
Após deploy:
|
||||
```
|
||||
https://automator.descomplicar.pt/webhook/<path>
|
||||
```
|
||||
|
||||
Modo teste (workflow inactivo):
|
||||
```
|
||||
https://automator.descomplicar.pt/webhook-test/<path>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Exemplos
|
||||
|
||||
### Webhook → Slack
|
||||
|
||||
```
|
||||
Webhook (POST /notify)
|
||||
↓
|
||||
Set (formatar)
|
||||
↓
|
||||
Slack (enviar)
|
||||
```
|
||||
|
||||
### Webhook → CRM
|
||||
|
||||
```
|
||||
Webhook (POST /lead)
|
||||
↓
|
||||
HTTP Request (criar no Desk)
|
||||
↓
|
||||
Email (notificar)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Testar
|
||||
|
||||
```javascript
|
||||
mcp__n8n__n8n_test_workflow({
|
||||
workflowId: "wf-xxx",
|
||||
inputData: {
|
||||
body: { "test": "data" },
|
||||
headers: { "Content-Type": "application/json" }
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
```bash
|
||||
curl -X POST https://automator.descomplicar.pt/webhook/meu-webhook \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"test": "data"}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Problema | Solução |
|
||||
|----------|---------|
|
||||
| 404 Not Found | Workflow não está activo |
|
||||
| 401 Unauthorized | Verificar autenticação |
|
||||
| Dados não chegam | Verificar responseMode |
|
||||
|
||||
---
|
||||
|
||||
*Skill v1.0 | Descomplicar®*
|
||||
Reference in New Issue
Block a user