The webhooks app enables your app to push real-time notifications to other platforms. The Vanty Starter Kit uses HTTPS to send these notifications as a JSON payload. You can then use these notifications to execute actions in your integrated systems.
You can use webhook event notifications to your other platforms when an event occurs, for example:
Defined your custom events that you may want to listen to.
apps/webhooks/events.py
class WebhookEvent(models.TextChoices):
"""
Webhook events
Define your custom events here
"""
user_signed_up = "user.signed_up"
payment_confirmed = "payments.payment_confirmed"
new_subscriber = "newsletter.new_subscriber" # a new event
Notes
newsletter.new_subscriber
. app_name.event
. This is good
practice to avoid potential conflicts later as you add more events.Add a webhook signal to listen for the webhook event
apps/newsletter/views.py
from apps.webhooks.events import WebhookEvent
from apps.webhooks.signals import webhook_signal
def new_subscriber_view(request):
.... # other logic
webhook_signal.send(
request.user.__class__,
event=WebhookEvent.new_subscriber,
data={"email": email},
)
Notes
A webhook target is an endpoint that you will send webhook events to. Webhook targets can be added directly from the dashboard. To create a new webhook, add the name, and URL of the target endpoint, select the events you want to listen to and set the status to enabled.
Basic information about failed/successful webhook events is available on the detail page for each webhook.
Success
Error
Warning
Info