Skip to content

Commit 4be568e

Browse files
authored
feat(tools): added clay tools/block (#326)
1 parent 8bb500b commit 4be568e

9 files changed

Lines changed: 566 additions & 1 deletion

File tree

docs/content/docs/tools/clay.mdx

Lines changed: 246 additions & 0 deletions
Large diffs are not rendered by default.

docs/content/docs/tools/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"airtable",
55
"autoblocks",
66
"browser_use",
7+
"clay",
78
"confluence",
89
"dropdown",
910
"elevenlabs",

sim/blocks/blocks/clay.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { ClayIcon } from '@/components/icons'
2+
import { ClayPopulateResponse } from '@/tools/clay/types'
3+
import { BlockConfig } from '../types'
4+
5+
export const ClayBlock: BlockConfig<ClayPopulateResponse> = {
6+
type: 'clay',
7+
name: 'Clay',
8+
description: 'Populate Clay workbook with data',
9+
longDescription:
10+
'Populate Clay workbook with data using a JSON or plain text. Enables direct communication and notifications with channel confirmation.',
11+
category: 'tools',
12+
bgColor: '#E0E0E0',
13+
icon: ClayIcon,
14+
subBlocks: [
15+
{
16+
id: 'webhookURL',
17+
title: 'Webhook URL',
18+
type: 'short-input',
19+
layout: 'full',
20+
placeholder: 'Enter Clay webhook URL',
21+
},
22+
{
23+
id: 'data',
24+
title: 'Data (JSON or Plain Text)',
25+
type: 'long-input',
26+
layout: 'full',
27+
placeholder: 'Enter your JSON data to populate your Clay table',
28+
description: `JSON vs. Plain Text:
29+
JSON: Best for populating multiple columns.
30+
Plain Text: Best for populating a table in free-form style.
31+
`,
32+
},
33+
{
34+
id: 'authToken',
35+
title: 'Auth Token',
36+
type: 'short-input',
37+
layout: 'full',
38+
placeholder: 'Enter your Clay Auth token',
39+
password: true,
40+
connectionDroppable: false,
41+
},
42+
],
43+
tools: {
44+
access: ['clay_populate'],
45+
},
46+
inputs: {
47+
authToken: { type: 'string', required: true },
48+
webhookURL: { type: 'string', required: true },
49+
data: { type: 'json', required: true },
50+
},
51+
outputs: {
52+
response: {
53+
type: {
54+
data: 'any',
55+
},
56+
},
57+
},
58+
}

sim/blocks/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { BlockConfig } from './types'
4949
import { Mem0Block } from './blocks/mem0'
5050
import { S3Block } from './blocks/s3'
5151
import { TelegramBlock } from './blocks/telegram'
52+
import { ClayBlock } from './blocks/clay'
5253

5354
// Export blocks for ease of use
5455
export {
@@ -101,6 +102,7 @@ export {
101102
StagehandAgentBlock,
102103
S3Block,
103104
TelegramBlock,
105+
ClayBlock,
104106
}
105107

106108
// Registry of all block configurations, alphabetically sorted
@@ -154,6 +156,7 @@ const blocks: Record<string, BlockConfig> = {
154156
x: XBlock,
155157
youtube: YouTubeBlock,
156158
telegram: TelegramBlock,
159+
clay: ClayBlock,
157160
}
158161

159162
// Helper functions

sim/components/icons.tsx

Lines changed: 168 additions & 1 deletion
Large diffs are not rendered by default.

sim/tools/clay/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { clayPopulateTool } from './populate'
2+
3+
export { clayPopulateTool }

sim/tools/clay/populate.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { ToolConfig } from '../types'
2+
import { ClayPopulateParams, ClayPopulateResponse } from './types'
3+
4+
export const clayPopulateTool: ToolConfig<ClayPopulateParams, ClayPopulateResponse> = {
5+
id: 'clay_populate',
6+
name: 'Clay Populate',
7+
description:
8+
'Populate Clay with data from a JSON file. Enables direct communication and notifications with timestamp tracking and channel confirmation.',
9+
version: '1.0.0',
10+
11+
params: {
12+
webhookURL: {
13+
type: 'string',
14+
required: true,
15+
requiredForToolCall: true,
16+
description: 'The webhook URL to populate',
17+
},
18+
data: {
19+
type: 'json',
20+
required: true,
21+
description: 'The data to populate',
22+
optionalToolInput: true,
23+
},
24+
authToken: {
25+
type: 'string',
26+
required: false,
27+
description: 'Optional auth token for WebhookURL',
28+
},
29+
},
30+
31+
request: {
32+
url: (params: ClayPopulateParams) => params.webhookURL,
33+
method: 'POST',
34+
headers: (params: ClayPopulateParams) => ({
35+
'Content-Type': 'application/json',
36+
Authorization: `Bearer ${params.authToken}`,
37+
}),
38+
body: (params: ClayPopulateParams) => ({
39+
data: params.data,
40+
}),
41+
},
42+
43+
transformResponse: async (response: Response) => {
44+
const contentType = response.headers.get('content-type')
45+
let data
46+
47+
if (contentType?.includes('application/json')) {
48+
data = await response.json()
49+
if (!data.ok) {
50+
throw new Error(data.error || 'Clay API error')
51+
}
52+
} else {
53+
// Handle text response
54+
data = await response.text()
55+
if (data !== 'OK' && !response.ok) {
56+
throw new Error(data || 'Clay API error')
57+
}
58+
}
59+
60+
return {
61+
success: true,
62+
output: {
63+
data: contentType?.includes('application/json') ? data : { message: data },
64+
},
65+
}
66+
},
67+
68+
transformError: (error: any) => {
69+
const message = error.message || 'Clay populate failed'
70+
return message
71+
},
72+
}

sim/tools/clay/types.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ToolResponse } from "../types"
2+
3+
export interface ClayPopulateParams {
4+
webhookURL: string
5+
data: JSON
6+
authToken?: string
7+
}
8+
9+
export interface ClayPopulateResponse extends ToolResponse {
10+
output: {
11+
data: any
12+
}
13+
}

sim/tools/registry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { ToolConfig } from './types'
4242
import { s3GetObjectTool } from './s3'
4343
import { jiraRetrieveTool, jiraUpdateTool, jiraWriteTool, jiraBulkRetrieveTool } from './jira'
4444
import { telegramMessageTool } from './telegram'
45+
import { clayPopulateTool } from './clay'
4546

4647
// Registry of all available tools
4748
export const tools: Record<string, ToolConfig> = {
@@ -128,4 +129,5 @@ export const tools: Record<string, ToolConfig> = {
128129
elevenlabs_tts: elevenLabsTtsTool,
129130
s3_get_object: s3GetObjectTool,
130131
telegram_message: telegramMessageTool,
132+
clay_populate: clayPopulateTool,
131133
}

0 commit comments

Comments
 (0)