To integrate webhooks into your application, follow these steps to set up an HTTP or HTTPS endpoint function that can accept webhook requests with a POST method:
This code snippet is a webhook function configured to check that the event type was received, to handle the event, and return a 200 response.
# Django
from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework import status
@api_view(["POST"])
def listen_webhook(req):
"""
Listen Webhook
"""
webhook_payload = req.data
event = webhook_payload["event"]
if event == "form.created":
account_id = webhook_payload["account"]["id"]
form_id = webhook_payload["form"]["id"]
elif event == "form.submit":
account_id = webhook_payload["account"]["id"]
form_id = webhook_payload["form"]["id"]
form_submission_id = webhook_payload["form_submission"]["id"]
# handle your application logics here using the webhook payload data
response = {}
response[“status”] = “success”
return Response(response, status=status.HTTP_200_OK)
# Laravel
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class ListenWebhookController extends Controller
{
public function listenWebhook(Request $request)
{
$webhookPayload = $request->all();
$event = $webhookPayload["event"];
if ($event == "form.created") {
$accountId = $webhookPayload["account"]["id"];
$formId = $webhookPayload["form"]["id"];
} elseif ($event == "form.submit") {
$accountId = $webhookPayload["account"]["id"];
$formId = $webhookPayload["form"]["id"];
$formSubmissionId = $webhookPayload["form_submission"]["id"];
}
# handle your application logics here using the webhook payload data
$response = [];
$response["status"] = "success";
return response()->json($response, 200);
}
}
To retrieve all submitted values using a form submission ID, you can utilize the Builder / Get Single Submitted Entry Details API. This API allows you to fetch detailed information about a specific form submission, providing access to all the submitted values associated with that submission.
You can obtain selected field submitted values using a form submission ID and field slugs by utilizing the Form Builder / Get Single Submitted Entry Details Via Field Slug API. This API enables you to specify the form submission ID and the specific field slugs for which you want to retrieve submitted values, providing targeted access to the requested information.