Skip to content

Commit b935ae2

Browse files
committed
Auto-trigger ReplyAgent after EmailAgent finds customer inquiries
1 parent 535a87f commit b935ae2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/bro/reasoner/openai_generic.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,24 @@ def _process(self, item: dict[str, Any]) -> tuple[
10321032
if self._email_agent:
10331033
_logger.info("Running EmailAgent...")
10341034
result = self._email_agent.run()
1035+
1036+
# Auto-trigger ReplyAgent for customer inquiries
1037+
if self._reply_agent and result:
1038+
# Extract customer names from the result for reply agent
1039+
import re
1040+
1041+
customer_matches = re.findall(r"^Customer:\s*(.+)$", result, re.MULTILINE)
1042+
if customer_matches:
1043+
_logger.info(
1044+
f"Found {len(customer_matches)} customer inquiries, auto-triggering ReplyAgent"
1045+
)
1046+
for customer in customer_matches:
1047+
try:
1048+
_logger.info(f"Running ReplyAgent for: {customer}")
1049+
reply_result = self._reply_agent.run(customer)
1050+
_logger.info(f"ReplyAgent result: {reply_result}")
1051+
except Exception as e:
1052+
_logger.error(f"ReplyAgent failed for {customer}: {e}")
10351053
else:
10361054
result = "EmailAgent not available. Google Workspace client is required."
10371055

0 commit comments

Comments
 (0)