Skip to content

Commit 0d141f2

Browse files
EricGustinbyrro
andauthored
Add google contacts to docs (#176)
* Add google contacts * fix typo --------- Co-authored-by: Renato Byrro <[email protected]>
1 parent 49f5021 commit 0d141f2

18 files changed

+505
-3
lines changed
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Calendar
2+
3+
import ToolInfo from "@/components/ToolInfo";
4+
import Badges from "@/components/Badges";
5+
import TabbedCodeBlock from "@/components/TabbedCodeBlock";
6+
import TableOfContents from "@/components/TableOfContents";
7+
8+
<ToolInfo
9+
description="Enable agents to interact with Google Contacts."
10+
author="Arcade"
11+
codeLink="https://github.com/ArcadeAI/arcade-ai/tree/main/toolkits/google"
12+
authType="oauth2"
13+
authProviderName="Google"
14+
versions={["0.1.0"]}
15+
/>
16+
17+
<Badges repo="arcadeai/arcade_google" />
18+
19+
The Arcade Contacts toolkit provides a pre-built set of tools for interacting with Google Contacts. These tools make it easy to build agents and AI apps that can:
20+
21+
- Create new contacts
22+
- Search for contacts by name or email
23+
24+
## Install
25+
26+
```bash
27+
pip install arcade_google
28+
```
29+
30+
<Note>
31+
pip installing the toolkit is only needed if you are [self-hosting](/home/install/overview) Arcade. You do not need to install the toolkit if you're using Arcade Cloud.
32+
</Note>
33+
34+
## Available Tools
35+
36+
<TableOfContents
37+
headers={["Tool Name", "Description"]}
38+
data={[
39+
["SearchContactsByEmail", "Search the user's contacts in Google Contacts by email address."],
40+
["SearchContactsByName", "Search the user's contacts in Google Contacts by name."],
41+
["CreateContact", "Create a new contact record in Google Contacts."],
42+
]}
43+
/>
44+
45+
<Tip>
46+
If you need to perform an action that's not listed here, you can [get in touch
47+
with us](mailto:[email protected]) to request a new tool, or [create your
48+
own tools](/home/build-tools/create-a-toolkit) with the [Google auth
49+
provider](/home/auth-providers/google#using-google-auth-in-custom-tools).
50+
</Tip>
51+
52+
## SearchContactsByEmail
53+
54+
Search the user's contacts in Google Contacts by email address.
55+
56+
<TabbedCodeBlock
57+
tabs={[
58+
{
59+
label: "Call the tool with user authorization",
60+
content: {
61+
Python: [
62+
"/examples/integrations/toolkits/google/contacts/search_contacts_by_email_example_call_tool.py",
63+
],
64+
JavaScript: [
65+
"/examples/integrations/toolkits/google/contacts/search_contacts_by_email_example_call_tool.js",
66+
],
67+
},
68+
},
69+
{
70+
label: "Execute the tool with OpenAI",
71+
content: {
72+
Python: [
73+
"/examples/integrations/toolkits/google/contacts/search_contacts_by_email_example_llm_oai.py",
74+
],
75+
JavaScript: [
76+
"/examples/integrations/toolkits/google/contacts/search_contacts_by_email_example_llm_oai.js",
77+
],
78+
},
79+
},
80+
]}
81+
/>
82+
83+
**Parameters**
84+
85+
- **`email`** _(string, required)_: The email address to search for.
86+
- **`limit`** _(integer, optional)_: The maximum number of contacts to return (30 is the max allowed by the Google API).
87+
88+
---
89+
90+
## SearchContactsByName
91+
92+
Search the user's contacts in Google Contacts by name.
93+
94+
<TabbedCodeBlock
95+
tabs={[
96+
{
97+
label: "Call the tool with user authorization",
98+
content: {
99+
Python: [
100+
"/examples/integrations/toolkits/google/contacts/search_contacts_by_name_example_call_tool.py",
101+
],
102+
JavaScript: [
103+
"/examples/integrations/toolkits/google/contacts/search_contacts_by_name_example_call_tool.js",
104+
],
105+
},
106+
},
107+
{
108+
label: "Execute the tool with OpenAI",
109+
content: {
110+
Python: [
111+
"/examples/integrations/toolkits/google/contacts/search_contacts_by_name_example_llm_oai.py",
112+
],
113+
JavaScript: [
114+
"/examples/integrations/toolkits/google/contacts/search_contacts_by_name_example_llm_oai.js",
115+
],
116+
},
117+
},
118+
]}
119+
/>
120+
121+
**Parameters**
122+
123+
- **`name`** _(string, required)_: The full name to search for.
124+
- **`limit`** _(integer, optional)_: The maximum number of contacts to return (30 is the max allowed by the Google API).
125+
126+
---
127+
128+
## CreateContact
129+
130+
Create a new contact record in Google Contacts.
131+
132+
<TabbedCodeBlock
133+
tabs={[
134+
{
135+
label: "Call the tool with user authorization",
136+
content: {
137+
Python: [
138+
"/examples/integrations/toolkits/google/contacts/create_contact_example_call_tool.py",
139+
],
140+
JavaScript: [
141+
"/examples/integrations/toolkits/google/contacts/create_contact_example_call_tool.js",
142+
],
143+
},
144+
},
145+
{
146+
label: "Execute the tool with OpenAI",
147+
content: {
148+
Python: [
149+
"/examples/integrations/toolkits/google/contacts/create_contact_example_llm_oai.py",
150+
],
151+
JavaScript: [
152+
"/examples/integrations/toolkits/google/contacts/create_contact_example_llm_oai.js",
153+
],
154+
},
155+
},
156+
]}
157+
/>
158+
159+
**Parameters**
160+
161+
- **`given_name`** _(string, required)_: The given name of the contact.
162+
- **`family_name`** _(string, optional)_: The optional family name of the contact.
163+
- **`email`** _(string, optional)_: The optional email address of the contact.
164+
165+
166+
---
167+
168+
## Auth
169+
170+
The Arcade Contacts toolkit uses the [Google auth provider](/home/auth-providers/google) to connect to users' Google accounts.
171+
172+
With the hosted Arcade Engine, there's nothing to configure. Your users will see `Arcade (demo)` as the name of the application that's requesting permission.
173+
174+
<Warning type="warning" emoji="⚠️">
175+
The hosted Arcade Engine is intended for demo and testing purposes only, not
176+
for production use. To use Arcade and Google Contacts in production, you
177+
must use a self-hosted instance of the Arcade Engine.
178+
</Warning>
179+
180+
With a self-hosted installation of Arcade, you need to [configure the Google auth provider](/home/auth-providers/google#configuring-google-auth) with your own Google app credentials.

public/examples/integrations/toolkits/google/calendar/create_event_example_call_tool.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ const response = await client.tools.execute({
3333
user_id: USER_ID,
3434
});
3535

36-
console.log(response);
36+
console.log(response);

public/examples/integrations/toolkits/google/calendar/create_event_example_llm_oai.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ const response = await client.chat.completions.create({
1919
tool_choice: 'generate'
2020
});
2121

22-
console.log(response.choices[0].message.content);
22+
console.log(response.choices[0].message.content);

public/examples/integrations/toolkits/google/calendar/delete_event_example_call_tool.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ const response = await client.tools.execute({
2929
user_id: USER_ID,
3030
});
3131

32-
console.log(response);
32+
console.log(response);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Arcade } from "@arcadeai/arcadejs";
2+
3+
const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable
4+
5+
const USER_ID = "[email protected]";
6+
const TOOL_NAME = "Google.CreateContact";
7+
8+
// Start the authorization process
9+
const authResponse = await client.tools.authorize({
10+
tool_name: TOOL_NAME,
11+
user_id: USER_ID,
12+
});
13+
14+
if (authResponse.status !== "completed") {
15+
console.log(`Click this link to authorize: ${authResponse.url}`);
16+
}
17+
18+
// Wait for the authorization to complete
19+
await client.auth.waitForCompletion(authResponse);
20+
21+
const toolInput = {
22+
given_name: "John",
23+
family_name: "Doe",
24+
25+
};
26+
27+
const response = await client.tools.execute({
28+
tool_name: TOOL_NAME,
29+
input: toolInput,
30+
user_id: USER_ID,
31+
});
32+
33+
console.log(response);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from arcadepy import Arcade
2+
3+
client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable
4+
5+
USER_ID = "[email protected]"
6+
TOOL_NAME = "Google.CreateContact"
7+
8+
auth_response = client.tools.authorize(
9+
tool_name=TOOL_NAME,
10+
user_id=USER_ID,
11+
)
12+
13+
if auth_response.status != "completed":
14+
print(f"Click this link to authorize: {auth_response.url}")
15+
16+
# Wait for the authorization to complete
17+
client.auth.wait_for_completion(auth_response)
18+
19+
tool_input = {
20+
"given_name": "John",
21+
"family_name": "Doe",
22+
"email": "[email protected]",
23+
}
24+
25+
response = client.tools.execute(
26+
tool_name=TOOL_NAME,
27+
input=tool_input,
28+
user_id=USER_ID,
29+
)
30+
print(response)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import OpenAI from 'openai';
2+
3+
const USER_ID = "[email protected]";
4+
const PROMPT = "Create a new contact record for John Doe with the email [email protected].";
5+
const TOOL_NAME = "Google.CreateContact";
6+
7+
const client = new OpenAI({
8+
baseURL: 'https://api.arcade.dev',
9+
apiKey: process.env.ARCADE_API_KEY
10+
});
11+
12+
const response = await client.chat.completions.create({
13+
messages: [
14+
{ role: 'user', content: PROMPT }
15+
],
16+
model: 'gpt-4o-mini',
17+
user: USER_ID,
18+
tools: [TOOL_NAME],
19+
tool_choice: 'generate'
20+
});
21+
22+
console.log(response.choices[0].message.content);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
from openai import OpenAI
3+
4+
USER_ID = "[email protected]"
5+
PROMPT = "Create a new contact record for John Doe with the email [email protected]."
6+
TOOL_NAME = "Google.CreateContact"
7+
8+
client = OpenAI(
9+
base_url="https://api.arcade.dev", api_key=os.environ.get("ARCADE_API_KEY")
10+
)
11+
12+
response = client.chat.completions.create(
13+
messages=[
14+
{"role": "user", "content": PROMPT},
15+
],
16+
model="gpt-4o-mini",
17+
user=USER_ID,
18+
tools=[TOOL_NAME],
19+
tool_choice="generate",
20+
)
21+
print(response.choices[0].message.content)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Arcade } from "@arcadeai/arcadejs";
2+
3+
const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable
4+
5+
const USER_ID = "[email protected]";
6+
const TOOL_NAME = "Google.SearchContactsByEmail";
7+
8+
// Start the authorization process
9+
const authResponse = await client.tools.authorize({
10+
tool_name: TOOL_NAME,
11+
user_id: USER_ID,
12+
});
13+
14+
if (authResponse.status !== "completed") {
15+
console.log(`Click this link to authorize: ${authResponse.url}`);
16+
}
17+
18+
// Wait for the authorization to complete
19+
await client.auth.waitForCompletion(authResponse);
20+
21+
const toolInput = {
22+
23+
limit: 30,
24+
};
25+
26+
const response = await client.tools.execute({
27+
tool_name: TOOL_NAME,
28+
input: toolInput,
29+
user_id: USER_ID,
30+
});
31+
32+
console.log(response);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from arcadepy import Arcade
2+
3+
client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable
4+
5+
USER_ID = "[email protected]"
6+
TOOL_NAME = "Google.SearchContactsByEmail"
7+
8+
auth_response = client.tools.authorize(
9+
tool_name=TOOL_NAME,
10+
user_id=USER_ID,
11+
)
12+
13+
if auth_response.status != "completed":
14+
print(f"Click this link to authorize: {auth_response.url}")
15+
16+
# Wait for the authorization to complete
17+
client.auth.wait_for_completion(auth_response)
18+
19+
tool_input = {
20+
"email": "[email protected]",
21+
"limit": 30,
22+
}
23+
24+
response = client.tools.execute(
25+
tool_name=TOOL_NAME,
26+
input=tool_input,
27+
user_id=USER_ID,
28+
)
29+
print(response)

0 commit comments

Comments
 (0)