diff --git a/.agents/skills/evolution-api/SKILL.md b/.agents/skills/evolution-api/SKILL.md index 0409ba3..9bf5338 100644 --- a/.agents/skills/evolution-api/SKILL.md +++ b/.agents/skills/evolution-api/SKILL.md @@ -47,7 +47,26 @@ To fetch the QR code for scanning: --- -## 4. Troubleshooting: "Não foi possível conectar o dispositivo" / Connection Failure +## 4. Sending a Text Message (v2.x.x Payload Schema) +In Evolution API v2, the `POST /message/sendText/` endpoint expects a simplified body structure compared to v1. +- **Method**: `POST` +- **URL**: `https:///message/sendText/` +- **Headers**: + - `apikey`: `` + - `Content-Type`: `application/json` +- **Body**: +```json +{ + "number": "5585981145217", + "text": "Your message here", + "delay": 1200 +} +``` +*Note: Do not use the legacy `textMessage` or `options` wrappers (like `{ options: { delay: 1200 }, textMessage: { text: "..." } }`), as these will return a `400 Bad Request` in v2.* + +--- + +## 5. Troubleshooting: "Não foi possível conectar o dispositivo" / Connection Failure A common error during QR code scanning is `Não foi possível conectar o dispositivo` on the phone, while the API is stuck. This is caused by a corrupted Baileys session cache in the Evolution API container. ### Resolution Steps: @@ -60,7 +79,7 @@ A common error during QR code scanning is `Não foi possível conectar o disposi --- -## 5. Reference Implementation (Node.js/Express) +## 6. Reference Implementation (Node.js/Express) ```typescript import axios from 'axios'; diff --git a/server.ts b/server.ts index 639035a..160f9c4 100644 --- a/server.ts +++ b/server.ts @@ -1372,8 +1372,8 @@ export async function sendWhatsappNotification(phone: string, text: string) { await axios.post(`${apiUrl}/message/sendText/${instance}`, { number: cleanPhone, - options: { delay: 1200 }, - textMessage: { text } + text: text, + delay: 1200 }, { headers: { apikey: settings.evolutionApiKey } });