Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1766878

Browse filesBrowse files
committed
feature #19269 [Notifier][Webhook] Added documentation for Webhook in combination with the Notifier component (TimoBakx)
This PR was merged into the 6.3 branch. Discussion ---------- [Notifier][Webhook] Added documentation for Webhook in combination with the Notifier component The consumer slightly differs between the Mailer and Notifier implementations, so I think it is good have a bit of extra documentation for that, separately. Commits ------- 31687e4 [Notifier][Webhook] Added documentation for Webhook in combination with the Notifier component
2 parents 19a87a6 + 31687e4 commit 1766878
Copy full SHA for 1766878

File tree

2 files changed

+57
-6
lines changed
Filter options

2 files changed

+57
-6
lines changed

‎notifier.rst

Copy file name to clipboardExpand all lines: notifier.rst
+11-5Lines 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

Copy file name to clipboardExpand all lines: webhook.rst
+46-1Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ With this done, you can now add a RemoteEvent consumer to react to the webhooks:
106106
use Symfony\Component\RemoteEvent\RemoteEvent;
107107

108108
#[AsRemoteEventConsumer('mailer_mailgun')]
109-
final readonly class WebhookListener implements ConsumerInterface
109+
class WebhookListener implements ConsumerInterface
110110
{
111111
public function consume(RemoteEvent $event): void
112112
{
@@ -130,3 +130,48 @@ With this done, you can now add a RemoteEvent consumer to react to the webhooks:
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+
The support for Twilio 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+
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.