Skip to content

Add docs for ListEmailsByProperty tool #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
59 changes: 58 additions & 1 deletion pages/toolkits/productivity/microsoft/outlook_mail.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ These tools are currently available in the Arcade Sheets toolkit.
["ReplyAllToEmail", "Reply to all recipients of an existing email in Outlook."],
["ListEmails", "List emails in the user's mailbox across all folders."],
["ListEmailsInFolder", "List the user's emails in the specified folder."],
["ListEmailsByProperty", "List emails in the user's mailbox across all folders filtering by a property."]
]}
/>

Expand Down Expand Up @@ -305,6 +306,39 @@ Exactly one of `well_known_folder_name` or `folder_id` MUST be provided.

---

## ListEmailsByProperty

List emails in the user's mailbox across all folders filtering by a property.

**Parameters**

- **`property`** (enum ([EmailFilterProperty](#emailfilterproperty)), required): The property to filter the emails by.
- **`operator`** (enum ([FilterOperator](#filteroperator)), required): The operator to use for the filter
- **`value`** (string, required): The value to filter the emails by.
- **`limit`** (int, optional): The number of messages to return. Max is 100. Defaults to 5.
- **`pagination_token`** (str, optional): The pagination token to continue a previous request

<TabbedCodeBlock
tabs={[
{
label: "Call the tool with user authorization",
content: {
Python: ["/examples/integrations/toolkits/microsoft/outlook_mail/list_emails_by_property_example_call_tool.py"],
JavaScript: ["/examples/integrations/toolkits/microsoft/outlook_mail/list_emails_by_property_example_call_tool.js"]
}
},
{
label: "Execute the tool with OpenAI",
content: {
Python: ["/examples/integrations/toolkits/microsoft/outlook_mail/list_emails_by_property_example_llm_oai.py"],
JavaScript: ["/examples/integrations/toolkits/microsoft/outlook_mail/list_emails_by_property_example_llm_oai.js"]
}
}
]}
/>

---

## Auth

The Arcade Outlook Mail toolkit uses the [Microsoft auth provider](/home/auth-providers/microsoft) to connect to users' Microsoft accounts.
Expand Down Expand Up @@ -337,4 +371,27 @@ The type of reply to send to an email.
- **`REPLY`** _(string: "reply")_
- **`REPLY_ALL`** _(string: "reply_all")_

<ToolFooter pipPackageName="arcade_microsoft" />
<ToolFooter pipPackageName="arcade_microsoft" />

### EmailFilterProperty

The property to filter the emails by.

- **`SUBJECT`** _(string: "subject")_
- **`CONVERSATION_ID`** _(string: "conversationId")_
- **`RECEIVED_DATE_TIME`** _(string: "receivedDateTime")_
- **`SENDER`** _(string: "sender/emailAddress/address")_

### FilterOperator

The operator to use for the filter.

- **`EQUAL`** _(string: "eq")_
- **`NOT_EQUAL`** _(string: "ne")_
- **`GREATER_THAN`** _(string: "gt")_
- **`GREATER_THAN_OR_EQUAL_TO`** _(string: "ge")_
- **`LESS_THAN`** _(string: "lt")_
- **`LESS_THAN_OR_EQUAL_TO`** _(string: "le")_
- **`STARTS_WITH`** _(string: "startsWith")_
- **`ENDS_WITH`** _(string: "endsWith")_
- **`CONTAINS`** _(string: "contains")_
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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 = "Microsoft.ListEmailsByProperty";

// 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 = {
property: "sender",
operator: "contains",
value: "arcade.dev",
limit: 10,
};

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,31 @@
from arcadepy import Arcade

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

USER_ID = "[email protected]"
TOOL_NAME = "Microsoft.ListEmailsByProperty"

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 = {
"property": "sender",
"operator": "contains",
"value": "arcade.dev",
"limit": 10,
}

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 = "List 10 emails from anyone from the domain 'arcade.dev'";
const TOOL_NAME = "Microsoft.ListEmailsByProperty";

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 = "List 10 emails from anyone from the domain 'arcade.dev'"
TOOL_NAME = "Microsoft.ListEmailsByProperty"

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)