Skip to content

Commit 36f4863

Browse files
authored
Document Slack tools to retrieve messages and metadata from MPIM conversations (#160)
document slack tools to retrieve messages and metadata from MPIM conversations
1 parent 6816414 commit 36f4863

9 files changed

+294
-2
lines changed

pages/toolkits/social-communication/slack.mdx

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The Arcade Slack toolkit provides a comprehensive set of tools for interacting w
2626
- Retrieve user information
2727
- List users
2828
- List conversations
29+
- Retrieve messages in a channel, direct or multi-person conversation
2930
- Retrieve conversation metadata
3031

3132
## Install
@@ -65,6 +66,10 @@ pip install arcade_slack
6566
"GetMessagesInDirectMessageConversationByUsername",
6667
"Fetch the messages in a direct message conversation using the username of the other participant.",
6768
],
69+
[
70+
"GetMessagesInMultiPersonDmConversationByUsername",
71+
"Fetch the messages in a multi-person direct message conversation using the usernames of the other participants.",
72+
],
6873
[
6974
"GetConversationMetadataById",
7075
"Retrieve metadata of a conversation using its ID.",
@@ -77,6 +82,10 @@ pip install arcade_slack
7782
"GetDirectMessageConversationMetadataByUsername",
7883
"Retrieve metadata of a direct message conversation using the username of the other participant.",
7984
],
85+
[
86+
"GetMultiPersonDmConversationMetadataByUsername",
87+
"Retrieve metadata of a multi-person direct message conversation using the usernames of the other participants.",
88+
],
8089
["ListConversationsMetadata", "List metadata for Slack conversations."],
8190
[
8291
"ListPublicChannelsMetadata",
@@ -354,11 +363,51 @@ Get the messages in a channel in Slack.
354363
]}
355364
/>
356365

357-
Get the messages in a channel in Slack.
366+
Get the messages in a Direct Message conversation with another user in Slack.
358367

359368
**Parameters**
360369

361-
- **`channel_name`** _(string, required)_ The name of the channel to get messages for.
370+
- **`username`** _(string, required)_ The username of the user to get messages with.
371+
- **`oldest_relative`** _(string, optional)_ The oldest message to include in the results, specified as a time offset from the current time in the format 'DD:HH:MM'.
372+
- **`latest_relative`** _(string, optional)_ The latest message to include in the results, specified as a time offset from the current time in the format 'DD:HH:MM'.
373+
- **`oldest_datetime`** _(string, optional)_ The oldest message to include in the results, specified as a datetime string in the format 'YYYY-MM-DD HH:MM:SS'.
374+
- **`latest_datetime`** _(string, optional)_ The latest message to include in the results, specified as a datetime string in the format 'YYYY-MM-DD HH:MM:SS'.
375+
- **`limit`** _(int, optional)_ The maximum number of messages to return. Defaults to 200.
376+
- **`next_cursor`** _(string, optional)_ The cursor to use for pagination.
377+
378+
---
379+
380+
## GetMessagesInMultiPersonDmConversationByUsername
381+
382+
<br />
383+
<TabbedCodeBlock
384+
tabs={[
385+
{
386+
label: "Call the Tool with User Authorization",
387+
content: {
388+
Python: [
389+
"/examples/integrations/toolkits/slack/get_messages_in_multi_person_dm_conversation_by_username_example_call_tool.py",
390+
],
391+
JavaScript: ["/examples/integrations/toolkits/slack/get_messages_in_multi_person_dm_conversation_by_username_example_call_tool.js"],
392+
},
393+
},
394+
{
395+
label: "Execute the Tool with OpenAI",
396+
content: {
397+
Python: [
398+
"/examples/integrations/toolkits/slack/get_messages_in_multi_person_dm_conversation_by_username_example_llm_oai.py",
399+
],
400+
JavaScript: ["/examples/integrations/toolkits/slack/get_messages_in_multi_person_dm_conversation_by_username_example_llm_oai.js"],
401+
},
402+
},
403+
]}
404+
/>
405+
406+
Get the messages in a multi-person direct message conversation in Slack by the usernames of the participants (other than the currently authenticated user).
407+
408+
**Parameters**
409+
410+
- **`usernames`** _(list of strings, required)_ The usernames of the users to get messages with.
362411
- **`oldest_relative`** _(string, optional)_ The oldest message to include in the results, specified as a time offset from the current time in the format 'DD:HH:MM'.
363412
- **`latest_relative`** _(string, optional)_ The latest message to include in the results, specified as a time offset from the current time in the format 'DD:HH:MM'.
364413
- **`oldest_datetime`** _(string, optional)_ The oldest message to include in the results, specified as a datetime string in the format 'YYYY-MM-DD HH:MM:SS'.
@@ -472,6 +521,41 @@ Get the metadata of a direct message conversation in Slack searching by the user
472521

473522
---
474523

524+
## GetMultiPersonDmConversationMetadataByUsername
525+
526+
<br />
527+
<TabbedCodeBlock
528+
tabs={[
529+
{
530+
label: "Call the Tool with User Authorization",
531+
content: {
532+
Python: [
533+
"/examples/integrations/toolkits/slack/get_multi_person_dm_conversation_metadata_by_username_example_call_tool.py",
534+
],
535+
JavaScript: ["/examples/integrations/toolkits/slack/get_multi_person_dm_conversation_metadata_by_username_example_call_tool.js"],
536+
},
537+
},
538+
{
539+
label: "Execute the Tool with OpenAI",
540+
content: {
541+
Python: [
542+
"/examples/integrations/toolkits/slack/get_multi_person_dm_conversation_metadata_by_username_example_llm_oai.py",
543+
],
544+
JavaScript: ["/examples/integrations/toolkits/slack/get_multi_person_dm_conversation_metadata_by_username_example_llm_oai.js"],
545+
},
546+
},
547+
]}
548+
/>
549+
550+
Get the metadata of a multi-person direct message conversation in Slack searching by the usernames of the participants (other than the currently authenticated user).
551+
552+
**Parameters**
553+
554+
- **`usernames`** _(list of strings, required)_ The usernames of the users to get messages with.
555+
- **`next_cursor`** _(string, optional)_ The cursor to use for pagination, if continuing from a previous search.
556+
557+
---
558+
475559
## ListConversationsMetadata
476560

477561
<br />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 = "Slack.GetMessagesInMultiPersonDmConversationByUsername";
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+
usernames: ["john_doe", "jane_doe"],
23+
limit: 100,
24+
oldest_datetime: "2023-01-01 00:00:00",
25+
latest_datetime: "2023-01-31 23:59:59"
26+
};
27+
28+
const response = await client.tools.execute({
29+
tool_name: TOOL_NAME,
30+
input: toolInput,
31+
user_id: USER_ID,
32+
});
33+
34+
console.log(response);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 = "Slack.GetMessagesInMultiPersonDmConversationByUsername"
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+
"usernames": ["john_doe", "jane_doe"],
21+
"limit": 100,
22+
"oldest_datetime": "2023-01-01 00:00:00",
23+
"latest_datetime": "2023-01-31 23:59:59",
24+
}
25+
26+
response = client.tools.execute(
27+
tool_name=TOOL_NAME,
28+
input=tool_input,
29+
user_id=USER_ID,
30+
)
31+
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 = "Fetch the messages in the multi-person direct message conversation with the usernames 'john_doe' and 'jane_doe' between '2023-01-01 00:00:00' and '2023-01-31 23:59:59'."
5+
const TOOL_NAME = 'Slack.GetMessagesInMultiPersonDmConversationByUsername';
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 = "Fetch the messages in the multi-person direct message conversation with the usernames 'john_doe' and 'jane_doe' between '2023-01-01 00:00:00' and '2023-01-31 23:59:59'."
6+
TOOL_NAME = "Slack.GetMessagesInMultiPersonDmConversationByUsername"
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: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 = "Slack.GetMultiPersonDmConversationMetadataByUsername";
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+
usernames: ["john_doe", "jane_doe"]
23+
};
24+
25+
const response = await client.tools.execute({
26+
tool_name: TOOL_NAME,
27+
input: toolInput,
28+
user_id: USER_ID,
29+
});
30+
31+
console.log(response);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 = "Slack.GetMultiPersonDmConversationMetadataByUsername"
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 = {"usernames": ["john_doe", "jane_doe"]}
20+
21+
response = client.tools.execute(
22+
tool_name=TOOL_NAME,
23+
input=tool_input,
24+
user_id=USER_ID,
25+
)
26+
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 = "Retrieve the metadata for the multi-person direct message conversation with the usernames 'john_doe' and 'jane_doe'."
5+
const TOOL_NAME = 'Slack.GetMultiPersonDmConversationMetadataByUsername';
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 = "Retrieve the metadata for the multi-person direct message conversation with the usernames 'john_doe' and 'jane_doe'."
6+
TOOL_NAME = "Slack.GetMultiPersonDmConversationMetadataByUsername"
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)

0 commit comments

Comments
 (0)