#Using GMAIL_SEND_EMAIL in a CrewAI project

1 messages · Page 1 of 1 (latest)

rich saffron
#

Hello. I'm creating a project that has 2 agents. An email writer that writes personalized emails and an email sender that sends those emails. The email writer outputs JSON and the email sender uses that as input to use in the GMAIL_SEND_EMAIL tool. Sadly, I get this error message: "Error: the Action Input is not a valid key, value dictionary.". I doublechecked the required parameters but it seems to not work.

Output from the email writer agent (i replaced the actual values with <description>. those values are strings):
[
{
'recipient_email': '<email address>',
'subject': '<subject>',
'body': "<content>",
'user_id': 'me',
'is_html': True
},
{
'recipient_email': '<email address>',
'subject': '<subject>',
'body': "<content>",
'user_id': 'me',
'is_html': True
}
]

Do you have a sample input for this tool? How do I fix this issue?

thick heron
#

Can you share your sample code snippet or what LLM model are you using?

rich saffron
#

I'm using OpenAI. Here's a code snippet:
email_writer_task = Task(
description=(
"Create personalized emails based from {document} for each customer in {customers}."
"For each email, create a dictionary with: "
"'recipient_email': recipient email address, "
"'subject': engaging subject line, "
"'body': personalized email body, "
"'user_id': 'me', "
"'is_html': True, "
),
expected_output="A list of dictionaries, each containing email parameters (recipient_email, subject, body, user_id, is_html, attachment)",
agent=email_writer,
output_json=EmailOutput,
verbose=True
)
email_sender_task = Task(
description=(
"For each dictionary in the list provided by the Email Writer, "
"use the GMAIL_SEND_EMAIL tool to send the email with those parameters"
),
expected_output="Send emails for each customer in {customers}",
agent=email_sender,
context=[email_writer_task],
verbose=True
)

#

I have tried doing it manually and it worked fine. I see the logs but all from my manual runs.

thick heron
#

checking.

#

also you are using which llm model?

rich saffron
#

Oh sorry. I use gpt-3.5-turbo

thick heron
#

Can you once try with gpt-4o and see if it works.

rich saffron
#

It returned the same issue. I noticed that this prompt shows up after the run: "* A new version of composio is available, run pip install composio-core==0.5.40 to update.". Should I update composio?

rich saffron
#

Good morning. I realized that there different Framework examples for each tool. I tried using the CrewAI example but it still have the same issue.

Code:
import os
from crewai import Agent, Task, Crew
from langchain_openai import ChatOpenAI
from composio_crewai import ComposioToolSet, Action, App
composio_toolset = ComposioToolSet(api_key="API_KEY")
connected_account = composio_toolset.get_connected_account(id="ACCOUNT_ID")
print(connected_account)
tools = composio_toolset.get_tools(actions=['GMAIL_SEND_EMAIL'], entity_id=connected_account.entityId)

# Define agent
crewai_agent = Agent(
role="Sample Agent",
goal="""You are an AI agent that is responsible for taking actions based on the tools you have""",
backstory=(
"You are AI agent that is responsible for taking actions based on the tools you have"
),
verbose=True,
tools=tools,
llm=ChatOpenAI(),
)
task = Task(
description="Send an email to [email protected] with the subject 'Test Email' and the body 'This is a test email.'. Add in the JSON input 'user_id': 'me'",
agent=crewai_agent,
expected_output="Send email using the GMAIL_SEND_EMAIL tool"
)
my_crew = Crew(agents=[crewai_agent], tasks=[task])

result = my_crew.kickoff()
print(result)

#

Result:

thick heron
#

Checking right away.

thick heron
#
import os
from crewai import Agent, Task, Crew
from langchain_openai import ChatOpenAI
from composio_crewai import ComposioToolSet, Action, App

composio_toolset = ComposioToolSet()
# connected_account = composio_toolset.get_connected_account(id="ACCOUNT_ID")
# print(connected_account)

tools = composio_toolset.get_tools(
    actions=[Action.GMAIL_SEND_EMAIL]
)

# Define agent
crewai_agent = Agent(
    role="Sample Agent",
    goal="""You are an AI agent that is responsible for taking actions based on the tools you have""",
    backstory=(
        "You are AI agent that is responsible for taking actions based on the tools you have"
    ),
    verbose=True,
    tools=tools,
    llm=ChatOpenAI(),
)
task = Task(
    description="Send an email to [email protected] with the subject 'Test Email' and the body 'This is a test email.'. Add in the JSON input 'user_id': 'me'",
    agent=crewai_agent,
    tools=tools,
    expected_output="Send email using the GMAIL_SEND_EMAIL tool",
)
my_crew = Crew(agents=[crewai_agent], tasks=[task])
result = my_crew.kickoff()
print(result)

This worked for me. I used openai GPT-4o