Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,23 +360,23 @@ Use the delivery id to ignore repeats.

No phone numbers, names or message text in any payload. Every event is emitted by exactly one process.

| Event | Payload |
| ------------------------------------- | ---------------------------------------------------------------------------------------------- |
| `messagegate.message.queued` | `{ messageId, channel, templateKey, status, code?, at }` |
| `messagegate.message.sent` | same |
| `messagegate.message.delivered` | same |
| `messagegate.message.read` | same |
| `messagegate.message.failed` | same, `code` set |
| `messagegate.message.uncertain` | same, `code` set |
| `messagegate.message.expired` | same, `code: 'DEADLINE_PASSED'` |
| `messagegate.message.discarded` | same |
| `messagegate.message.fallback` | `{ messageId, channel, templateKey, status: 'fallback', code, at }` (`channel` = next channel) |
| `messagegate.message.received` | `{ inboundId, contactId, channel, replyTo, kind, buttonPayload?, media?: { status }, at }` |
| `messagegate.media.ready` | `{ inboundId, fileId, mime, size, at }` (`fileId` is the media library id) |
| `messagegate.media.failed` | `{ inboundId, code, at }` |
| `messagegate.contact.opted-out` | `{ channel, at }` |
| `messagegate.contact.unreachable` | `{ channel: 'whatsapp', at }` |
| `messagegate.template.status-changed` | template id, key, language, new status |
| Event | Payload |
| ------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| `messagegate.message.queued` | `{ messageId, channel, templateKey, status, code?, at }` |
| `messagegate.message.sent` | same |
| `messagegate.message.delivered` | same |
| `messagegate.message.read` | same |
| `messagegate.message.failed` | same, `code` set |
| `messagegate.message.uncertain` | same, `code` set |
| `messagegate.message.expired` | same, `code: 'DEADLINE_PASSED'` |
| `messagegate.message.discarded` | same |
| `messagegate.message.fallback` | `{ messageId, channel, templateKey, status: 'fallback', code, at }` (`channel` = next channel) |
| `messagegate.message.received` | `{ inboundId, contactId, channel, replyTo, kind, buttonPayload?, media?: { status }, at }` |
| `messagegate.media.ready` | `{ inboundId, fileId, mime, size, at }` (`fileId` is the media library id) |
| `messagegate.media.failed` | `{ inboundId, code, at }` |
| `messagegate.contact.opted-out` | `{ channel, at }`: opt-out keyword, `/stop`, Twilio `OptOutType=STOP`, Twilio 21610, seven.io 407004 |
| `messagegate.contact.unreachable` | `{ channel: 'whatsapp', at }` |
| `messagegate.template.status-changed` | template id, key, language, new status |

```js
strapi.eventHub.on('messagegate.message.read', ({ messageId, templateKey }) => {
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## [Unreleased]

### Fixed

- seven.io: the admin and README now say to set the webhook's request method to **JSON**. seven.io's default sends form fields, which MessageGate cannot read; such a signed webhook now logs a warning instead of being dropped without a trace.
- seven.io: SMS texts are cut at 1520 characters (the documented limit) instead of 1600, so texts between 1521 and 1600 characters no longer fail with code 401.
- seven.io: return code 101 for the single recipient is a rejection with the recipient's own error code instead of `uncertain`; 500 (no credit) and 501 (spending limit) mark the account unhealthy; 407004 (recipient unsubscribed) revokes SMS consent.
- seven.io: inbound SMS keep their real receive time (`time` is a Unix timestamp); HLR checks return `roaming` from the documented object.
- Twilio: error 21610 (recipient replied STOP) and an inbound `OptOutType=STOP` (Advanced Opt-Out) revoke consent for the channel, so later sends stop at the consent check instead of failing at Twilio. Error 21611 (sender queue full) is retried.
- Telegram: long texts with `&`, `<` or `>` are no longer cut inside an HTML entity (the Bot API refused them); the 4096 limit counts visible characters.
- Webhook URLs, Twilio status callbacks, signed file links and the webhook raw-body capture follow `api.rest.prefix`. With a custom prefix every webhook used to fail the signature check.
- Outgoing texts are never cut inside an emoji.
- `Retry-After` given as an HTTP date is honoured (capped at 24 hours).

### Documentation

- `docs/audits/2026-11-20-provider-apis.md`: audit of all four provider APIs against their official specs and docs.

## [1.1.2](https://github.com/Schero94/Magic-MessageGate/compare/messagegate-v1.1.1...messagegate-v1.1.2) (2026-11-18)


Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ Then, in **Accounts → Connect a channel → WhatsApp**, pick one of two ways:

Copy the webhook URL shown for the account into the provider's status and inbound settings so delivery receipts and replies arrive.

- **seven.io**: dashboard → Developer → Webhooks, add the URL for the events `dlr` and `sms_mo` and set the **request method to JSON**. seven.io's default sends form fields, which MessageGate ignores (the Strapi log then says so). SMS texts are cut at 1520 characters, seven.io's limit.
- **Twilio**: set the URL as the status callback and the incoming-message webhook of the number or Messaging Service. With Advanced Opt-Out, a `STOP` reply revokes consent even when the keyword is not in MessageGate's own list, and Twilio error 21610 (recipient unsubscribed) does the same.

Webhook URLs and file links follow `api.rest.prefix` from `config/api` (default `/api`).

### RCS (Twilio)

1. Get an RCS sender approved in the Twilio Console and add it to a **Messaging Service**.
Expand Down
6 changes: 2 additions & 4 deletions admin/src/pages/Accounts/AccountWizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
credentialPayload,
fieldsFor,
validateCredentials,
webhookHint,
} from '../../utils/providers.mjs';
import { reasonText } from '../../utils/reasons';

Expand Down Expand Up @@ -614,10 +615,7 @@ export const AccountWizard = ({ mode, account, hasDefault, onClose, onSaved }) =
name="webhookUrl"
label={t('accounts.webhookUrl', 'Webhook URL')}
value={result.account.webhookUrl}
hint={t(
'accounts.webhookUrl.hint',
'Enter it in the provider console for delivery and read receipts.'
)}
hint={webhookHint(t, result.account.provider)}
/>
) : null}
{result.account.provider === 'meta' && !result.steps ? (
Expand Down
3 changes: 2 additions & 1 deletion admin/src/pages/Accounts/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useReturnFocus } from '../../hooks/useReturnFocus';
import { ToneBadge } from '../../components/ui/StatusBadge';
import { useT } from '../../hooks/useT';
import { channelLabels, providerLabels } from '../../utils/channels';
import { webhookHint } from '../../utils/providers.mjs';
import { reasonText } from '../../utils/reasons';
import { AccountWizard } from './AccountWizard';

Expand Down Expand Up @@ -149,7 +150,7 @@ const AccountCard = ({ account, rbac, onEdit, onChanged }) => {
hint={
account.provider === 'telegram'
? t('accounts.webhookUrl.telegram', 'Registered with Telegram automatically on "Test connection".')
: t('accounts.webhookUrl.hint', 'Enter it in the provider console for delivery and read receipts.')
: webhookHint(t, account.provider)
}
/>
) : (
Expand Down
2 changes: 2 additions & 0 deletions admin/src/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
"accounts.webhookUrl": "Webhook-URL",
"accounts.webhookUrl.hint": "In der Konsole des Anbieters eintragen, für Zustell- und Lesebestätigungen.",
"accounts.webhookUrl.missing": "Keine öffentliche URL konfiguriert (server.url), daher keine Webhook-URL. Zustellberichte brauchen sie.",
"accounts.webhookUrl.seven": "seven.io-Dashboard > Entwickler > Webhooks: diese URL für die Ereignisse „dlr“ und „sms_mo“ mit der Anfragemethode JSON eintragen.",
"accounts.webhookUrl.telegram": "Wird bei „Verbindung testen“ automatisch bei Telegram registriert.",
"accounts.webhookUrl.twilio": "Twilio Console: als Status-Callback und als Webhook für eingehende Nachrichten der Nummer oder des Messaging Service eintragen.",
"accounts.wizard.checkTitle": "Gespeichert, aber der Test schlug fehl",
"accounts.wizard.choose": "Welcher Kanal soll verbunden werden?",
"accounts.wizard.connectTest": "Verbinden und testen",
Expand Down
2 changes: 2 additions & 0 deletions admin/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
"accounts.webhookUrl": "Webhook URL",
"accounts.webhookUrl.hint": "Enter it in the provider console for delivery and read receipts.",
"accounts.webhookUrl.missing": "No public URL configured (server.url), so no webhook URL can be shown. Delivery receipts need it.",
"accounts.webhookUrl.seven": "seven.io dashboard > Developer > Webhooks: add this URL for the events \"dlr\" and \"sms_mo\" with the request method JSON.",
"accounts.webhookUrl.telegram": "Registered with Telegram automatically on \"Test connection\".",
"accounts.webhookUrl.twilio": "Twilio Console: use it as the status callback and the incoming message webhook of the number or Messaging Service.",
"accounts.wizard.checkTitle": "Saved, but the test failed",
"accounts.wizard.choose": "Which channel do you want to connect?",
"accounts.wizard.connectTest": "Connect and test",
Expand Down
2 changes: 2 additions & 0 deletions admin/src/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
"accounts.webhookUrl": "URL del webhook",
"accounts.webhookUrl.hint": "Introdúcela en la consola del proveedor para las confirmaciones de entrega y lectura.",
"accounts.webhookUrl.missing": "No hay URL pública configurada (server.url), así que no se puede mostrar la URL del webhook. Los informes de entrega la necesitan.",
"accounts.webhookUrl.seven": "Panel de seven.io > Developer > Webhooks: añade esta URL para los eventos «dlr» y «sms_mo» con el método de solicitud JSON.",
"accounts.webhookUrl.telegram": "Se registra automáticamente en Telegram al pulsar «Probar conexión».",
"accounts.webhookUrl.twilio": "Twilio Console: úsala como status callback y como webhook de mensajes entrantes del número o del Messaging Service.",
"accounts.wizard.checkTitle": "Guardada, pero la prueba falló",
"accounts.wizard.choose": "¿Qué canal quieres conectar?",
"accounts.wizard.connectTest": "Conectar y probar",
Expand Down
2 changes: 2 additions & 0 deletions admin/src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
"accounts.webhookUrl": "URL du webhook",
"accounts.webhookUrl.hint": "À saisir dans la console du fournisseur pour les accusés de livraison et de lecture.",
"accounts.webhookUrl.missing": "Aucune URL publique configurée (server.url), donc aucune URL de webhook. Les accusés de livraison en ont besoin.",
"accounts.webhookUrl.seven": "Tableau de bord seven.io > Developer > Webhooks : ajoutez cette URL pour les événements « dlr » et « sms_mo » avec la méthode de requête JSON.",
"accounts.webhookUrl.telegram": "Enregistré automatiquement auprès de Telegram lors de « Tester la connexion ».",
"accounts.webhookUrl.twilio": "Twilio Console : utilisez-la comme status callback et comme webhook des messages entrants du numéro ou du Messaging Service.",
"accounts.wizard.checkTitle": "Enregistré, mais le test a échoué",
"accounts.wizard.choose": "Quel canal voulez-vous connecter ?",
"accounts.wizard.connectTest": "Connecter et tester",
Expand Down
2 changes: 2 additions & 0 deletions admin/src/translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
"accounts.webhookUrl": "URL do webhook",
"accounts.webhookUrl.hint": "Informe no console do provedor para as confirmações de entrega e leitura.",
"accounts.webhookUrl.missing": "Nenhuma URL pública configurada (server.url), por isso não há URL de webhook. Os relatórios de entrega precisam dela.",
"accounts.webhookUrl.seven": "Painel da seven.io > Developer > Webhooks: adicione esta URL para os eventos \"dlr\" e \"sms_mo\" com o método de requisição JSON.",
"accounts.webhookUrl.telegram": "Registrada automaticamente no Telegram ao usar \"Testar conexão\".",
"accounts.webhookUrl.twilio": "Twilio Console: use-a como status callback e como webhook de mensagens recebidas do número ou do Messaging Service.",
"accounts.wizard.checkTitle": "Salva, mas o teste falhou",
"accounts.wizard.choose": "Qual canal você quer conectar?",
"accounts.wizard.connectTest": "Conectar e testar",
Expand Down
26 changes: 26 additions & 0 deletions admin/src/utils/providers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,29 @@ export function credentialPayload(provider, values, channel = PROVIDER_CHANNEL[p
}
return config;
}

/**
* Where the owner enters an account's webhook URL, per provider. seven.io
* posts form fields unless the hook's request method is JSON, which
* MessageGate needs to read delivery reports and replies
* (https://docs.seven.io/en/rest-api/endpoints/webhooks).
*
* @param {(id: string, fallback: string, values?: object) => string} t - Translator.
* @param {string} provider
* @returns {string}
*/
export function webhookHint(t, provider) {
if (provider === 'seven') {
return t(
'accounts.webhookUrl.seven',
'seven.io dashboard > Developer > Webhooks: add this URL for the events "dlr" and "sms_mo" with the request method JSON.'
);
}
if (provider === 'twilio') {
return t(
'accounts.webhookUrl.twilio',
'Twilio Console: use it as the status callback and the incoming message webhook of the number or Messaging Service.'
);
}
return t('accounts.webhookUrl.hint', 'Enter it in the provider console for delivery and read receipts.');
}
Loading