> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kernel.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Build A Workflow

> Learn how to use the API to build a workflow

<Info>
  **Prerequisite** You should already have the Kernel react SDK installed (see the [quickstart](quickstart))
</Info>

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.

<Steps>
  <Step title="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

    ```python theme={null}
    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()
    ```
  </Step>

  <Step title="Configure webhook URL">
    Point Kernel to your newly created event handler by setting the webhook URL in the [Terminal](https://terminal.kernel.dev/).
  </Step>
</Steps>

### Event schema

| Name         | Description                                                                                                                   |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| event\_id    | A Kernel uuid that uniquely identifies the event                                                                              |
| client\_id   | Your application's unique identifier for the corresponding Link, typically matching a "Project" or "App" ID                   |
| user\_config | user input from Link creation, in the schema you provided in the Terminal                                                     |
| payload      | event payload from upstream git provider (see [github docs](https://docs.github.com/en/webhooks/webhook-events-and-payloads)) |
