I am working with agno`s tool Email Tool. While using this tools I faced 2 challenges
- The tools is not picking Receiver`s Email Dynamically from the user input even after specifying instructions. The receiver email needs to be pass hard coded.
- This tool is currently working with gmail only.
here is my code snippet
agent = Agent(
tools=[
EmailTools(
receiver_email=None,
sender_email=sender_email,
sender_name=sender_name,
sender_passkey=sender_passkey,
)
],
instructions=[
“The user will specify the recipient’s email address, subject, and body in their input.”,
“You Must pass the extracted email address to the EmailTools in receiver_email parameter.”,
“Do NOT Provide any python code or script to accomplish the task.”,
“DO Not Provide any instructions to send email”,
],
model=ollama_model
)
agent.print_response(“”"
Send an email with the following:
- receiver_email: “ANY_EMAIL_ADDRESS for testing purpose”
- Subject: test email
- Body: Hello, this is a test email.
“”", stream=True)
Hey @Rishabh_Garg
thanks for reaching out and supporting Agno. I’ve shared this with the team, we’re working through all requests one by one and will get back to you soon.
If it’s urgent, please let us know. We appreciate your patience!
I was brainstorming it and found a solution for it which is working for me. But if someone has better solution they can also provide their answers
def send_email_to_recipient(receiver_email: str, subject: str, body: str) → str:
“”“Function to send email using EmailTools with dynamic receiver”“”
if not receiver_email:
return “Error: Please provide a valid email address for the receiver.”
try:
# Create EmailTools instance with the provided receiver email
email_tool = EmailTools(
receiver_email=receiver_email,
sender_email=sender_email,
sender_name=sender_name,
sender_passkey=sender_passkey,
)
result = email_tool.email_user(subject=subject, body=body)
return f"Email sent successfully to {receiver_email} with subject: {subject}"
except Exception as e:
return f"Failed to send email to {receiver_email}: {str(e)}"
agent = Agent(
tools=[send_email_to_recipient],
instructions=[
“When the user asks to send an email, extract the receiver_email, subject, and body from their message.”,
“Call the send_email_to_recipient function with these three parameters.”,
“The receiver_email should be the email address specified by the user.”,
“Do NOT provide any python code or script.”,
“Do NOT provide any instructions to send email.”,
“Just call the function with the extracted parameters.”,
],
model=ollama_model
)
agent.print_response(“”"
Send an email with the following:
- receiver_email: “ANY_EMAIL_ADDRESS for testing purpose”
- Subject: test email
- Body: Hello, this is a test email.
“”", stream=True)
Hi @Rishabh_Garg ,You are right here , creating you own custom tool is the way to go here . Custom Tools - Agno