@funnelchat-hq/sdk 0.3.0 → 0.3.1

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.
package/README.md CHANGED
@@ -40,16 +40,14 @@ Is the phone someone else's? Send them a page that shows the QR instead: `const
40
40
 
41
41
  ### 3. Send a message
42
42
 
43
- The contact goes first; then the text, from your number:
43
+ One call, from your number to a phone (with country code, digits only):
44
44
 
45
45
  ```ts
46
- const contact = await funnelchat.contacts.create({ phone: '5491100000000', name: 'Ana' }); // with country code, digits only
47
-
48
- const { message } = await funnelchat.messages.sendDirect({ device_id: device.id, contact_id: contact.id, text: 'Hi Ana!' });
49
- console.log(message.id, message.status); // 1002 'queued'
46
+ const { message } = await funnelchat.messages.sendDirect({ device_id: device.id, phone: '5491100000000', text: 'Hi Ana!' });
47
+ console.log(message.id, message.contact_id, message.status); // 1002 2001 'queued'
50
48
  ```
51
49
 
52
- The answer is the queued message: accepted is not delivered yet. With an official number, free text only goes within 24 hours of the contact's last message; after that, an [approved template](#templates).
50
+ If that phone is not a contact yet, it is created in the workspace of your key; `message.contact_id` is its id. The answer is the queued message: accepted is not delivered yet. With an official number, free text only goes within 24 hours of the contact's last message, so the first message to a new contact is an [approved template](#templates).
53
51
 
54
52
  ### 4. Know when it was read
55
53
 
@@ -71,7 +69,7 @@ app.post('/hooks/funnelchat', express.raw({ type: 'application/json' }), (req, r
71
69
  });
72
70
  ```
73
71
 
74
- The status goes `sent`, `delivered`, `read` (or `failed`, with `error`). You can also ask for it: `(await funnelchat.messages.get(contact.id, message.id)).status`. More in [Webhooks](#webhooks).
72
+ The status goes `sent`, `delivered`, `read` (or `failed`, with `error`). You can also ask for it: `funnelchat.messages.get(contactId, messageId)`, with `message.contact_id` and `message.id`. More in [Webhooks](#webhooks).
75
73
 
76
74
  ## Receive messages
77
75
 
@@ -191,10 +189,10 @@ if (window.is_open) {
191
189
  }
192
190
  ```
193
191
 
194
- - `contacts.create({ phone })` (7 to 15 digits) answers the existing contact when that phone is already there. A contact has to exist before you send it anything.
192
+ - **By phone, without `contact_id`:** `sendDirect` and `templates.send` take `phone` (7 to 15 digits, with country code) and create the contact in the workspace of your key when it does not exist yet, as `contacts.upsert` would; the contact stays even if a rule then stops the send. With an official number you can send `whatsapp_id` (Meta's id of the person, such as `US.13491208655302741918`) instead of `phone`; with a QR number that is a `422`. A phone that is a contact of another workspace of your account answers `404`, and nothing is created or sent. With `contact_id` too, `phone` or `whatsapp_id` must be that contact's: otherwise `422 recipient_mismatch`. Creating the contact takes **Contacts and conversations → Edit**, which **Send** includes.
195
193
  - `message.id` is the same `message_id` of `message.status_changed`. With it, `funnelchat.messages.get(2001, message.id)` tells you how it is going: `status` moves from `queued` to `sent`, `delivered`, `read` or `failed`, and a `failed` one carries `error` (`code`, `title` and `reason`).
196
194
  - `client_reference` (1 to 64 visible ASCII characters, no spaces) comes back in the history of the contact and in `message.status_changed`.
197
- - `send` is `POST /api/v1/contacts/{contact}/message` and checks the `phone` (or `whatsapp_id`) of the body against the contact of the route: when it does not match, `422 recipient_mismatch`. `sendDirect` is `POST /api/v1/message/send-message`, with `device_id` and `contact_id` in the body.
195
+ - `send` is `POST /api/v1/contacts/{contact}/message` and checks the `phone` (or `whatsapp_id`) of the body against the contact of the route: when it does not match, `422 recipient_mismatch`. `sendDirect` is `POST /api/v1/message/send-message`, with `device_id` and the recipient (`phone`, `whatsapp_id` or `contact_id`) in the body.
198
196
  - Contact cards (`sendContactCard`) return `{ messages }`, one per card; a forward (`forward`) one item per destination with its `message` (or `null` when that destination was blocked); a template (`templates.send`) and a form (`sendForm`) `{ message }`.
199
197
 
200
198
  **A file by URL.** `file` is the URL of the file. When it does not end in a known extension (a signed URL, or one without extension), say what it is with `file_type` and, for a document, the name it arrives with:
@@ -217,8 +215,7 @@ Without `file_type`, a URL without a known extension answers `422` with `errors.
217
215
 
218
216
  ```ts
219
217
  const { message } = await funnelchat.templates.send(3, '45', {
220
- phone: '5491100000000',
221
- contact_id: 2001,
218
+ phone: '5491100000000', // a new phone becomes a contact, as with sendDirect
222
219
  template_variables: { body: ['Lucía'] }, // the body variables, in order
223
220
  });
224
221
  ```
package/dist/index.cjs CHANGED
@@ -594,14 +594,28 @@ var routes = [
594
594
  { "method": "GET", "path": "/api/v1/forms/families/{familyId}/versions", "operationId": "pendingForms.versions", "domain": "conversations", "permission": "conversations:read", "tag": "WhatsappForm", "summary": "The versions of a form", "pending": true },
595
595
  { "method": "GET", "path": "/api/v1/forms/templates", "operationId": "pendingForms.templates", "domain": "conversations", "permission": "conversations:read", "tag": "WhatsappForm", "summary": "Templates to start a form", "pending": true },
596
596
  { "method": "GET", "path": "/api/v1/groups", "operationId": "group.index", "domain": "communities", "permission": "communities:read", "tag": "Grupos", "summary": "Listar grupos", "pending": false },
597
+ { "method": "POST", "path": "/api/v1/groups", "operationId": "apiGroupAction.create", "domain": "communities", "permission": "communities:operate", "tag": "Acciones de grupo", "summary": "Crea un grupo", "pending": false },
597
598
  { "method": "GET", "path": "/api/v1/groups/{group}", "operationId": "group.show", "domain": "communities", "permission": "communities:read", "tag": "Grupos", "summary": "Ver un grupo", "pending": false },
598
599
  { "method": "GET", "path": "/api/v1/groups/{group}/actions", "operationId": "group.actions", "domain": "communities", "permission": "communities:read", "tag": "Grupos", "summary": "Listar las acciones de sesi\xF3n sobre un grupo", "pending": false },
600
+ { "method": "POST", "path": "/api/v1/groups/{group}/admins", "operationId": "apiGroupAction.promoteAdmins", "domain": "communities", "permission": "communities:operate", "tag": "Acciones de grupo", "summary": "Promueve tel\xE9fonos a administrador", "pending": false },
601
+ { "method": "POST", "path": "/api/v1/groups/{group}/admins/remove", "operationId": "apiGroupAction.demoteAdmins", "domain": "communities", "permission": "communities:operate", "tag": "Acciones de grupo", "summary": "Quita el rol de administrador a tel\xE9fonos", "pending": false },
602
+ { "method": "PUT", "path": "/api/v1/groups/{group}/description", "operationId": "apiGroupAction.updateDescription", "domain": "communities", "permission": "communities:operate", "tag": "Acciones de grupo", "summary": "Cambia la descripci\xF3n del grupo", "pending": false },
603
+ { "method": "GET", "path": "/api/v1/groups/{group}/invite-link/live", "operationId": "apiGroupAction.inviteLink", "domain": "communities", "permission": "communities:read", "tag": "Acciones de grupo", "summary": "Link de invitaci\xF3n vigente del grupo", "pending": false },
604
+ { "method": "POST", "path": "/api/v1/groups/{group}/invite-link/renew", "operationId": "apiGroupAction.renewInviteLink", "domain": "communities", "permission": "communities:operate", "tag": "Acciones de grupo", "summary": "Renueva el link de invitaci\xF3n del grupo", "pending": false },
605
+ { "method": "GET", "path": "/api/v1/groups/{group}/join-requests", "operationId": "apiGroupAction.joinRequests", "domain": "communities", "permission": "communities:read", "tag": "Acciones de grupo", "summary": "Solicitudes pendientes para unirse al grupo", "pending": false },
606
+ { "method": "POST", "path": "/api/v1/groups/{group}/join-requests/approve", "operationId": "apiGroupAction.approveJoinRequests", "domain": "communities", "permission": "communities:operate", "tag": "Acciones de grupo", "summary": "Aprueba solicitudes para unirse al grupo", "pending": false },
607
+ { "method": "POST", "path": "/api/v1/groups/{group}/join-requests/reject", "operationId": "apiGroupAction.rejectJoinRequests", "domain": "communities", "permission": "communities:operate", "tag": "Acciones de grupo", "summary": "Rechaza solicitudes para unirse al grupo", "pending": false },
599
608
  { "method": "GET", "path": "/api/v1/groups/{group}/messages", "operationId": "group.messages", "domain": "communities", "permission": "communities:read", "tag": "Grupos", "summary": "Listar los mensajes enviados a un grupo", "pending": false },
600
- { "method": "POST", "path": "/api/v1/groups/{group}/messages", "operationId": "pendingGroups.sendMessage", "domain": "communities", "permission": "communities:send", "tag": "GroupAction", "summary": "Send a message to a group", "pending": true },
609
+ { "method": "POST", "path": "/api/v1/groups/{group}/messages", "operationId": "apiGroupAction.sendMessage", "domain": "communities", "permission": "communities:send", "tag": "Acciones de grupo", "summary": "Mandar un mensaje a un grupo", "pending": false },
610
+ { "method": "PUT", "path": "/api/v1/groups/{group}/name", "operationId": "apiGroupAction.updateName", "domain": "communities", "permission": "communities:operate", "tag": "Acciones de grupo", "summary": "Cambia el nombre del grupo", "pending": false },
601
611
  { "method": "GET", "path": "/api/v1/groups/{group}/participant-events", "operationId": "group.participantEvents", "domain": "communities", "permission": "communities:read", "tag": "Participantes", "summary": "Listar entradas y salidas de un grupo", "pending": false },
612
+ { "method": "POST", "path": "/api/v1/groups/{group}/participants", "operationId": "apiGroupAction.addParticipants", "domain": "communities", "permission": "communities:operate", "tag": "Acciones de grupo", "summary": "Suma participantes al grupo", "pending": false },
613
+ { "method": "POST", "path": "/api/v1/groups/{group}/participants/remove", "operationId": "apiGroupAction.removeParticipants", "domain": "communities", "permission": "communities:operate", "tag": "Acciones de grupo", "summary": "Saca participantes del grupo", "pending": false },
614
+ { "method": "PUT", "path": "/api/v1/groups/{group}/photo", "operationId": "apiGroupAction.updatePhoto", "domain": "communities", "permission": "communities:operate", "tag": "Acciones de grupo", "summary": "Cambia la foto del grupo", "pending": false },
602
615
  { "method": "GET", "path": "/api/v1/groups/{group}/scheduled-messages", "operationId": "group.scheduledMessages", "domain": "communities", "permission": "communities:read", "tag": "Grupos", "summary": "Listar los env\xEDos programados que incluyen un grupo", "pending": false },
616
+ { "method": "PUT", "path": "/api/v1/groups/{group}/settings", "operationId": "apiGroupAction.updateSettings", "domain": "communities", "permission": "communities:operate", "tag": "Acciones de grupo", "summary": "Cambia si los miembros pueden escribir", "pending": false },
603
617
  { "method": "GET", "path": "/api/v1/groups/{groupUid}/metadata", "operationId": "groupMetadata.show", "domain": "communities", "permission": "communities:read", "tag": "Grupos", "summary": "Ver los datos actuales de un grupo en WhatsApp", "pending": false },
604
- { "method": "GET", "path": "/api/v1/groups/actions/{action}", "operationId": "pendingGroups.retrieveAction", "domain": "communities", "permission": "communities:read", "tag": "GroupAction", "summary": "A group action", "pending": true },
618
+ { "method": "GET", "path": "/api/v1/groups/actions/{action}", "operationId": "apiGroupAction.show", "domain": "communities", "permission": "communities:read", "tag": "Acciones de grupo", "summary": "Ver c\xF3mo sali\xF3 una acci\xF3n de grupo", "pending": true },
605
619
  { "method": "GET", "path": "/api/v1/groups/participants", "operationId": "group.participants", "domain": "communities", "permission": "communities:read", "tag": "Participantes", "summary": "Listar los participantes de un grupo", "pending": false },
606
620
  { "method": "GET", "path": "/api/v1/kanban-settings", "operationId": "kanbanSetting.index", "domain": "conversations", "permission": "conversations:read", "tag": "KanbanSetting", "summary": "Listar tableros", "pending": false },
607
621
  { "method": "POST", "path": "/api/v1/kanban-settings", "operationId": "kanbanSetting.store", "domain": "conversations", "permission": "conversations:write", "tag": "KanbanSetting", "summary": "Crear un tablero", "pending": false },
@@ -1448,7 +1462,7 @@ var Webhooks = class extends Resource {
1448
1462
  };
1449
1463
 
1450
1464
  // src/version.ts
1451
- var VERSION = "0.3.0";
1465
+ var VERSION = "0.3.1";
1452
1466
 
1453
1467
  // src/client.ts
1454
1468
  var BASE_URLS = {