continuing-cyan
continuing-cyan4mo ago

Using GMAIL_SEND_EMAIL in a CrewAI project

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?
11 Replies
Soham
Soham4mo ago
Can you share your sample code snippet or what LLM model are you using? https://app.composio.dev/app/gmail can you click send email action and try doing it manually once and share if it worked? Also can you see any logs here? https://app.composio.dev/logs?status=all&page=1&time=1w
continuing-cyan
continuing-cyanOP4mo ago
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 )
continuing-cyan
continuing-cyanOP4mo ago
I have tried doing it manually and it worked fine. I see the logs but all from my manual runs.
No description
No description
No description
Soham
Soham4mo ago
checking. also you are using which llm model?
continuing-cyan
continuing-cyanOP4mo ago
Oh sorry. I use gpt-3.5-turbo
Soham
Soham4mo ago
Can you once try with gpt-4o and see if it works.
continuing-cyan
continuing-cyanOP4mo ago
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?
No description
No description
continuing-cyan
continuing-cyanOP4mo ago
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 naynesmikel@gmail.com 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)
continuing-cyan
continuing-cyanOP4mo ago
Result:
No description
Soham
Soham4mo ago
Checking right away.
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 soham@composio.dev 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)
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 soham@composio.dev 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
probable-pink
probable-pink4mo ago
Hey @mikeeemik, did your issue got resolved??

Did you find this page helpful?