> For the complete documentation index, see [llms.txt](https://docs.clickai.vn/clickai-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clickai.vn/clickai-docs/clickai-docs-en/function/database/integration-with-ai.md).

# Integration with AI

## Table of Contents

·       \[Integration Overview]\(#integration-overview)

·       \[Tables + Workflow]\(#tables--workflow)

·       \[Tables + AI Agent]\(#tables--ai-agent)

·       \[Tables + Webhooks]\(#tables--webhooks)

·       \[REST API]\(#rest-api)

·       \[MCP Server — Connect AI via MCP Protocol]\(#mcp-server--connect-ai-via-mcp-protocol)

·       \[AI Integration Use-cases]\(#ai-integration-use-cases)

·       \[Best Practices]\(#best-practices)

&#x20;

## Integration Overview

ClickAI Tables is more than just data storage — it's the central hub connecting the entire ClickAI AI ecosystem. You can:

graph LR\
&#x20;   A\[📊 Tables] --> B\[🤖 AI Agent]\
&#x20;   A --> C\[⚙️ Workflow]\
&#x20;   A --> D\[🔔 Webhooks]\
&#x20;   A --> E\[📡 REST API]\
&#x20;   A --> F\[🔌 MCP Server]\
&#x20;   C --> A\
&#x20;   B --> A\
&#x20;   F --> B

·       Read data from Tables in Workflows/Agents

·       Write data to Tables from AI processing results

·       Trigger automations when data changes via Webhooks

·       Access programmatically via REST API

·       Connect LLMs directly via MCP Server (Model Context Protocol)

&#x20;

## Tables + Workflow

### Read Data from Tables in a Workflow

Use the HTTP Request node in a Workflow to query data from the Tables API:

1\.     Add an HTTP Request node to the Workflow

2\.     Configure:

·       Method: GET

·       URL: <https://tables.clickai.vn/api/v2/tables/{table\\_id}/records>

·       Headers: xc-auth: {API\_TOKEN}

3\.     Process the response data in subsequent nodes

### Write Data to Tables from a Workflow

4\.     Add an HTTP Request node to the Workflow

5\.     Configure:

·       Method: POST

·       URL: <https://tables.clickai.vn/api/v2/tables/{table\\_id}/records>

·       Headers: xc-auth: {API\_TOKEN}

·       Body: JSON containing the new record data

{\
&#x20; "Title": "{{workflow\.output.title}}",\
&#x20; "Status": "Processed",\
&#x20; "AI\_Summary": "{{workflow\.output.summary}}",\
&#x20; "Score": {{workflow\.output.score}}\
}

### Example Workflow: Automated Lead Processing

graph TD\
&#x20;   A\[🔔 Webhook: New Lead] --> B\[📊 Read Lead from Tables]\
&#x20;   B --> C\[🧠 LLM: Analyze Lead]\
&#x20;   C --> D{Score > 80?}\
&#x20;   D -->|Yes| E\[📊 Update Status = Hot]\
&#x20;   D -->|No| F\[📊 Update Status = Cold]\
&#x20;   E --> G\[📧 Send notification to Sales]\
&#x20;   F --> H\[📧 Send nurturing email]

&#x20;

## Tables + AI Agent

### Use Tables as a Tool for AI Agent

AI Agents can use the Tables API as a tool to query and update data:

6\.     In the Agent configuration, add a Custom Tool

7\.     Configure the Tables API endpoint

8\.     The Agent will automatically call the API when it needs to look up information

Example: A customer support Agent can:

·       Look up customer information from the "Customers" table

·       Check order status from the "Orders" table

·       Create new tickets in the "Support Tickets" table

·       Update processing status

### Connect Tables via App Integration

Use the App Integration module (Composio) to connect Tables:

9\.     Go to Workspace → App Integration

10\.  Find and connect NocoDB/ClickAI Tables

11\.  Configure authentication

12\.  Use the available actions in Agent/Workflow

&#x20;

## Tables + Webhooks

Webhooks send automatic notifications when data in Tables changes:

### Webhook Configuration

13\.  Open the table → Table Details → Webhooks tab

14\.  Click Create Webhook

15\.  Configure:

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Setting</td><td valign="top">Description</td></tr><tr><td valign="top">Event</td><td valign="top">After Insert / After Update / After Delete</td></tr><tr><td valign="top">URL</td><td valign="top">Receiving endpoint (e.g., ClickAI Workflow trigger)</td></tr><tr><td valign="top">Method</td><td valign="top">POST</td></tr><tr><td valign="top">Headers</td><td valign="top">Custom headers if needed</td></tr><tr><td valign="top">Condition</td><td valign="top">Trigger only when specific conditions are met</td></tr></tbody></table>

&#x20;

### Webhook Payload

{\
&#x20; "type": "records.after.insert",\
&#x20; "data": {\
&#x20;   "table\_id": "tbl\_xxxxx",\
&#x20;   "rows": \[\
&#x20;     {\
&#x20;       "Id": 1,\
&#x20;       "Title": "New Customer Lead",\
&#x20;       "Email": "<customer@example.com>",\
&#x20;       "Status": "New"\
&#x20;     }\
&#x20;   ]\
&#x20; },\
&#x20; "timestamp": "2024-01-15T10:30:00Z"\
}

### Connect Webhook → ClickAI Workflow

16\.  Create a new Workflow in ClickAI Studio

17\.  Use the Start Node with trigger type Webhook

18\.  Copy the Webhook URL from the Workflow

19\.  Paste the URL into the table's Webhook configuration

20\.  Whenever data changes → Webhook triggers → Workflow runs automatically

&#x20;

## REST API

ClickAI Tables provides a full REST API for all data operations:

### Authentication

\# Using API Token\
curl -H "xc-auth: YOUR\_API\_TOKEN" \\\
&#x20; <https://tables.clickai.vn/api/v2/tables/{table\\_id}/records>

### Key API Endpoints

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Method</td><td valign="top">Endpoint</td><td valign="top">Description</td></tr><tr><td valign="top">GET</td><td valign="top">/api/v2/tables/{id}/records</td><td valign="top">List records</td></tr><tr><td valign="top">GET</td><td valign="top">/api/v2/tables/{id}/records/{row_id}</td><td valign="top">Get a specific record</td></tr><tr><td valign="top">POST</td><td valign="top">/api/v2/tables/{id}/records</td><td valign="top">Create new record(s)</td></tr><tr><td valign="top">PATCH</td><td valign="top">/api/v2/tables/{id}/records</td><td valign="top">Update record(s)</td></tr><tr><td valign="top">DELETE</td><td valign="top">/api/v2/tables/{id}/records</td><td valign="top">Delete record(s)</td></tr></tbody></table>

&#x20;

### Query Parameters

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Parameter</td><td valign="top">Description</td><td valign="top">Example</td></tr><tr><td valign="top">where</td><td valign="top">Filter records</td><td valign="top">(Status,eq,Active)</td></tr><tr><td valign="top">sort</td><td valign="top">Sort records</td><td valign="top">-CreatedAt (descending)</td></tr><tr><td valign="top">fields</td><td valign="top">Select returned fields</td><td valign="top">Title,Email,Status</td></tr><tr><td valign="top">limit</td><td valign="top">Limit number of records</td><td valign="top">25</td></tr><tr><td valign="top">offset</td><td valign="top">Pagination offset</td><td valign="top">50</td></tr></tbody></table>

&#x20;

### Example: Get Active Customers

curl -X GET \\\
&#x20; "<https://tables.clickai.vn/api/v2/tables/tbl\\_xxx/records?where=(Status,eq,Active)\\&sort=-CreatedAt\\&limit=10>" \\\
&#x20; -H "xc-auth: YOUR\_API\_TOKEN"

### Example: Create a New Record

curl -X POST \\\
&#x20; "<https://tables.clickai.vn/api/v2/tables/tbl\\_xxx/records>" \\\
&#x20; -H "xc-auth: YOUR\_API\_TOKEN" \\\
&#x20; -H "Content-Type: application/json" \\\
&#x20; -d '{\
&#x20;   "Title": "John Doe",\
&#x20;   "Email": "<john.doe@example.com>",\
&#x20;   "Phone": "+1234567890",\
&#x20;   "Status": "New"\
&#x20; }'

💡 TIP: You can find the API Token in \*\*Table Details\*\* → \*\*API Snippet\*\* tab or in \*\*Workspace Settings\*\* → \*\*API Tokens\*\*.

&#x20;

## MCP Server — Connect AI via MCP Protocol

MCP (Model Context Protocol) is a standard protocol that allows AI applications (LLMs) to interact directly with data in Tables using natural language — no API coding required.

With MCP, you can ask AI directly:

·       \*"Show me all customers from Hanoi"\*

·       \*"Add a new task: Review documentation, priority High"\*

·       \*"Update order #123 status to Delivered"\*

·       \*"Delete all leads with status = Lost"\*

### How MCP Works

graph LR\
&#x20;   A\[👤 User] -->|Natural language| B\[🤖 AI Client]\
&#x20;   B -->|MCP Protocol| C\[🔌 MCP Server]\
&#x20;   C -->|REST API| D\[📊 ClickAI Tables]\
&#x20;   D -->|Data| C\
&#x20;   C -->|Results| B\
&#x20;   B -->|Response| A

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Component</td><td valign="top">Role</td></tr><tr><td valign="top">AI Client</td><td valign="top">AI application (Claude Desktop, Cursor, Windsurf...)</td></tr><tr><td valign="top">MCP Server</td><td valign="top">Bridge between AI and Tables — translates AI commands into API calls</td></tr><tr><td valign="top">ClickAI Tables</td><td valign="top">Database that receives and processes data requests</td></tr></tbody></table>

&#x20;

### MCP Server Capabilities

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Feature Group</td><td valign="top">Capabilities</td></tr><tr><td valign="top">Record CRUD</td><td valign="top">Create, read, update, delete records using natural language</td></tr><tr><td valign="top">Table Management</td><td valign="top">List, create, delete tables</td></tr><tr><td valign="top">Field Management</td><td valign="top">Add, delete, manage fields/columns</td></tr><tr><td valign="top">View Management</td><td valign="top">List, create, delete views (Grid, Gallery, Kanban...)</td></tr><tr><td valign="top">Data Operations</td><td valign="top">Filter, sort, search, aggregate data</td></tr></tbody></table>

&#x20;

### Configure MCP on ClickAI Tables

#### Method 1: Create MCP Endpoint from the UI (Recommended)

21\.  Open a base in ClickAI Tables

22\.  Click the Overview button in the left sidebar

23\.  Select the Settings tab

24\.  Choose Model Context Protocol from the settings menu

25\.  Click New MCP Endpoint

26\.  Name the endpoint and click Create

27\.  Copy the auto-generated MCP Config JSON

#### Method 2: Manual Configuration (Self-hosted)

For self-hosted ClickAI Tables instances, configure manually using an API Token:

Step 1: Gather configuration details

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Setting</td><td valign="top">How to obtain</td></tr><tr><td valign="top">NOCODB_BASE_URL</td><td valign="top">Your Tables instance URL (e.g., https://tables.clickai.vn)</td></tr><tr><td valign="top">NOCODB_API_TOKEN</td><td valign="top">Account Settings → API Tokens → Create Token</td></tr><tr><td valign="top">NOCODB_BASE_ID</td><td valign="top">Found in the URL when opening a base: .../#/nc/base/BASE_ID_HERE/...</td></tr></tbody></table>

&#x20;

Step 2: Create the MCP Config JSON

{\
&#x20; "mcpServers": {\
&#x20;   "clickai-tables": {\
&#x20;     "command": "npx",\
&#x20;     "args": \["-y", "nocodb-mcp-server"],\
&#x20;     "env": {\
&#x20;       "NOCODB\_BASE\_URL": "<https://tables.clickai.vn",\\>
&#x20;       "NOCODB\_API\_TOKEN": "your\_api\_token\_here",\
&#x20;       "NOCODB\_BASE\_ID": "your\_base\_id\_here"\
&#x20;     }\
&#x20;   }\
&#x20; }\
}

### Connect to Claude Desktop

28\.  Open Claude Desktop → Preferences (⌘+, on Mac / Ctrl+, on Windows)

29\.  Go to Develop → Edit Config

30\.  Paste the MCP Config JSON into claude\_desktop\_config.json

31\.  Save the file and restart Claude Desktop

32\.  Verify: open Claude, you should see the 🔌 MCP Tools icon in the input area

// \~/Library/Application Support/Claude/claude\_desktop\_config.json (macOS)\
// %APPDATA%\Claude\claude\_desktop\_config.json (Windows)\
{\
&#x20; "mcpServers": {\
&#x20;   "clickai-tables": {\
&#x20;     "command": "npx",\
&#x20;     "args": \["-y", "nocodb-mcp-server"],\
&#x20;     "env": {\
&#x20;       "NOCODB\_BASE\_URL": "<https://tables.clickai.vn",\\>
&#x20;       "NOCODB\_API\_TOKEN": "xc-auth-xxxxxxxxxxxxx",\
&#x20;       "NOCODB\_BASE\_ID": "p\_xxxxxxxxxxxxxxxx"\
&#x20;     }\
&#x20;   }\
&#x20; }\
}

### Connect to Cursor

33\.  Open Cursor → Settings (⇧+⌘+J / Ctrl+Shift+J)

34\.  Navigate to the MCP tab

35\.  Click Add Custom MCP

36\.  Paste the MCP Config JSON and save

37\.  On success, you will see the NocoDB tools listed

### Example Usage with Claude

After connecting, you can communicate using natural language:

👤 "Show me the 10 most recent customers in the Customers table"\
🤖 Claude auto-calls MCP → list\_records(table: Customers, sort: -CreatedAt, limit: 10)\
&#x20;  → Returns a table of the 10 newest customers\
\
👤 "Add a new customer: John Doe, email: <john@example.com>, phone: +1234567890"\
🤖 Claude auto-calls MCP → create\_record(table: Customers, data: {...})\
&#x20;  → ✅ Record created successfully\
\
👤 "Create a new table called 'Feedback' with 3 columns: Customer Name, Rating, Comment"\
🤖 Claude auto-calls MCP → create\_table(...) + create\_fields(...)\
&#x20;  → ✅ Feedback table created with 3 fields

### MCP Permission Management

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Mode</td><td valign="top">Description</td><td valign="top">Best for</td></tr><tr><td valign="top">Always Ask Permission</td><td valign="top">AI asks for confirmation before each action</td><td valign="top">Production data, critical operations</td></tr><tr><td valign="top">Allow Unsupervised</td><td valign="top">AI executes without confirmation</td><td valign="top">Test data, dev environments</td></tr></tbody></table>

&#x20;

🚨 WARNING: \*\*Security when using MCP:\*\* - Use API Tokens with minimal permissions (read-only if you only need to query) - Never use Admin tokens for MCP integrations - Enable "Always Ask Permission" mode for production data - Review MCP Config JSON carefully before sharing — ensure tokens are not exposed

💡 TIP: MCP is especially useful for developers who want to quickly prototype, query data, or manage databases without opening the Tables UI. Combining MCP with Claude Desktop turns Tables into your personal data assistant.

&#x20;

## AI Integration Use-cases

### 1. Smart CRM with AI Agent

Customer chats → AI Agent queries CRM in Tables →\
Responds based on purchase history → Logs interaction in Tables

### 2. Automated Customer Segmentation

Webhook: New Order → Workflow → LLM analyzes behavior →\
Updates Segment field in Tables → Triggers personalized outreach

### 3. AI-Powered Content Calendar

Form View collects ideas → Workflow → LLM writes draft →\
Saves draft to table → Kanban View manages progress

### 4. Automated Helpdesk

Form View receives ticket → Webhook → AI classifies →\
Updates Priority & Category → Assigns to appropriate staff

### 5. Intelligent Reporting

Scheduled Workflow → Query Tables API → LLM analyzes data →\
Generates report → Sends email to management

&#x20;

## Best Practices

💡 TIP: \*\*Effective Table Design:\*\* - Each table should focus on a single entity (Customers, Orders, Products) - Use Links to create relationships instead of duplicating data - Use clear, descriptive field names - Use Single Select for status fields to leverage Kanban View

🚨 WARNING: \*\*API Integration Notes:\*\* - Secure API Tokens — never hardcode in client-side code - Implement rate limiting to avoid excessive API calls - Validate data before writing to Tables - Set up error handling in Workflows for API failure cases

⚠️ IMPORTANT: \*\*Performance Optimization:\*\* - Use the \`fields\` parameter to fetch only necessary data - Implement pagination for tables with many records - Use \`where\` filters at the API level instead of client-side filtering - Cache API results when data doesn't change frequently


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clickai.vn/clickai-docs/clickai-docs-en/function/database/integration-with-ai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
