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

[Notifier][Webhook] Added documentation for Webhook in combination with the Notifier component #19269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2023
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
16 changes: 11 additions & 5 deletions 16 notifier.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ to send SMS messages to mobile phones. This feature requires subscribing to
a third-party service that sends SMS messages. Symfony provides integration
with a couple popular SMS services:

================== ===================================== ===========================================================================
Service Package DSN
================== ===================================== ===========================================================================
================== ===================================== ========================================================================================================================= ===============
Service Package DSN Webhook support
================== ===================================== ========================================================================================================================= ===============
`46elks`_ ``symfony/forty-six-elks-notifier`` ``forty-six-elks://API_USERNAME:API_PASSWORD@default?from=FROM``
`AllMySms`_ ``symfony/all-my-sms-notifier`` ``allmysms://LOGIN:APIKEY@default?from=FROM``
`AmazonSns`_ ``symfony/amazon-sns-notifier`` ``sns://ACCESS_KEY:SECRET_KEY@default?region=REGION``
Expand Down Expand Up @@ -95,10 +95,10 @@ Service Package DSN
`SpotHit`_ ``symfony/spot-hit-notifier`` ``spothit://TOKEN@default?from=FROM``
`Telnyx`_ ``symfony/telnyx-notifier`` ``telnyx://API_KEY@default?from=FROM&messaging_profile_id=MESSAGING_PROFILE_ID``
`TurboSms`_ ``symfony/turbo-sms-notifier`` ``turbosms://AUTH_TOKEN@default?from=FROM``
`Twilio`_ ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM``
`Twilio`_ ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM`` yes
`Vonage`_ ``symfony/vonage-notifier`` ``vonage://KEY:SECRET@default?from=FROM``
`Yunpian`_ ``symfony/yunpian-notifier`` ``yunpian://APIKEY@default``
================== ===================================== ===========================================================================
================== ===================================== ========================================================================================================================= ===============

.. versionadded:: 6.1

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

.. tip::

Some third party transports, when using the API, support status callback
via webhooks. See the :doc:`Webhook documentation </webhook>` for more
details.

To enable a texter, add the correct DSN in your ``.env`` file and
configure the ``texter_transports``:

Expand Down
47 changes: 46 additions & 1 deletion 47 webhook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ With this done, you can now add a RemoteEvent consumer to react to the webhooks:
use Symfony\Component\RemoteEvent\RemoteEvent;

#[AsRemoteEventConsumer('mailer_mailgun')]
final readonly class WebhookListener implements ConsumerInterface
class WebhookListener implements ConsumerInterface
{
public function consume(RemoteEvent $event): void
{
Expand All @@ -130,3 +130,48 @@ With this done, you can now add a RemoteEvent consumer to react to the webhooks:
// Handle the mail engagement event
}
}

Usage in combination with the Notifier component
------------------------------------------------

The usage of the Webhook component when using a third-party transport in
the Notifier is very similar to the usage with the Mailer.

Currently, the following third-party sms transports support webhooks:

============ ==========================================
SMS service Parser service name
============ ==========================================
Twilio ``notifier.webhook.request_parser.twilio``
============ ==========================================

.. versionadded:: 6.3

The support for Twilio was introduced in Symfony 6.3.

For SMS transports, an additional ``SmsEvent`` is available in the RemoteEvent
consumer::

use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
use Symfony\Component\RemoteEvent\Event\Sms\SmsEvent;
use Symfony\Component\RemoteEvent\RemoteEvent;

#[AsRemoteEventConsumer('notifier_twilio')]
class WebhookListener implements ConsumerInterface
{
public function consume(RemoteEvent $event): void
{
if ($event instanceof SmsEvent) {
$this->handleSmsEvent($event);
} else {
// This is not an sms event
return;
}
}

private function handleSmsEvent(SmsEvent $event): void
{
// Handle the sms event
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.