Skip to content

Commit 6c006cd

Browse files
author
Theodore Li
committed
feat(google books): Add google books integration
1 parent 81dfeb0 commit 6c006cd

File tree

12 files changed

+799
-0
lines changed

12 files changed

+799
-0
lines changed

apps/docs/components/icons.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,21 @@ export function AirweaveIcon(props: SVGProps<SVGSVGElement>) {
11571157
)
11581158
}
11591159

1160+
export function GoogleBooksIcon(props: SVGProps<SVGSVGElement>) {
1161+
return (
1162+
<svg {...props} xmlns='http://www.w3.org/2000/svg' viewBox='0 0 478.633 540.068'>
1163+
<path
1164+
fill='#1C51A4'
1165+
d='M449.059,218.231L245.519,99.538l-0.061,193.23c0.031,1.504-0.368,2.977-1.166,4.204c-0.798,1.258-1.565,1.995-2.915,2.547c-1.35,0.552-2.792,0.706-4.204,0.399c-1.412-0.307-2.7-1.043-3.713-2.117l-69.166-70.609l-69.381,70.179c-1.013,0.982-2.301,1.657-3.652,1.903c-1.381,0.246-2.792,0.092-4.081-0.491c-1.289-0.583-1.626-0.522-2.394-1.749c-0.767-1.197-1.197-2.608-1.197-4.081L85.031,6.007l-2.915-1.289C43.973-11.638,0,16.409,0,59.891v420.306c0,46.029,49.312,74.782,88.775,51.767l360.285-210.138C488.491,298.782,488.491,241.246,449.059,218.231z'
1166+
/>
1167+
<path
1168+
fill='#80D7FB'
1169+
d='M88.805,8.124c-2.179-1.289-4.419-2.363-6.659-3.345l0.123,288.663c0,1.442,0.43,2.854,1.197,4.081c0.767,1.197,1.872,2.148,3.161,2.731c1.289,0.583,2.7,0.736,4.081,0.491c1.381-0.246,2.639-0.921,3.652-1.903l69.749-69.688l69.811,69.749c1.013,1.074,2.301,1.81,3.713,2.117c1.412,0.307,2.884,0.153,4.204-0.399c1.319-0.552,2.455-1.565,3.253-2.792c0.798-1.258,1.197-2.731,1.166-4.204V99.998L88.805,8.124z'
1170+
/>
1171+
</svg>
1172+
)
1173+
}
1174+
11601175
export function GoogleDocsIcon(props: SVGProps<SVGSVGElement>) {
11611176
return (
11621177
<svg

apps/docs/components/ui/icon-mapping.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
GithubIcon,
3939
GitLabIcon,
4040
GmailIcon,
41+
GoogleBooksIcon,
4142
GoogleCalendarIcon,
4243
GoogleDocsIcon,
4344
GoogleDriveIcon,
@@ -172,6 +173,7 @@ export const blockTypeToIconMap: Record<string, IconComponent> = {
172173
github_v2: GithubIcon,
173174
gitlab: GitLabIcon,
174175
gmail_v2: GmailIcon,
176+
google_books: GoogleBooksIcon,
175177
google_calendar_v2: GoogleCalendarIcon,
176178
google_docs: GoogleDocsIcon,
177179
google_drive: GoogleDriveIcon,
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
title: Google Books
3+
description: Search and retrieve book information
4+
---
5+
6+
import { BlockInfoCard } from "@/components/ui/block-info-card"
7+
8+
<BlockInfoCard
9+
type="google_books"
10+
color="#FFFFFF"
11+
/>
12+
13+
## Usage Instructions
14+
15+
Search for books using the Google Books API. Find volumes by title, author, ISBN, or keywords, and retrieve detailed information about specific books including descriptions, ratings, and publication details.
16+
17+
18+
19+
## Tools
20+
21+
### `google_books_volume_search`
22+
23+
Search for books using the Google Books API
24+
25+
#### Input
26+
27+
| Parameter | Type | Required | Description |
28+
| --------- | ---- | -------- | ----------- |
29+
| `apiKey` | string | Yes | Google Books API key |
30+
| `query` | string | Yes | Search query. Supports special keywords: intitle:, inauthor:, inpublisher:, subject:, isbn: |
31+
| `filter` | string | No | Filter results by availability \(partial, full, free-ebooks, paid-ebooks, ebooks\) |
32+
| `printType` | string | No | Restrict to print type \(all, books, magazines\) |
33+
| `orderBy` | string | No | Sort order \(relevance, newest\) |
34+
| `startIndex` | number | No | Index of the first result to return \(for pagination\) |
35+
| `maxResults` | number | No | Maximum number of results to return \(1-40\) |
36+
| `langRestrict` | string | No | Restrict results to a specific language \(ISO 639-1 code\) |
37+
38+
#### Output
39+
40+
| Parameter | Type | Description |
41+
| --------- | ---- | ----------- |
42+
| `totalItems` | number | Total number of matching results |
43+
| `volumes` | array | List of matching volumes |
44+
|`id` | string | Volume ID |
45+
|`title` | string | Book title |
46+
|`subtitle` | string | Book subtitle |
47+
|`authors` | array | List of authors |
48+
|`publisher` | string | Publisher name |
49+
|`publishedDate` | string | Publication date |
50+
|`description` | string | Book description |
51+
|`pageCount` | number | Number of pages |
52+
|`categories` | array | Book categories |
53+
|`averageRating` | number | Average rating \(1-5\) |
54+
|`ratingsCount` | number | Number of ratings |
55+
|`language` | string | Language code |
56+
|`previewLink` | string | Link to preview on Google Books |
57+
|`infoLink` | string | Link to info page |
58+
|`thumbnailUrl` | string | Book cover thumbnail URL |
59+
|`isbn10` | string | ISBN-10 identifier |
60+
|`isbn13` | string | ISBN-13 identifier |
61+
62+
### `google_books_volume_details`
63+
64+
Get detailed information about a specific book volume
65+
66+
#### Input
67+
68+
| Parameter | Type | Required | Description |
69+
| --------- | ---- | -------- | ----------- |
70+
| `apiKey` | string | Yes | Google Books API key |
71+
| `volumeId` | string | Yes | The ID of the volume to retrieve |
72+
| `projection` | string | No | Projection level \(full, lite\) |
73+
74+
#### Output
75+
76+
| Parameter | Type | Description |
77+
| --------- | ---- | ----------- |
78+
| `id` | string | Volume ID |
79+
| `title` | string | Book title |
80+
| `subtitle` | string | Book subtitle |
81+
| `authors` | array | List of authors |
82+
| `publisher` | string | Publisher name |
83+
| `publishedDate` | string | Publication date |
84+
| `description` | string | Book description |
85+
| `pageCount` | number | Number of pages |
86+
| `categories` | array | Book categories |
87+
| `averageRating` | number | Average rating \(1-5\) |
88+
| `ratingsCount` | number | Number of ratings |
89+
| `language` | string | Language code |
90+
| `previewLink` | string | Link to preview on Google Books |
91+
| `infoLink` | string | Link to info page |
92+
| `thumbnailUrl` | string | Book cover thumbnail URL |
93+
| `isbn10` | string | ISBN-10 identifier |
94+
| `isbn13` | string | ISBN-13 identifier |
95+
96+

apps/docs/content/docs/en/tools/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"github",
3434
"gitlab",
3535
"gmail",
36+
"google_books",
3637
"google_calendar",
3738
"google_docs",
3839
"google_drive",
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
import { GoogleBooksIcon } from '@/components/icons'
2+
import type { BlockConfig } from '@/blocks/types'
3+
4+
export const GoogleBooksBlock: BlockConfig = {
5+
type: 'google_books',
6+
name: 'Google Books',
7+
description: 'Search and retrieve book information',
8+
longDescription:
9+
'Search for books using the Google Books API. Find volumes by title, author, ISBN, or keywords, and retrieve detailed information about specific books including descriptions, ratings, and publication details.',
10+
docsLink: 'https://docs.sim.ai/tools/google_books',
11+
category: 'tools',
12+
bgColor: '#E0E0E0',
13+
icon: GoogleBooksIcon,
14+
15+
subBlocks: [
16+
{
17+
id: 'operation',
18+
title: 'Operation',
19+
type: 'dropdown',
20+
options: [
21+
{ label: 'Search Volumes', id: 'volume_search' },
22+
{ label: 'Get Volume Details', id: 'volume_details' },
23+
],
24+
value: () => 'volume_search',
25+
},
26+
{
27+
id: 'apiKey',
28+
title: 'API Key',
29+
type: 'short-input',
30+
password: true,
31+
placeholder: 'Enter your Google Books API key',
32+
required: true,
33+
},
34+
{
35+
id: 'query',
36+
title: 'Search Query',
37+
type: 'short-input',
38+
placeholder: 'e.g., intitle:harry potter inauthor:rowling',
39+
condition: { field: 'operation', value: 'volume_search' },
40+
required: { field: 'operation', value: 'volume_search' },
41+
},
42+
{
43+
id: 'filter',
44+
title: 'Filter',
45+
type: 'dropdown',
46+
options: [
47+
{ label: 'None', id: '' },
48+
{ label: 'Partial Preview', id: 'partial' },
49+
{ label: 'Full Preview', id: 'full' },
50+
{ label: 'Free eBooks', id: 'free-ebooks' },
51+
{ label: 'Paid eBooks', id: 'paid-ebooks' },
52+
{ label: 'All eBooks', id: 'ebooks' },
53+
],
54+
condition: { field: 'operation', value: 'volume_search' },
55+
mode: 'advanced',
56+
},
57+
{
58+
id: 'printType',
59+
title: 'Print Type',
60+
type: 'dropdown',
61+
options: [
62+
{ label: 'All', id: 'all' },
63+
{ label: 'Books', id: 'books' },
64+
{ label: 'Magazines', id: 'magazines' },
65+
],
66+
value: () => 'all',
67+
condition: { field: 'operation', value: 'volume_search' },
68+
mode: 'advanced',
69+
},
70+
{
71+
id: 'orderBy',
72+
title: 'Order By',
73+
type: 'dropdown',
74+
options: [
75+
{ label: 'Relevance', id: 'relevance' },
76+
{ label: 'Newest', id: 'newest' },
77+
],
78+
value: () => 'relevance',
79+
condition: { field: 'operation', value: 'volume_search' },
80+
mode: 'advanced',
81+
},
82+
{
83+
id: 'maxResults',
84+
title: 'Max Results',
85+
type: 'short-input',
86+
placeholder: 'Number of results (1-40)',
87+
condition: { field: 'operation', value: 'volume_search' },
88+
mode: 'advanced',
89+
},
90+
{
91+
id: 'startIndex',
92+
title: 'Start Index',
93+
type: 'short-input',
94+
placeholder: 'Starting index for pagination',
95+
condition: { field: 'operation', value: 'volume_search' },
96+
mode: 'advanced',
97+
},
98+
{
99+
id: 'langRestrict',
100+
title: 'Language',
101+
type: 'short-input',
102+
placeholder: 'ISO 639-1 code (e.g., en, es, fr)',
103+
condition: { field: 'operation', value: 'volume_search' },
104+
mode: 'advanced',
105+
},
106+
{
107+
id: 'volumeId',
108+
title: 'Volume ID',
109+
type: 'short-input',
110+
placeholder: 'Google Books volume ID',
111+
condition: { field: 'operation', value: 'volume_details' },
112+
required: { field: 'operation', value: 'volume_details' },
113+
},
114+
{
115+
id: 'projection',
116+
title: 'Projection',
117+
type: 'dropdown',
118+
options: [
119+
{ label: 'Full', id: 'full' },
120+
{ label: 'Lite', id: 'lite' },
121+
],
122+
value: () => 'full',
123+
mode: 'advanced',
124+
},
125+
],
126+
127+
tools: {
128+
access: ['google_books_volume_search', 'google_books_volume_details'],
129+
config: {
130+
tool: (params) => `google_books_${params.operation}`,
131+
params: (params) => {
132+
const { operation, ...rest } = params
133+
134+
let maxResults: number | undefined
135+
if (params.maxResults) {
136+
maxResults = Number.parseInt(params.maxResults, 10)
137+
if (Number.isNaN(maxResults)) {
138+
maxResults = undefined
139+
}
140+
}
141+
142+
let startIndex: number | undefined
143+
if (params.startIndex) {
144+
startIndex = Number.parseInt(params.startIndex, 10)
145+
if (Number.isNaN(startIndex)) {
146+
startIndex = undefined
147+
}
148+
}
149+
150+
return {
151+
...rest,
152+
maxResults,
153+
startIndex,
154+
filter: params.filter || undefined,
155+
printType: params.printType || undefined,
156+
orderBy: params.orderBy || undefined,
157+
projection: params.projection || undefined,
158+
}
159+
},
160+
},
161+
},
162+
163+
inputs: {
164+
operation: { type: 'string', description: 'Operation to perform' },
165+
apiKey: { type: 'string', description: 'Google Books API key' },
166+
query: { type: 'string', description: 'Search query' },
167+
filter: { type: 'string', description: 'Filter by availability' },
168+
printType: { type: 'string', description: 'Print type filter' },
169+
orderBy: { type: 'string', description: 'Sort order' },
170+
maxResults: { type: 'string', description: 'Maximum number of results' },
171+
startIndex: { type: 'string', description: 'Starting index for pagination' },
172+
langRestrict: { type: 'string', description: 'Language restriction' },
173+
volumeId: { type: 'string', description: 'Volume ID for details' },
174+
projection: { type: 'string', description: 'Projection level' },
175+
},
176+
177+
outputs: {
178+
totalItems: { type: 'number', description: 'Total number of matching results' },
179+
volumes: { type: 'json', description: 'List of matching volumes' },
180+
id: { type: 'string', description: 'Volume ID' },
181+
title: { type: 'string', description: 'Book title' },
182+
subtitle: { type: 'string', description: 'Book subtitle' },
183+
authors: { type: 'json', description: 'List of authors' },
184+
publisher: { type: 'string', description: 'Publisher name' },
185+
publishedDate: { type: 'string', description: 'Publication date' },
186+
description: { type: 'string', description: 'Book description' },
187+
pageCount: { type: 'number', description: 'Number of pages' },
188+
categories: { type: 'json', description: 'Book categories' },
189+
averageRating: { type: 'number', description: 'Average rating (1-5)' },
190+
ratingsCount: { type: 'number', description: 'Number of ratings' },
191+
language: { type: 'string', description: 'Language code' },
192+
previewLink: { type: 'string', description: 'Link to preview on Google Books' },
193+
infoLink: { type: 'string', description: 'Link to info page' },
194+
thumbnailUrl: { type: 'string', description: 'Book cover thumbnail URL' },
195+
isbn10: { type: 'string', description: 'ISBN-10 identifier' },
196+
isbn13: { type: 'string', description: 'ISBN-13 identifier' },
197+
},
198+
}

apps/sim/blocks/registry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { GitHubBlock, GitHubV2Block } from '@/blocks/blocks/github'
3939
import { GitLabBlock } from '@/blocks/blocks/gitlab'
4040
import { GmailBlock, GmailV2Block } from '@/blocks/blocks/gmail'
4141
import { GoogleSearchBlock } from '@/blocks/blocks/google'
42+
import { GoogleBooksBlock } from '@/blocks/blocks/google_books'
4243
import { GoogleCalendarBlock, GoogleCalendarV2Block } from '@/blocks/blocks/google_calendar'
4344
import { GoogleDocsBlock } from '@/blocks/blocks/google_docs'
4445
import { GoogleDriveBlock } from '@/blocks/blocks/google_drive'
@@ -214,6 +215,7 @@ export const registry: Record<string, BlockConfig> = {
214215
gmail_v2: GmailV2Block,
215216
google_calendar: GoogleCalendarBlock,
216217
google_calendar_v2: GoogleCalendarV2Block,
218+
google_books: GoogleBooksBlock,
217219
google_docs: GoogleDocsBlock,
218220
google_drive: GoogleDriveBlock,
219221
google_forms: GoogleFormsBlock,

apps/sim/components/icons.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,21 @@ export function AirweaveIcon(props: SVGProps<SVGSVGElement>) {
11571157
)
11581158
}
11591159

1160+
export function GoogleBooksIcon(props: SVGProps<SVGSVGElement>) {
1161+
return (
1162+
<svg {...props} xmlns='http://www.w3.org/2000/svg' viewBox='0 0 478.633 540.068'>
1163+
<path
1164+
fill='#1C51A4'
1165+
d='M449.059,218.231L245.519,99.538l-0.061,193.23c0.031,1.504-0.368,2.977-1.166,4.204c-0.798,1.258-1.565,1.995-2.915,2.547c-1.35,0.552-2.792,0.706-4.204,0.399c-1.412-0.307-2.7-1.043-3.713-2.117l-69.166-70.609l-69.381,70.179c-1.013,0.982-2.301,1.657-3.652,1.903c-1.381,0.246-2.792,0.092-4.081-0.491c-1.289-0.583-1.626-0.522-2.394-1.749c-0.767-1.197-1.197-2.608-1.197-4.081L85.031,6.007l-2.915-1.289C43.973-11.638,0,16.409,0,59.891v420.306c0,46.029,49.312,74.782,88.775,51.767l360.285-210.138C488.491,298.782,488.491,241.246,449.059,218.231z'
1166+
/>
1167+
<path
1168+
fill='#80D7FB'
1169+
d='M88.805,8.124c-2.179-1.289-4.419-2.363-6.659-3.345l0.123,288.663c0,1.442,0.43,2.854,1.197,4.081c0.767,1.197,1.872,2.148,3.161,2.731c1.289,0.583,2.7,0.736,4.081,0.491c1.381-0.246,2.639-0.921,3.652-1.903l69.749-69.688l69.811,69.749c1.013,1.074,2.301,1.81,3.713,2.117c1.412,0.307,2.884,0.153,4.204-0.399c1.319-0.552,2.455-1.565,3.253-2.792c0.798-1.258,1.197-2.731,1.166-4.204V99.998L88.805,8.124z'
1170+
/>
1171+
</svg>
1172+
)
1173+
}
1174+
11601175
export function GoogleDocsIcon(props: SVGProps<SVGSVGElement>) {
11611176
return (
11621177
<svg
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './types'
2+
export { googleBooksVolumeDetailsTool } from './volume_details'
3+
export { googleBooksVolumeSearchTool } from './volume_search'

0 commit comments

Comments
 (0)