How can I ensure an agent sends a response when triggered by email

Hi,

My agent is properly looking up information with my tool(s) but I want it to Reply to Email if it was triggered by email but it never works, below is my instruction:

You are a helpful Property Management assistant chatting with {{ current_user.firstName }} {{ current_user.lastName }} OR you've been triggered by email:
From: {emailData.from}
Cc: {emailData.Cc} (if present)
To: {other recipients} (if present, excluding the agent email)
Subject: {emailData.subject}

You're designed to interact with Triovest's database and API data endpoints. You have access to a set of tools that allows you to:

  • Generate information summaries and answers using Triovest's endpoints.
  • Retrieve information about Property/Tenants/Spaces/Units/Vendors.
  • Send emails with HTML or Markdown content.

Your goals:

  • Help the user by answering their question using the data from the endpoints.
  • Ask clarifying questions if required parameters are missing.
  • Format tool input in the exact schema expected by each tool.
  • Avoid hallucinating endpoints, fields, or behaviours not explicitly described in the tools.

Best Practices:

  • Confirm user intent: If the user's request is ambigious, ask follow-up questions before running tools
  • Chain tools when needed: For example, after retrieving data from an endpoint you can continue using tools like "Reply to Email" to reply back to the user.
  • Keep endpoint constraints in mind (e.g., date ranges, allowed fields)

This agent can be triggered via email. If you've been triggered by email then you must respond back in email with the "Reply to Email" tool, you'll know you've been triggered by email if {emailData.from} has values. When triggered by email:

  1. The agent will receive the email content and sender information
  2. The agent may also receive prior messages in the chain.
  3. The agent should use all of the available context to devise a response.
  4. The agent uses the "Reply to Email" tool to send a response with the answer everytime, no exceptions.

Is there a way to consistently get it to reply to email? Attached is my screenshot of (at the bottom) where it calls the right tool to retrieve information but ends without using the Reply to Email tool

Hey @metechnologies! Thanks for reaching out. I will look into this as soon as I get a chance, but wanted to let you know that I broke your post out into a separate topic. :+1:

1 Like

@metechnologies what model are you using?

gpt-4o-mini, do I have to use a specific type of model?

No, not necessarily, but certain models are better at following instructions than others. I just tested your instructions with both 4.1 and 4o-mini (with mocked tools) and it emailed back in both cases.

Can you confirm that your agent still has the "reply to email" tool?

Yes here is my agent's screenshot, I simplified it from scratch and only added the Get Webpage Content

It won't use the email tool

Having issues even with the bare minimal configuration, just clicked on +Email and it still won't work:

Hmm! I just created a new agent, configured nothing except the model, and enabled email, and it works as expected.

May I ask what you're sending in the email, and perhaps to try the same repro agent I have here?

Your example works for me if there are no other tools except "Reply to Email". In my agent when I have multiple tools and the request is asking for it to send an email. It will use the other tools and never use the Email tools. It will even reply back that it did send an email but not actually follow through with the email tool use.

Can you test adding more tools like web search and have it Search and then send an email with the search results?

@metechnologies I added web search, made no other changes to my agent, and here's how it works:

I'm wondering if your issue is due to the unpredictability of LLMs or if there's an actual bug here. Might ask @Darren to step in to track down the bug, but as a final test, would you mind creating the exact same agent and giving it the exact same input via email?

Hi,

Agent Config Screenshot:

Here is my thread:

It was able to provide the summary in my chat but how do I just get it to just send the email without asking me about sending?

Just to double check, have you modified any of the Advanced settings? Either the temperature or max iterations? Like Kent, the agents I spin up are consistently able to follow my instructions and send a summary email after a sequence of other tool invocations. This is true whether I trigger the agent via chat or email. :thinking:

If you're still having issues this, would you be able to join Office Hours tomorrow? It might beneficial to take closer look at this together.

try:

# Instructions
- After understanding everything below here and comprehending everything sent to you, follow the 'Steps' section to respond.
- You are a helpful assistant who might be triggered by email. 

# Context
- User:
{{ current_user }}

- Date:
{{ new Date() }}

# Steps
1) Check if you were sent any prior messages in the conversation.  
2) Form a response
3) If you were also sent email content and sender information then use the 'Reply to Email' tool to send your response to everyone who was in the 'Cc' or 'To' parameter of the most recently sent email, otherwise respond as you normally would

# Important
- Always use the 'Context' section and any message history received when forming a response.
- Never Cc anyone who was not on the most recent email.

You might want to try re-naming 'Reply To Email' to 'Send Email' also. It might think 'Reply To Email' means special instructions on forming the response content, not actually sending the email.

after re-reading your prompt, the problem might actually be the phrase 'should use' in your step #4 and 'should NOT' in step #6.

technically, 'should' doesn't mean it has to.... maybe try 'will always' for #4 and 'will never' for #6

Thanks for the help but it's still not sending the email after the first tool.

It performed the Search Web tool and then just summarized:

I've tried on gpt 4.1 and gpt 4.1 mini and both are not completing the email step, here is a thread with bobthebear's instruction:

My temp and iterations are default I believe:
image

I'm happy to jump on a call / drop in to show.

Very bizarre - it would be great to see you in Office Hours next week!

just curious if you tried renaming the function to 'Send Email' instead of 'Reply to Email'? At this point i doubt it would make a difference... but I did notice it replied with "I will now send you an email" and not something like "I will now reply to your email", "I will now send a reply email" or something similar. Which makes me wonder if it's having a problem associating the task it wants to do with the function name (especially if you don't have a description for the function). Maybe you could try adding something like "Always use 'Reply to Email' to send an email", "Always include the name of any functions or tools used and if it was successful at the end of your response", "Always inform the user if you do not have access to the proper function or tool you need to complete their request" or maybe "Always track debug information for tool/function use and include it in your response".... I'd put these at the bottom under the Important section (things placed here with the important tag at the bottom tend to be followed more strictly than if it was near the top and/or if it didn't have the 'important' tag [I'll see if I can find the article with this and other tips and update here])

Slight side note, hope you don't mind, do yall have any research/data or insights into temperature within the context of Retool Agents and why, or what lead to, the default of 0.3... I mean.... if you can share that stuff :innocent: