> For the complete documentation index, see [llms.txt](https://docs.snackprompt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snackprompt.com/bring-your-data-into-ai/how-to/get-started-with-integrations/how-to-integrate-with-make.md).

# How to Integrate with Make

Learn how to use the SnackPrompt AI Engine API to build powerful automations and AI-powered scenarios in Make (formerly Integromat).

### Overview

Make offers several ways to integrate external APIs into your automations:

| Method                | Use Case         | Description                                      |
| --------------------- | ---------------- | ------------------------------------------------ |
| **HTTP Module**       | Direct API calls | Make HTTP requests to any API                    |
| **Webhooks**          | Receive data     | Trigger scenarios when external events occur     |
| **JSON Module**       | Data processing  | Parse and create JSON structures                 |
| **OpenAI/AI Modules** | AI integration   | Combine with AI models for intelligent workflows |

### Integration Architecture

```
┌─────────────────────────────────────────────────────────┐
│                        Make                             │
│  ┌─────────────┐    ┌─────────────┐    ┌────────────┐   │
│  │   Trigger   │───▶│ HTTP Module │───▶│   Action  │   │
│  └─────────────┘    └──────┬──────┘    └────────────┘   │
│                            │                            │
│                     ┌──────▼──────┐                     │
│                     │    Router   │                     │
│                     │ (optional)  │                     │
│                     └──────┬──────┘                     │
└────────────────────────────┼────────────────────────────┘
                             │
                             ▼
              ┌──────────────────────────────┐
              │  SnackPrompt AI Engine API   │
              │  /v1/kb/search or /v1/kb/chat│
              └──────────────────────────────┘
```

***

### Method 1: HTTP Module (Recommended)

Use the **HTTP > Make a request** module to call the SnackPrompt AI Engine API directly.

#### Step 1: Create a New Scenario

1. Go to [make.com](https://make.com) and click **Create a new scenario**
2. Choose your trigger module (e.g., Webhook, Email, Schedule)

#### Step 2: Add HTTP Module

1. Click **+** to add a new module
2. Search for **HTTP**
3. Select **Make a request**

#### Step 3: Configure the Request

**For Search Endpoint:**

<table><thead><tr><th width="247">Field</th><th>Value</th></tr></thead><tbody><tr><td>URL</td><td><code>https://api-integrations.snackprompt.com/v1/kb/search</code></td></tr><tr><td>Method</td><td><code>POST</code></td></tr><tr><td>Body type</td><td><code>Raw</code></td></tr><tr><td>Content type</td><td><code>JSON (application/json)</code></td></tr></tbody></table>

**Headers:**

| Name        | Value          |
| ----------- | -------------- |
| `x-api-key` | `YOUR_API_KEY` |

**Request content (JSON):**

```json
{
  "query": "{{1.query}}",
  "filters": {
    "tenant_id": "YOUR_TENANT_ID"
  },
  "limit": 5
}
```

Replace `{{1.query}}` with the appropriate variable from your trigger module.

#### Step 4: Parse the Response

Check **Parse response** to automatically parse the JSON response into usable variables.

#### Step 5: Use the Results

The API returns a list of relevant documents in `items[]`. You can use them in subsequent modules:

* `{{2.items[].payload.original_text}}` - The document content
* `{{2.items[].score}}` - Relevance score
* `{{2.items[].payload.snack_item_id}}` - Document ID

***

### Method 2: Webhooks (Receive Requests)

Use when you want to **receive requests** and respond with knowledge base information.

#### Step 1: Create Webhook Trigger

1. Create a new scenario
2. Add **Webhooks > Custom webhook** as the trigger
3. Click **Add** to create a new webhook
4. Copy the webhook URL provided

#### Step 2: Add HTTP Module

Configure as shown in Method 1, using the webhook data:

**Request content:**

```json
{
  "query": "{{1.query}}",
  "filters": {
    "tenant_id": "YOUR_TENANT_ID"
  },
  "limit": 5
}
```

#### Step 3: Return Response

Add **Webhooks > Webhook response** module at the end:

| Field          | Value                              |
| -------------- | ---------------------------------- |
| Status         | `200`                              |
| Body           | `{{2.body}}` or formatted response |
| Custom headers | `Content-Type: application/json`   |

***

### Method 3: Chat Endpoint for Complete Responses

Use the `/v1/kb/chat` endpoint when you want the **API to handle all the RAG** and return a ready response.

#### Configuration

<table><thead><tr><th width="252">Field</th><th>Value</th></tr></thead><tbody><tr><td>URL</td><td><code>https://api-integrations.snackprompt.com/v1/kb/chat</code></td></tr><tr><td>Method</td><td><code>POST</code></td></tr><tr><td>Body type</td><td><code>Raw</code></td></tr><tr><td>Content type</td><td><code>JSON (application/json)</code></td></tr></tbody></table>

**Headers:**

| Name        | Value          |
| ----------- | -------------- |
| `x-api-key` | `YOUR_API_KEY` |

**Request content:**

```json
{
  "query": "{{1.message}}",
  "filters": {
    "tenant_id": "YOUR_TENANT_ID",
    "tag_names": ["Support", "FAQ"]
  }
}
```

#### Response

The API returns:

* `answer`: AI-generated response ready to use
* `sources`: Sources used to generate the response

Access with `{{2.answer}}` and `{{2.sources}}`.

***

### Method 4: With AI Modules (RAG Pipeline)

Combine the search API with Make's AI modules for custom RAG workflows.

#### RAG Scenario Structure

```
[Trigger] → [HTTP: Search API] → [Text Aggregator] → [OpenAI: Create Completion] → [Action]
```

#### Step 1: Search for Context

Use HTTP module to call `/v1/kb/search` as shown in Method 1.

#### Step 2: Format Context with Iterator + Aggregator

**Add Iterator module:**

* Array: `{{2.items}}`

**Add Text Aggregator module:**

* Source module: Iterator
* Text: `[{{3.i}}] {{3.payload.original_text}}`
* Row separator: `\n\n`

#### Step 3: Generate Response with OpenAI

**Add OpenAI > Create a Completion module:**

| Field    | Value                      |
| -------- | -------------------------- |
| Model    | `gpt-4` or `gpt-3.5-turbo` |
| Messages | System + User messages     |

**System Message:**

```
You are a helpful assistant. Answer the user's question based ONLY on the following context.

Context:
{{4.text}}

If the context doesn't contain relevant information, say "I don't have information about that."
```

**User Message:**

```
{{1.query}}
```

***

### Practical Use Cases

#### 1. Support Chatbot

```
[Webhook] → [HTTP: /chat] → [Webhook Response]
```

Simple chatbot that answers questions using your knowledge base.

#### 2. Email Auto-Responder

```
[Email: Watch] → [HTTP: /chat] → [Email: Send]
```

Automatically respond to customer emails with relevant information.

#### 3. Slack Integration

```
[Slack: Watch Channel] → [HTTP: /search] → [Slack: Post Message]
```

Answer questions posted in a Slack channel.

#### 4. Multi-Source RAG with Router

```
[Webhook] → [Router]
                │
                ├─[Filter: Sales]──→ [HTTP: tag=Sales] ───┐
                │                                          │
                └─[Filter: Support]→ [HTTP: tag=Support]──┼→ [Array Aggregator] → [OpenAI] → [Response]
```

Route queries to different knowledge bases based on topic.

#### 5. Scheduled Knowledge Digest

```
[Schedule: Weekly] → [HTTP: /search trending] → [Iterator] → [Notion: Create Page]
```

Generate weekly reports from your knowledge base.

#### 6. Form Response with Fallback

```
[Typeform: Watch] → [HTTP: /search] → [Router]
                                          │
                                          ├─[Filter: results > 0]→ [Email: Send Answer]
                                          │
                                          └─[Filter: results = 0]→ [Zendesk: Create Ticket]
```

***

### Configuration Tips

#### 1. Store Credentials Securely

Use Make's **Connections** or **Data Stores** for API keys:

1. Go to **Connections** in the left menu
2. Create a new **HTTP Basic Auth** or **API Key** connection
3. Use the connection in your HTTP modules

#### 2. Use Variables and Data Stores

Store `tenant_id` and other config in a Data Store:

```json
{
  "query": "{{1.query}}",
  "filters": {
    "tenant_id": "{{datastore.config.tenant_id}}"
  }
}
```

#### 3. Handle Errors with Error Handler

Right-click the HTTP module and add an **Error Handler**:

```
[HTTP Module] ──error──→ [Router]
                            │
                            ├─[Filter: 4xx]→ [Slack: Notify]
                            │
                            └─[Filter: 5xx]→ [Resume] → [Sleep] → [Retry]
```

#### 4. Limit Results for Efficiency

Start with fewer results:

```json
{
  "limit": 3
}
```

#### 5. Use Filters for Context

Direct searches with tags:

```json
{
  "filters": {
    "tenant_id": "...",
    "tag_names": ["{{1.detected_category}}"]
  }
}
```

#### 6. Enable Parse Response

Always check **Parse response** in the HTTP module to easily access response fields.

***

### Complete Example: Customer Support Automation

#### Scenario Overview

1. Customer submits question via form
2. Scenario searches knowledge base
3. If answer found, sends automated reply
4. If not found, creates support ticket

#### Step-by-Step Setup

**Module 1: Typeform - Watch Responses**

* Connection: Your Typeform account
* Form: Select your support form

**Module 2: HTTP - Make a request**

* URL: `https://api-integrations.snackprompt.com/v1/kb/chat`
* Method: `POST`
* Headers: `x-api-key: YOUR_API_KEY`
* Body type: `Raw`
* Content type: `JSON (application/json)`
* Request content:

  ```json
  {
    "query": "{{1.answers[].text}}",
    "filters": {
      "tenant_id": "YOUR_TENANT_ID",
      "tag_names": ["Support"]
    }
  }
  ```
* Parse response: `Yes`

**Module 3: Router**

* Route 1: `{{length(2.sources)}} > 0` (has results)
* Route 2: `{{length(2.sources)}} = 0` (no results)

**Module 4A: Gmail - Send an Email** (Route 1)

* To: `{{1.answers[email].email}}`
* Subject: `Re: Your question`
* Content: `{{2.answer}}`

**Module 4B: Zendesk - Create Ticket** (Route 2)

* Subject: `Support Request: {{1.answers[subject].text}}`
* Description: `{{1.answers[question].text}}`

***

### Working with Arrays

#### Iterating Over Results

Use **Iterator** to process each result:

```
[HTTP: /search] → [Iterator] → [Your Module]
                      │
                Array: {{2.items}}
```

Inside the iterator, access:

* `{{3.payload.original_text}}`
* `{{3.score}}`
* `{{3.payload.snack_item_id}}`

#### Aggregating Results

Use **Text Aggregator** to combine results:

| Field         | Value                           |
| ------------- | ------------------------------- |
| Source module | Iterator                        |
| Text          | `- {{3.payload.original_text}}` |
| Row separator | `\n`                            |

Result: A formatted list of all documents.

#### Array Functions

Useful functions for working with results:

| Function   | Example                    | Description         |
| ---------- | -------------------------- | ------------------- |
| `first()`  | `{{first(2.items)}}`       | Get first result    |
| `last()`   | `{{last(2.items)}}`        | Get last result     |
| `length()` | `{{length(2.items)}}`      | Count results       |
| `slice()`  | `{{slice(2.items; 0; 3)}}` | Get first 3 results |

***

### Troubleshooting

#### Error: "tenant\_id is required"

Make sure `tenant_id` is inside the `filters` object:

```json
// ❌ Wrong
{ "query": "...", "tenant_id": "..." }

// ✅ Correct
{ "query": "...", "filters": { "tenant_id": "..." } }
```

#### Error: "Invalid JSON"

1. Verify JSON syntax in the request content
2. Check for unescaped special characters in variables
3. Use the **JSON > Create JSON** module to build complex payloads safely

#### Empty Response / No Items

1. Verify your `tenant_id` is correct
2. Check if the query matches content in your knowledge base
3. Remove `tag_names` filter to search all content
4. Increase the `limit` parameter

#### Cannot Access Response Fields

1. Ensure **Parse response** is checked
2. Verify the response structure by checking execution history
3. Use `{{2.body}}` to see the raw response

#### Rate Limiting (429 Error)

1. Add a **Sleep** module between API calls
2. Use Make's built-in **Rate limiting** in scenario settings
3. Consider using **Queue** for high-volume scenarios

#### Timeout Errors

1. Increase the **Timeout** setting in the HTTP module
2. Check if your query is too complex
3. Reduce the `limit` parameter

***

### Advanced Patterns

#### Caching with Data Stores

Cache frequent queries to reduce API calls:

```
[Trigger] → [Data Store: Search] → [Router]
                                      │
                                      ├─[Found]→ [Use Cache]
                                      │
                                      └─[Not Found]→ [HTTP: /search] → [Data Store: Add] → [Continue]
```

#### Retry Pattern

Automatic retry on failure:

```
[HTTP Module] ──error──→ [Tools: Sleep] → [Tools: Increment] → [Router]
                                                                   │
                                                                   ├─[retries < 3]→ [Resume]
                                                                   │
                                                                   └─[retries >= 3]→ [Error Notification]
```

#### Batch Processing

Process multiple queries efficiently:

```
[Trigger with Array] → [Iterator] → [HTTP: /search] → [Array Aggregator] → [Next Module]
```

***

### Related

* [Endpoints Reference](/bring-your-data-into-ai/reference/endpoints.md)
* [Available Filters](/bring-your-data-into-ai/reference/filters.md)
* [Error Hand](/bring-your-data-into-ai/how-to/how-to-handle-errors.md)

### External Resources

* [Make HTTP Module Documentation](https://www.make.com/en/help/app/http)
* [Make Webhooks Guide](https://www.make.com/en/help/app/webhooks)
* [Make Error Handling](https://www.make.com/en/help/errors/error-handling)
* [Make JSON Module](https://www.make.com/en/help/app/json)
