Skip to content

Bug Report: AgentMail API Usage Error in Sales Agent Example #4

@fazmain

Description

@fazmain

Summary

The sales-agent example fails when attempting to reply to emails due to incorrect AgentMail client API usage. The code tries to access client.messages.reply() but this method doesn't exist on the AgentMail object.

Error

AttributeError: 'AgentMail' object has no attribute 'messages'

Full traceback:

Exception in thread Thread-14 (process_webhook):
File "/Users/faiaz/Desktop/MHacks/Test/agentmail-examples/sales-agent/main.py", line 69, in process_webhook
client.messages.reply(inbox_id=inbox, message_id=email["message_id"], text=response.final_output)
^^^^^^^^^^^^^^^
AttributeError: 'AgentMail' object has no attribute 'messages'

Reproduction Steps

  1. Follow the sales-agent README setup instructions
  2. Configure environment variables and create inbox/webhook
  3. Send an email to your-inbox-username@agentmail.to
  4. Webhook receives the email and processes it
  5. Code crashes when trying to reply

Expected vs Actual Behavior

  • Expected: AgentMail client should allow replying to emails via client.messages.reply()
  • Actual: AgentMail object has no messages attribute

Root Cause Analysis

Looking at the code in main.py:69, there's a discrepancy between the example code and the actual AgentMail client API:

Current (broken) code:

client.messages.reply(inbox_id=inbox, message_id=email["message_id"], text=response.final_output)

Likely correct API (based on line 20):

client.inboxes.messages.reply(inbox_id=inbox, message_id=email["message_id"], text=response.final_output)

Notice that line 20 shows client = AgentMail() and the working inbox creation uses client.inboxes.messages.reply() pattern.

Impact

  • Severity: High - Breaks core functionality
  • Scope: Sales-agent example is completely non-functional
  • User Experience: Users cannot complete the tutorial

Proposed Fix

Update line 69 in main.py from:

client.messages.reply(inbox_id=inbox, message_id=email["message_id"], text=response.final_output)

To:

client.inboxes.messages.reply(inbox_id=inbox, message_id=email["message_id"], text=response.final_output)

Environment

  • AgentMail Version: 0.0.60
  • Python: 3.12
  • OS: macOS
  • File: agentmail-examples/sales-agent/main.py:69

Additional Notes

This appears to be a simple API usage error where the example code is missing the .inboxes part of the method chain. The fix should be straightforward, but it needs verification against the current AgentMail API documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions