Skip to content

Commit e6d0506

Browse files
committed
[Notifier][Webhook] Added documentation for Webhook in combination with the Notifier component
1 parent 0b58658 commit e6d0506

File tree

2 files changed

+56
-5
lines changed

2 files changed

+56
-5
lines changed

notifier.rst

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ to send SMS messages to mobile phones. This feature requires subscribing to
5555
a third-party service that sends SMS messages. Symfony provides integration
5656
with a couple popular SMS services:
5757

58-
================== ===================================== ===========================================================================
59-
Service Package DSN
60-
================== ===================================== ===========================================================================
58+
================== ===================================== ========================================================================================================================= ===============
59+
Service Package DSN Webhook support
60+
================== ===================================== ========================================================================================================================= ===============
6161
`46elks`_ ``symfony/forty-six-elks-notifier`` ``forty-six-elks://API_USERNAME:API_PASSWORD@default?from=FROM``
6262
`AllMySms`_ ``symfony/all-my-sms-notifier`` ``allmysms://LOGIN:APIKEY@default?from=FROM``
6363
`AmazonSns`_ ``symfony/amazon-sns-notifier`` ``sns://ACCESS_KEY:SECRET_KEY@default?region=REGION``
@@ -95,10 +95,10 @@ Service Package DSN
9595
`SpotHit`_ ``symfony/spot-hit-notifier`` ``spothit://TOKEN@default?from=FROM``
9696
`Telnyx`_ ``symfony/telnyx-notifier`` ``telnyx://API_KEY@default?from=FROM&messaging_profile_id=MESSAGING_PROFILE_ID``
9797
`TurboSms`_ ``symfony/turbo-sms-notifier`` ``turbosms://AUTH_TOKEN@default?from=FROM``
98-
`Twilio`_ ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM``
98+
`Twilio`_ ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM`` yes
9999
`Vonage`_ ``symfony/vonage-notifier`` ``vonage://KEY:SECRET@default?from=FROM``
100100
`Yunpian`_ ``symfony/yunpian-notifier`` ``yunpian://APIKEY@default``
101-
================== ===================================== ===========================================================================
101+
================== ===================================== ========================================================================================================================= ===============
102102

103103
.. versionadded:: 6.1
104104

@@ -116,6 +116,12 @@ Service Package DSN
116116
were introduced in Symfony 6.3.
117117
The ``from`` option in ``Smsapi`` DSN is optional since Symfony 6.3.
118118

119+
.. tip::
120+
121+
Some third party transports, when using the API, support status callback
122+
via webhooks. See the :doc:`Webhook documentation </webhook>` for more
123+
details.
124+
119125
To enable a texter, add the correct DSN in your ``.env`` file and
120126
configure the ``texter_transports``:
121127

webhook.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,48 @@ final readonly class WebhookListener implements ConsumerInterface
130130
// Handle the mail engagement event
131131
}
132132
}
133+
134+
Usage in combination with the Notifier component
135+
------------------------------------------------
136+
137+
The usage of the Webhook component when using a third-party transport in
138+
the Notifier is very similar to the usage with the Mailer.
139+
140+
Currently, the following third-party sms transports support webhooks:
141+
142+
============ ==========================================
143+
SMS service Parser service name
144+
============ ==========================================
145+
Twilio ``notifier.webhook.request_parser.twilio``
146+
============ ==========================================
147+
148+
.. versionadded:: 6.3
149+
150+
Webhook support for the Twilio service was introduced in Symfony 6.3.
151+
152+
For SMS transports, an additional ``SmsEvent`` is available in the RemoteEvent
153+
consumer::
154+
155+
use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
156+
use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
157+
use Symfony\Component\RemoteEvent\Event\Sms\SmsEvent;
158+
use Symfony\Component\RemoteEvent\RemoteEvent;
159+
160+
#[AsRemoteEventConsumer('notifier_twilio')]
161+
final readonly class WebhookListener implements ConsumerInterface
162+
{
163+
public function consume(RemoteEvent $event): void
164+
{
165+
if ($event instanceof SmsEvent) {
166+
$this->handleSmsEvent($event);
167+
} else {
168+
// This is not an sms event
169+
return;
170+
}
171+
}
172+
173+
private function handleSmsEvent(SmsEvent $event): void
174+
{
175+
// Handle the sms event
176+
}
177+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy