Skip to main content
Prerequisite You should already have the Kernel react SDK installed (see the quickstart)
Now that users can link their repositories to your application, let’s build a workflow that leaves a message on each pull request created on a connected repository.
1

Build an event handler

This Django example
  1. filters on pull request events
  2. filters on connection links where the user has enabled a “preview” boolean
  3. clones the user repository
  4. leaves a comment on the pull request with the raw repository contents
class KernelWebhookDemoView(APIView):
    def post(self, request, *args, **kwargs):
        if 'pull_request' in request.data['payload'] and request.data['user_config']['enablePreview']:
            event_id = request.data['event_id']

            resp = requests.get(f"https://api.kernel.dev/link/clone/{event_id}", headers={
                "X-Kernel-Private-Key": "<your_private_api_key>"
            }, stream=True)
            resp.raise_for_status()

            resp = requests.post(f"https://api.kernel.dev/link/post-comment/{event_id}", headers={
                "X-Kernel-Private-Key": "<your_private_api_key>"
            }, json={
                "comment": resp.raw.read(),
            })
            resp.raise_for_status()
2

Configure webhook URL

Point Kernel to your newly created event handler by setting the webhook URL in the Terminal.

Event schema

NameDescription
event_idA Kernel uuid that uniquely identifies the event
client_idYour application’s unique identifier for the corresponding Link, typically matching a “Project” or “App” ID
user_configuser input from Link creation, in the schema you provided in the Terminal
payloadevent payload from upstream git provider (see github docs)