Skip to content

Commit 274d5e3

Browse files
authored
fix(clay): fixed clay tool (#1725)
* fixed clay tool * added metadata * added metadata to types * fix(clay): remove (optional) from subblock name * regen docs
1 parent c552bb9 commit 274d5e3

File tree

6 files changed

+68
-20
lines changed

6 files changed

+68
-20
lines changed

apps/docs/content/docs/en/tools/clay.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,14 @@ Populate Clay with data from a JSON file. Enables direct communication and notif
214214
| --------- | ---- | -------- | ----------- |
215215
| `webhookURL` | string | Yes | The webhook URL to populate |
216216
| `data` | json | Yes | The data to populate |
217-
| `authToken` | string | Yes | Auth token for Clay webhook authentication |
217+
| `authToken` | string | No | Optional auth token for Clay webhook authentication \(most webhooks do not require this\) |
218218

219219
#### Output
220220

221221
| Parameter | Type | Description |
222222
| --------- | ---- | ----------- |
223-
| `success` | boolean | Operation success status |
224-
| `output` | json | Clay populate operation results including response data from Clay webhook |
223+
| `data` | json | Response data from Clay webhook |
224+
| `metadata` | object | Webhook response metadata |
225225

226226

227227

apps/docs/content/docs/en/tools/discord.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { BlockInfoCard } from "@/components/ui/block-info-card"
77

88
<BlockInfoCard
99
type="discord"
10-
color="#E0E0E0"
10+
color="#5865F2"
1111
icon={true}
1212
iconSvg={`<svg className="block-icon"
1313

apps/docs/content/docs/en/tools/qdrant.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Search for similar vectors in a Qdrant collection
143143
| `vector` | array | Yes | Vector to search for |
144144
| `limit` | number | No | Number of results to return |
145145
| `filter` | object | No | Filter to apply to the search |
146+
| `search_return_data` | string | No | Data to return from search |
146147
| `with_payload` | boolean | No | Include payload in response |
147148
| `with_vector` | boolean | No | Include vector in response |
148149

@@ -165,6 +166,7 @@ Fetch points by ID from a Qdrant collection
165166
| `apiKey` | string | No | Qdrant API key \(optional\) |
166167
| `collection` | string | Yes | Collection name |
167168
| `ids` | array | Yes | Array of point IDs to fetch |
169+
| `fetch_return_data` | string | No | Data to return from fetch |
168170
| `with_payload` | boolean | No | Include payload in response |
169171
| `with_vector` | boolean | No | Include vector in response |
170172

apps/sim/blocks/blocks/clay.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ Plain Text: Best for populating a table in free-form style.
3838
title: 'Auth Token',
3939
type: 'short-input',
4040
layout: 'full',
41-
placeholder: 'Enter your Clay Auth token',
41+
placeholder: 'Enter your Clay webhook auth token',
4242
password: true,
4343
connectionDroppable: false,
44-
required: true,
44+
required: false,
45+
description:
46+
'Optional: If your Clay table has webhook authentication enabled, enter the auth token here. This will be sent in the x-clay-webhook-auth header.',
4547
},
4648
],
4749
tools: {
@@ -53,6 +55,10 @@ Plain Text: Best for populating a table in free-form style.
5355
data: { type: 'json', description: 'Data to populate' },
5456
},
5557
outputs: {
56-
data: { type: 'json', description: 'Response data' },
58+
data: { type: 'json', description: 'Response data from Clay webhook' },
59+
metadata: {
60+
type: 'json',
61+
description: 'Webhook metadata including status, headers, timestamp, and content type',
62+
},
5763
},
5864
}

apps/sim/tools/clay/populate.ts

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,80 @@ export const clayPopulateTool: ToolConfig<ClayPopulateParams, ClayPopulateRespon
2323
},
2424
authToken: {
2525
type: 'string',
26-
required: true,
26+
required: false,
2727
visibility: 'user-only',
28-
description: 'Auth token for Clay webhook authentication',
28+
description:
29+
'Optional auth token for Clay webhook authentication (most webhooks do not require this)',
2930
},
3031
},
3132

3233
request: {
3334
url: (params: ClayPopulateParams) => params.webhookURL,
3435
method: 'POST',
35-
headers: (params: ClayPopulateParams) => ({
36-
'Content-Type': 'application/json',
37-
Authorization: `Bearer ${params.authToken}`,
38-
}),
36+
headers: (params: ClayPopulateParams) => {
37+
const headers: Record<string, string> = {
38+
'Content-Type': 'application/json',
39+
}
40+
41+
if (params.authToken && params.authToken.trim() !== '') {
42+
headers['x-clay-webhook-auth'] = params.authToken
43+
}
44+
45+
return headers
46+
},
3947
body: (params: ClayPopulateParams) => ({
4048
data: params.data,
4149
}),
4250
},
4351

4452
transformResponse: async (response: Response) => {
4553
const contentType = response.headers.get('content-type')
46-
let data
54+
const timestamp = new Date().toISOString()
4755

56+
// Extract response headers
57+
const headers: Record<string, string> = {}
58+
response.headers.forEach((value, key) => {
59+
headers[key] = value
60+
})
61+
62+
// Parse response body
63+
let responseData
4864
if (contentType?.includes('application/json')) {
49-
data = await response.json()
65+
responseData = await response.json()
5066
} else {
51-
data = await response.text()
67+
responseData = await response.text()
5268
}
5369

5470
return {
5571
success: true,
5672
output: {
57-
data: contentType?.includes('application/json') ? data : { message: data },
73+
data: contentType?.includes('application/json') ? responseData : { message: responseData },
74+
metadata: {
75+
status: response.status,
76+
statusText: response.statusText,
77+
headers: headers,
78+
timestamp: timestamp,
79+
contentType: contentType || 'unknown',
80+
},
5881
},
5982
}
6083
},
6184

6285
outputs: {
63-
success: { type: 'boolean', description: 'Operation success status' },
64-
output: {
86+
data: {
6587
type: 'json',
66-
description: 'Clay populate operation results including response data from Clay webhook',
88+
description: 'Response data from Clay webhook',
89+
},
90+
metadata: {
91+
type: 'object',
92+
description: 'Webhook response metadata',
93+
properties: {
94+
status: { type: 'number', description: 'HTTP status code' },
95+
statusText: { type: 'string', description: 'HTTP status text' },
96+
headers: { type: 'object', description: 'Response headers from Clay' },
97+
timestamp: { type: 'string', description: 'ISO timestamp when webhook was received' },
98+
contentType: { type: 'string', description: 'Content type of the response' },
99+
},
67100
},
68101
},
69102
}

apps/sim/tools/clay/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,12 @@ export interface ClayPopulateParams {
99
export interface ClayPopulateResponse extends ToolResponse {
1010
output: {
1111
data: any
12+
metadata: {
13+
status: number
14+
statusText: string
15+
headers: Record<string, string>
16+
timestamp: string
17+
contentType: string
18+
}
1219
}
1320
}

0 commit comments

Comments
 (0)