Skip to content

Commit 04fe54c

Browse files
committed
exclude emails from intercom responses
1 parent 77b3b80 commit 04fe54c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

app/app.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,26 @@ def handle_webhook():
180180
if is_conversation_human_replied(conversation_id, r):
181181
logger.info(f"Conversation {conversation_id} already marked as human admin-replied; no action taken.")
182182
return 'OK'
183+
184+
# Check if the conversation is of type email
185+
conversation_type = data.get('data', {}).get('item', {}).get('source', {}).get('type')
186+
if conversation_type == 'email':
187+
logger.info(f"Conversation {conversation_id} is of type email; no action taken.")
188+
return 'OK'
189+
183190
# Fetch the conversation and generate an LLM answer for the user
184191
logger.info(f"Detected a user reply in conversation {conversation_id}; fetching an answer from LLM...")
185192
answer_intercom_conversation(app.rag_system, conversation_id)
193+
194+
elif topic == 'conversation.user.created':
195+
# In this case, the webhook event is a new user conversation
196+
# Check if the conversation is of type email
197+
conversation_type = data.get('data', {}).get('item', {}).get('source', {}).get('type')
198+
if conversation_type == 'email':
199+
logger.info(f"New conversation {conversation_id} is of type email; no action taken.")
200+
else:
201+
logger.info(f"New conversation {conversation_id} is not of type email; generating an answer from LLM...")
202+
answer_intercom_conversation(app.rag_system, conversation_id)
186203
else:
187204
logger.info(f"Received webhook for unsupported topic: {topic}; no action taken.")
188205
return 'OK'

0 commit comments

Comments
 (0)