xenial-black
xenial-blackβ€’6mo ago

Marking emails as read not working but AI think it is?

const tools = await toolset.getTools({ actions: ["GMAIL_FETCH_EMAILS", "GMAIL_ADD_LABEL_TO_EMAIL"]});

// Get emails
const emailResult = await agentExecutor.invoke({
input: "Collect all resent emails, Please use this search filter in the query to filter the emails for last 3d, newer_than:3d and only unread emails. Include Email ID, Subject, Sender and Date."
});

console.log("email result :",emailResult.output);


const formatData = await agentExecutor.invoke({
input: "Format the following such as: ---" + emailResult.output
});

console.log("formatData:", formatData.output)

try {
// await bot.sendMessage(process.env.TELEGRAM_CHAT_ID, result.output, { parse_mode: 'Markdown' });

await bot.sendMessage(process.env.TELEGRAM_CHAT_ID, formatData.output, { parse_mode: 'Markdown' });
console.log("We got real format")
} catch (error) {

await bot.sendMessage(process.env.TELEGRAM_CHAT_ID, formatData.output);
console.log("We got no format")
}


const addLabel = await agentExecutor.invoke({
input: "Add label 'Label_906366639289765258' to all these emails: ${"+emailResult.output+"}"
});

const addReceipt = await agentExecutor.invoke({
input: "Add label 'Label_3863516074469975887' to any email which is an Invoice / Bill / Receipt: ${"+emailResult.output+"}"
});

const markRead = await agentExecutor.invoke({
input: "Remove label 'UNREAD' to all these emails: ${"+emailResult.output+"}"
});

console.log("addLabel:", addLabel.output)
console.log("receipts:", addReceipt.output)
console.log("Read:", markRead.output)
const tools = await toolset.getTools({ actions: ["GMAIL_FETCH_EMAILS", "GMAIL_ADD_LABEL_TO_EMAIL"]});

// Get emails
const emailResult = await agentExecutor.invoke({
input: "Collect all resent emails, Please use this search filter in the query to filter the emails for last 3d, newer_than:3d and only unread emails. Include Email ID, Subject, Sender and Date."
});

console.log("email result :",emailResult.output);


const formatData = await agentExecutor.invoke({
input: "Format the following such as: ---" + emailResult.output
});

console.log("formatData:", formatData.output)

try {
// await bot.sendMessage(process.env.TELEGRAM_CHAT_ID, result.output, { parse_mode: 'Markdown' });

await bot.sendMessage(process.env.TELEGRAM_CHAT_ID, formatData.output, { parse_mode: 'Markdown' });
console.log("We got real format")
} catch (error) {

await bot.sendMessage(process.env.TELEGRAM_CHAT_ID, formatData.output);
console.log("We got no format")
}


const addLabel = await agentExecutor.invoke({
input: "Add label 'Label_906366639289765258' to all these emails: ${"+emailResult.output+"}"
});

const addReceipt = await agentExecutor.invoke({
input: "Add label 'Label_3863516074469975887' to any email which is an Invoice / Bill / Receipt: ${"+emailResult.output+"}"
});

const markRead = await agentExecutor.invoke({
input: "Remove label 'UNREAD' to all these emails: ${"+emailResult.output+"}"
});

console.log("addLabel:", addLabel.output)
console.log("receipts:", addReceipt.output)
console.log("Read:", markRead.output)
22 Replies
xenial-black
xenial-blackOPβ€’6mo ago
Above is code snippet and this gives me the result:
xenial-black
xenial-blackOPβ€’6mo ago
No description
xenial-black
xenial-blackOPβ€’6mo ago
But when i check its still unread πŸ€”
constant-blue
constant-blueβ€’6mo ago
Hey @Em, are you still getting this issue?? If yes could you share me what prompt you gave?? Also as you are using specific actions you need to use getActions(), like:
const tools = await toolset.getActions({ actions: ["GMAIL_FETCH_EMAILS", "GMAIL_ADD_LABEL_TO_EMAIL"]}); // getTools() is used for adding whole app (or list of) as a tool
const tools = await toolset.getActions({ actions: ["GMAIL_FETCH_EMAILS", "GMAIL_ADD_LABEL_TO_EMAIL"]}); // getTools() is used for adding whole app (or list of) as a tool
xenial-black
xenial-blackOPβ€’6mo ago
It’s in the code above. See the remove unread part for the prompt. And yes I have the add label in there it’s able to add but haven’t been able to remove labels But the gpt says that it did remove it so it must be hallucinating or something Sorry on phone atm
constant-blue
constant-blueβ€’6mo ago
What model are you using?? No issues, whenever you are with you laptop just ping me, if I am there will help you out for sure πŸ˜„
xenial-black
xenial-blackOPβ€’6mo ago
3.5 turbo
constant-blue
constant-blueβ€’6mo ago
Okay, it is recommended to use gpt-4-turbo or gpt-4o as many times gpt-3.5-turbo can't even send request to composio. Try to change your model and let me know πŸ™Œ
xenial-black
xenial-blackOPβ€’6mo ago
But all the other requests seem to work.
constant-blue
constant-blueβ€’6mo ago
Yea but when you are working with tools, it is not recommended
xenial-black
xenial-blackOPβ€’6mo ago
Hm i tried making a seperate smarter AI https://hastebin.skyra.pw/nusiwecadi.php code is there
xenial-black
xenial-blackOPβ€’6mo ago
No description
xenial-black
xenial-blackOPβ€’6mo ago
but now i get this weird error
correct-apricot
correct-apricotβ€’6mo ago
Hey @Em - There's no action to remove the label in Gmail tool as of now but we'll priortize this and get a action live for this by Wednesday EOD.
xenial-black
xenial-blackOPβ€’6mo ago
oh sweet thanks @Karthikeya
I'm drowning in emails, i really need AI to start clearing them out for me πŸ˜‚ another question. Is it possible to make the agent output to be a JSON? The OpenAI API has that abillity. But i was wondering if i can do an action and ask the output to to be only a json so that i can then handle formatting myself for messages
constant-blue
constant-blueβ€’6mo ago
Yes that would be better and also you can create a json parsing function which will get json from the output even if there is some sort of text with json like:
` ` `
<json>
` ` `
` ` `
<json>
` ` `
or
Hey this is your json...:
<json>
Hey this is your json...:
<json>
Lemme know if you need that function, I have one πŸ˜„ @Em
xenial-black
xenial-blackOPβ€’6mo ago
I’d love to have it πŸ™ƒ
constant-blue
constant-blueβ€’6mo ago
You wished I delivered 🫑
import json
import typing as t

def parse_json_garbage(s: str) -> t.Dict[str, t.Any]:
"""
This function converts string containing json to a json object.

@param s: str - The string to parse.
@return: t.Dict[str, t.Any] - The parsed json garbage.
"""
s = s[next(idx for idx, c in enumerate(s) if c in "{["):]
try:
return json.loads(s)
except json.JSONDecodeError as e:
return json.loads(s[:e.pos])
import json
import typing as t

def parse_json_garbage(s: str) -> t.Dict[str, t.Any]:
"""
This function converts string containing json to a json object.

@param s: str - The string to parse.
@return: t.Dict[str, t.Any] - The parsed json garbage.
"""
s = s[next(idx for idx, c in enumerate(s) if c in "{["):]
try:
return json.loads(s)
except json.JSONDecodeError as e:
return json.loads(s[:e.pos])
Lemme know if you want any other help in composio πŸ™Œ
xenial-black
xenial-blackOPβ€’6mo ago
Oh that’s Python I’m in JS πŸ˜„
constant-blue
constant-blueβ€’6mo ago
Just convert it πŸ‘€
xenial-black
xenial-blackOPβ€’5mo ago
True haha how is it lookin? πŸ˜„
correct-apricot
correct-apricotβ€’5mo ago
Hey - Checking with the team. Give me few minutes! We're pushing this action into production in next few hours - will let know you here as soon as it is live.

Did you find this page helpful?