How can I make one agent to send input i.e email body crafted in research agent sent to another agent. as of now
“my research agent has :At the end summarize the analysis and recommendation in {email_body} and dispatch it to email_agent with {email_body}”
and task looks like
task.yaml
send_email_task:
description: “Task to send an email to {from_email} with {email_body}”
agent: “email_agent”
inputs:
sender_email: “sendder”
sender_password: “pass”
recipient_email: “email”
subject: “Log updates”
body: {email_body}
agent.yaml
email_agent:
role: “Log Sentinels”
goal: “An agent to send automated emails.”
backstory:
agent max_retries is set to 1 with timeout of 60 sec
I am getting following error
pydantic_core._pydantic_core.ValidationError: 3 validation errors for Agent
role
Field required [type=missing, input_value={‘verbose’: True}, input_type=dict]
For further information visit Redirecting...
goal
Field required [type=missing, input_value={‘verbose’: True}, input_type=dict]
For further information visit Redirecting...
backstory
Field required [type=missing, input_value={‘verbose’: True}, input_type=dict]
from crewai.tools import BaseTool
from typing import Type
from pydantic import BaseModel, Field,ConfigDict
from langchain_community.agent_toolkits import GmailToolkit
from langchain_community.tools.gmail.create_draft import GmailCreateDraft
from langchain_community.tools.gmail.send_message import GmailSendMessage'
class CreateDraftTool(BaseTool):
name: str = "Email Tool"
description: str = (
"""
Useful to create an email draft and send it too.
The input to this tool should be a pipe (|) separated text
of length 3 (three), representing who to send the email to,
the subject of the email and the actual message.
For example, "lorem@ipsum.com|Nice To Meet You|Hey it was great to meet you.".
and also send the email
"""
)
model_config = ConfigDict(arbitrary_types_allowed=True)
def _run(self,argument:str) -> str:
email, subject, message = argument.split("|")
gmail = GmailToolkit()
draft = GmailCreateDraft(api_resource=gmail.api_resource)
draft2 = GmailSendMessage(api_resource=gmail.api_resource)
result = draft({"to": [email], "subject": subject, "message": message})
result2 = draft2({"to": [email], "subject": subject, "message": message})
return f"\nDraft created: {result}\n Email Sent {result2}"
Go to your .env file and add MY_EMAIL = name.example@gmail.com
Set Up Google Credentials
1.Set Up Google Account: Follow the Google instructions to set up your Google account and obtain the credentials.json file.
2. Download and Place credentials.json: Once you’ve downloaded the file, name it credentials.json and place it in the root of the project.
In your crew.yaml go to the agent which is doing this task of sending emails and call the tool as follows tools = [CreateDraftTool()]
Please make sure you are using the latest crewai version and then if you are try using a decorators which goes @tool pretty similar to what is used to define agent and tasks like @agents and @task respectively.
But it would be really helpful if you could give me more context of what you are trying to do
Feel free to reach me out at sannidhay2004@gmail.com if you don’t feel comfortable sharing your idea and your work in a public forum like this