[31388f42] Implement end-to-end email ingest for Tradingtwins leads via MS Graph API
This commit is contained in:
@@ -28,6 +28,40 @@ def parse_tradingtwins_email(body):
|
||||
data['raw_body'] = body
|
||||
return data
|
||||
|
||||
def parse_roboplanet_form(body):
|
||||
"""
|
||||
Parses the Roboplanet website contact form (HTML format).
|
||||
Example: <b>Vorname:</b> BÄKO <br><b>Nachname:</b> eG <br><b>Email:</b> Alexander.Grau@baeko-hr.de ...
|
||||
"""
|
||||
data = {}
|
||||
|
||||
# Helper to strip HTML tags if needed, but we'll use regex on the content
|
||||
patterns = {
|
||||
'contact_first': r'Vorname:</b>\s*(.*?)\s*<br>',
|
||||
'contact_last': r'Nachname:</b>\s*(.*?)\s*<br>',
|
||||
'email': r'Email:</b>\s*(.*?)\s*<br>',
|
||||
'phone': r'Telefon:</b>\s*(.*?)\s*<br>',
|
||||
'company': r'Firma:</b>\s*(.*?)\s*<br>',
|
||||
'zip': r'PLZ:</b>\s*(.*?)\s*<br>',
|
||||
'message': r'Nachricht:</b>\s*(.*?)\s*(?:<br>|--|$)'
|
||||
}
|
||||
|
||||
for key, pattern in patterns.items():
|
||||
# Use re.DOTALL for message if it spans lines, but usually it's one block
|
||||
match = re.search(pattern, body, re.IGNORECASE | re.DOTALL)
|
||||
if match:
|
||||
# Clean HTML tags from the captured value if any
|
||||
val = re.sub(r'<.*?>', '', match.group(1)).strip()
|
||||
data[key] = val
|
||||
|
||||
# Combine names
|
||||
if 'contact_first' in data and 'contact_last' in data:
|
||||
data['contact'] = f"{data['contact_first']} {data['contact_last']}"
|
||||
|
||||
# For Roboplanet forms, we use the timestamp as ID or a hash if missing
|
||||
data['raw_body'] = body
|
||||
return data
|
||||
|
||||
def ingest_mock_leads():
|
||||
# Mock data from the session context
|
||||
leads = [
|
||||
|
||||
Reference in New Issue
Block a user