Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 180 additions & 0 deletions pages/toolkits/productivity/google/contacts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# Calendar

import ToolInfo from "@/components/ToolInfo";
import Badges from "@/components/Badges";
import TabbedCodeBlock from "@/components/TabbedCodeBlock";
import TableOfContents from "@/components/TableOfContents";

<ToolInfo
description="Enable agents to interact with Google Contacts."
author="Arcade"
codeLink="https://github.com/ArcadeAI/arcade-ai/tree/main/toolkits/google"
authType="oauth2"
authProviderName="Google"
versions={["0.1.0"]}
/>

<Badges repo="arcadeai/arcade_google" />

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:

- Create new contacts
- Search for contacts by name or email

## Install

```bash
pip install arcade_google
```

<Note>
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.
</Note>

## Available Tools

<TableOfContents
headers={["Tool Name", "Description"]}
data={[
["SearchContactsByEmail", "Search the user's contacts in Google Contacts by email address."],
["SearchContactsByName", "Search the user's contacts in Google Contacts by name."],
["CreateContact", "Create a new contact record in Google Contacts."],
]}
/>

<Tip>
If you need to perform an action that's not listed here, you can [get in touch
with us](mailto:[email protected]) to request a new tool, or [create your
own tools](/home/build-tools/create-a-toolkit) with the [Google auth
provider](/home/auth-providers/google#using-google-auth-in-custom-tools).
</Tip>

## SearchContactsByEmail

Search the user's contacts in Google Contacts by email address.

<TabbedCodeBlock
tabs={[
{
label: "Call the tool with user authorization",
content: {
Python: [
"/examples/integrations/toolkits/google/contacts/search_contacts_by_email_example_call_tool.py",
],
JavaScript: [
"/examples/integrations/toolkits/google/contacts/search_contacts_by_email_example_call_tool.js",
],
},
},
{
label: "Execute the tool with OpenAI",
content: {
Python: [
"/examples/integrations/toolkits/google/contacts/search_contacts_by_email_example_llm_oai.py",
],
JavaScript: [
"/examples/integrations/toolkits/google/contacts/search_contacts_by_email_example_llm_oai.js",
],
},
},
]}
/>

**Parameters**

- **`email`** _(string, required)_: The email address to search for.
- **`limit`** _(integer, optional)_: The maximum number of contacts to return (30 is the max allowed by the Google API).

---

## SearchContactsByName

Search the user's contacts in Google Contacts by name.

<TabbedCodeBlock
tabs={[
{
label: "Call the tool with user authorization",
content: {
Python: [
"/examples/integrations/toolkits/google/contacts/search_contacts_by_name_example_call_tool.py",
],
JavaScript: [
"/examples/integrations/toolkits/google/contacts/search_contacts_by_name_example_call_tool.js",
],
},
},
{
label: "Execute the tool with OpenAI",
content: {
Python: [
"/examples/integrations/toolkits/google/contacts/search_contacts_by_name_example_llm_oai.py",
],
JavaScript: [
"/examples/integrations/toolkits/google/contacts/search_contacts_by_name_example_llm_oai.js",
],
},
},
]}
/>

**Parameters**

- **`name`** _(string, required)_: The full name to search for.
- **`limit`** _(integer, optional)_: The maximum number of contacts to return (30 is the max allowed by the Google API).

---

## CreateContact

Create a new contact record in Google Contacts.

<TabbedCodeBlock
tabs={[
{
label: "Call the tool with user authorization",
content: {
Python: [
"/examples/integrations/toolkits/google/contacts/create_contact_example_call_tool.py",
],
JavaScript: [
"/examples/integrations/toolkits/google/contacts/create_contact_example_call_tool.js",
],
},
},
{
label: "Execute the tool with OpenAI",
content: {
Python: [
"/examples/integrations/toolkits/google/contacts/create_contact_example_llm_oai.py",
],
JavaScript: [
"/examples/integrations/toolkits/google/contacts/create_contact_example_llm_oai.js",
],
},
},
]}
/>

**Parameters**

- **`given_name`** _(string, required)_: The given name of the contact.
- **`family_name`** _(string, optional)_: The optional family name of the contact.
- **`email`** _(string, optional)_: The optional email address of the contact.


---

## Auth

The Arcade Contacts toolkit uses the [Google auth provider](/home/auth-providers/google) to connect to users' Google accounts.

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.

<Warning type="warning" emoji="⚠️">
The hosted Arcade Engine is intended for demo and testing purposes only, not
for production use. To use Arcade and Google Contacts in production, you
must use a self-hosted instance of the Arcade Engine.
</Warning>

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.
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ const response = await client.tools.execute({
user_id: USER_ID,
});

console.log(response);
console.log(response);
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ const response = await client.chat.completions.create({
tool_choice: 'generate'
});

console.log(response.choices[0].message.content);
console.log(response.choices[0].message.content);
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ const response = await client.tools.execute({
user_id: USER_ID,
});

console.log(response);
console.log(response);
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Arcade } from "@arcadeai/arcadejs";

const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable

const USER_ID = "[email protected]";
const TOOL_NAME = "Google.CreateContact";

// Start the authorization process
const authResponse = await client.tools.authorize({
tool_name: TOOL_NAME,
user_id: USER_ID,
});

if (authResponse.status !== "completed") {
console.log(`Click this link to authorize: ${authResponse.url}`);
}

// Wait for the authorization to complete
await client.auth.waitForCompletion(authResponse);

const toolInput = {
given_name: "John",
family_name: "Doe",
email: "[email protected]",
};

const response = await client.tools.execute({
tool_name: TOOL_NAME,
input: toolInput,
user_id: USER_ID,
});

console.log(response);
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from arcadepy import Arcade

client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable

USER_ID = "[email protected]"
TOOL_NAME = "Google.CreateContact"

auth_response = client.tools.authorize(
tool_name=TOOL_NAME,
user_id=USER_ID,
)

if auth_response.status != "completed":
print(f"Click this link to authorize: {auth_response.url}")

# Wait for the authorization to complete
client.auth.wait_for_completion(auth_response)

tool_input = {
"given_name": "John",
"family_name": "Doe",
"email": "[email protected]",
}

response = client.tools.execute(
tool_name=TOOL_NAME,
input=tool_input,
user_id=USER_ID,
)
print(response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import OpenAI from 'openai';

const USER_ID = "[email protected]";
const PROMPT = "Create a new contact record for John Doe with the email [email protected].";
const TOOL_NAME = "Google.CreateContact";

const client = new OpenAI({
baseURL: 'https://api.arcade.dev',
apiKey: process.env.ARCADE_API_KEY
});

const response = await client.chat.completions.create({
messages: [
{ role: 'user', content: PROMPT }
],
model: 'gpt-4o-mini',
user: USER_ID,
tools: [TOOL_NAME],
tool_choice: 'generate'
});

console.log(response.choices[0].message.content);
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
from openai import OpenAI

USER_ID = "[email protected]"
PROMPT = "Create a new contact record for John Doe with the email [email protected]."
TOOL_NAME = "Google.CreateContact"

client = OpenAI(
base_url="https://api.arcade.dev", api_key=os.environ.get("ARCADE_API_KEY")
)

response = client.chat.completions.create(
messages=[
{"role": "user", "content": PROMPT},
],
model="gpt-4o-mini",
user=USER_ID,
tools=[TOOL_NAME],
tool_choice="generate",
)
print(response.choices[0].message.content)
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Arcade } from "@arcadeai/arcadejs";

const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable

const USER_ID = "[email protected]";
const TOOL_NAME = "Google.SearchContactsByEmail";

// Start the authorization process
const authResponse = await client.tools.authorize({
tool_name: TOOL_NAME,
user_id: USER_ID,
});

if (authResponse.status !== "completed") {
console.log(`Click this link to authorize: ${authResponse.url}`);
}

// Wait for the authorization to complete
await client.auth.waitForCompletion(authResponse);

const toolInput = {
email: "[email protected]",
limit: 30,
};

const response = await client.tools.execute({
tool_name: TOOL_NAME,
input: toolInput,
user_id: USER_ID,
});

console.log(response);
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from arcadepy import Arcade

client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable

USER_ID = "[email protected]"
TOOL_NAME = "Google.SearchContactsByEmail"

auth_response = client.tools.authorize(
tool_name=TOOL_NAME,
user_id=USER_ID,
)

if auth_response.status != "completed":
print(f"Click this link to authorize: {auth_response.url}")

# Wait for the authorization to complete
client.auth.wait_for_completion(auth_response)

tool_input = {
"email": "[email protected]",
"limit": 30,
}

response = client.tools.execute(
tool_name=TOOL_NAME,
input=tool_input,
user_id=USER_ID,
)
print(response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import OpenAI from 'openai';

const USER_ID = "[email protected]";
const PROMPT = "Do i have any contacts with the email [email protected]? If so get info on them.";
const TOOL_NAME = "Google.SearchContactsByEmail";

const client = new OpenAI({
baseURL: 'https://api.arcade.dev',
apiKey: process.env.ARCADE_API_KEY
});

const response = await client.chat.completions.create({
messages: [
{ role: 'user', content: PROMPT }
],
model: 'gpt-4o-mini',
user: USER_ID,
tools: [TOOL_NAME],
tool_choice: 'generate'
});

console.log(response.choices[0].message.content);
Loading