This tutorial shows you how to build powerful automations that combine webhooks, APIs, and AI capabilities. You’ll learn to create a system that can receive data via webhooks, process it with custom code, and use AI to generate intelligent summaries—all without managing traditional databases.

What You’ll Build

A complete API and webhook integration with:

  • A webhook endpoint to receive external data
  • Custom code processing for data transformation
  • AI-powered text summarization using Knowledge Client
  • Seamless event-driven communication between components

This solution demonstrates how Prisme.ai can transform simple API integrations into intelligent data processing systems using generative AI to extract insights from incoming data.

Prerequisites

Before starting this tutorial, make sure you have:

  • An active Prisme.ai account
  • The Knowledge Client app installed in your workspace
  • The Custom Code app installed in your workspace

Step 1: Creating Your Workspace

Let’s start by setting up a dedicated workspace for our webhook integrations:

1

Access AI Builder

Log in to your Prisme.ai account and navigate to the AI Builder product

2

Create a New Workspace

Click the “Create Workspace” button to start a new project

3

Configure Workspace Settings

  • Name your workspace “AI API Integrator” (or a name of your choice)
  • Add an appropriate description and icon
  • Configure any additional settings as needed

Step 2: Creating the Summary Generation Automation

First, let’s create the automation that will use AI to generate summaries from JSON data:

1

Navigate to Automations

In your workspace, go to the Automations section

2

Create a New Automation

Click “Create Automation” and configure the following:

  • Name: “Generate Summary”
  • Slug: “generate-summary”
3

Configure the Automation

Use the following YAML configuration:

slug: generate-summary
name: Generate Summary
do:
  - set:
      name: stringifiedData
      value: '{% json({{payload.data}}) %}'
  - Knowledge Client.chat-completion:
      messages:
        - role: system
          content: Create a brief summary from a JSON object, focusing on key details and overarching information contained within, ensuring clarity and conciseness in the summary.
        - role: user
          content: '{{stringifiedData}}'
      output: genAIData
when:
  events:
    - summary-event
output: '{{genAIData.response}}'
4

Save the Automation

Click “Save” to create your summary generation automation

Notice that we first parse the JSON object as a string using the json() utility function. This is necessary because language models expect text input, not structured JSON. Learn more about this in the condition documentation.

Step 3: Creating the Webhook Automation

Now, let’s create the webhook automation that will receive data and trigger the summary generation:

1

Create Another Automation

Back in the Automations section, click “Create Automation” again

2

Configure the Webhook Automation

Use the following settings:

  • Name: “Webhook”
  • Slug: “webhook”
  • Trigger: Enable “Endpoint” to make it accessible via URL
3

Set Up the Automation Logic

Configure the automation with this YAML:

slug: webhook
name: Webhook
do:
  - Custom Code.run function:
      function: CleanData
      parameters:
        data: '{{query}}'
      output: cleanData
  - emit:
      payload:
        body: '{{body}}'
        headers: '{{headers}}'
        data: '{{cleanData}}'
      event: summary-event
when:
  endpoint: true
output:
  message: '{{cleanData}}'
4

Save the Webhook Automation

Click “Save” to create your webhook endpoint automation

5

Get Your Webhook URL

  • Click on the “Triggered when” section of your automation
  • Look for the blue “Get the link” button and click it
  • Copy the displayed URL, which will look like: https://api.studio.prisme.ai/v2/workspaces/YOUR-WorkspaceID/webhooks/webhook

Step 4: Configuring Custom Code

Now, let’s set up the Custom Code app to process our incoming data:

1

Access Custom Code App

Navigate to the Apps section in your workspace and open the Custom Code app

2

Create the CleanData Function

Configure the Custom Code app with the following YAML:

appName: Custom Code
slug: Custom Code
config:
  functions:
    CleanData:
      code: |-
        return data;
      parameters:
        data:
          type: object
          default: [
              {
                "id": 1,
                "name": "John Doe",
                "email": "john.doe@example.com",
                "isActive": true,
                "roles": ["admin", "user"]
              },
              {
                "id": 2,
                "name": "Jane Smith",
                "email": "jane.smith@example.com",
                "isActive": false,
                "roles": ["user"]
              }
            ]
3

Save the Custom Code Configuration

Click “Save” to apply your Custom Code settings

The Custom Code function includes a default value for testing purposes. In a real-world scenario, you would likely perform more complex data transformation operations here.

Step 5: Testing Your Webhook Integration

Let’s test our webhook and see the AI summary generation in action:

1

Prepare a Test Request

You can test your webhook by making an HTTP request to your webhook URL with query parameters, for example: https://api.studio.prisme.ai/v2/workspaces/YOUR-WorkspaceID/webhooks/webhook?city=Toulouse&country=France

2

Send the Request

Use a tool like curl, Postman, or simply enter the URL in your browser to trigger the webhook

3

Check the Response

The webhook should return a message containing the clean data

4

Verify Summary Generation

Check your activity logs to confirm that the summary-event was triggered and the AI generated a summary of the data:

{
  "city": "Toulouse",
  "country": "France"
}

Understanding HTTP Variables in Webhooks

When working with webhooks in Prisme.ai, several HTTP variables are automatically available at the root level inside your endpoint automation:

  • query: Contains query parameters from the URL
  • body: Contains the request body (for POST/PUT requests)
  • headers: Contains the HTTP request headers
  • method: Contains the HTTP method used (GET, POST, etc.)

In our webhook example, we’re passing the query variable to our Custom Code function and including both headers and body in the payload that triggers the summary-event.

Version Control and Deployment

To manage your webhook integrations effectively:

1

Save Your Current State

Use the “Pull” button in your workspace to create a new version

2

Create Additional Versions

As you make changes and improvements, create new versions to maintain a history of your work

3

Deploy Specific Versions

Select which version to deploy in your workspace settings

For more information, see the documentation on Version Control and RBAC.

Monitoring and Logs

Keep track of your webhook activity and performance:

1

Access Activity Logs

Navigate to the Activity section of your workspace to view detailed records of webhook calls, automation triggers, and AI operations

2

Set Up Alerts

Configure alerts for critical events or errors in your automations

3

Analyze Performance

Use logs to identify patterns, bottlenecks, or areas for improvement

Extending Your Webhook Integration

Your base webhook system is powerful, but consider these enhancements:

  • Authentication: Add API key validation or OAuth to secure your webhooks
  • Enhanced Processing: Implement more complex data transformations in your Custom Code
  • Multiple Endpoints: Create different webhook endpoints for various data sources or purposes
  • Error Handling: Add comprehensive error handling and retry mechanisms
  • Integration: Connect your webhooks to other systems like databases, messaging platforms, or CRMs

Next Steps