docs(email-api): Update email test script with manual sending instructions and link
This commit is contained in:
@@ -56,46 +56,59 @@ def create_email_document(person_id_input: int):
|
||||
return
|
||||
|
||||
# 2. Define Email Content
|
||||
subject = "Test E-Mail from Gemini CLI (API)"
|
||||
body = f"""Hallo {person.get('Firstname')},
|
||||
# Get Email Address from Person
|
||||
email_address = person.get("Emails", [{}])[0].get("Value", "k.A.")
|
||||
|
||||
subject = f"Optimierung Ihrer Service-Prozesse (Referenz: {person.get('Firstname')} {person.get('Lastname')})"
|
||||
|
||||
# We use the UDFs we already found in Person 193036
|
||||
udefs = person.get("UserDefinedFields", {})
|
||||
intro = udefs.get(settings.UDF_INTRO, "Guten Tag,")
|
||||
proof = udefs.get(settings.UDF_SOCIAL_PROOF, "Wir unterstützen Unternehmen bei der Automatisierung.")
|
||||
unsub = udefs.get(settings.UDF_UNSUBSCRIBE_LINK, "")
|
||||
|
||||
body = f"""{intro}
|
||||
|
||||
Dies ist ein Test für die Erstellung eines E-Mail-Dokuments direkt über die SuperOffice API.
|
||||
Wir nutzen das Template 'Ausg. E-Mail' (ID 157).
|
||||
{proof}
|
||||
|
||||
Abmelden: {unsub}
|
||||
|
||||
Viele Grüße,
|
||||
Gemini"""
|
||||
Christian Godelmann
|
||||
RoboPlanet"""
|
||||
|
||||
# 3. Create Document Payload
|
||||
# Note: DocumentTemplateId 157 = "Ausg. E-Mail"
|
||||
template_id = 157
|
||||
|
||||
payload = {
|
||||
"Name": subject, # Internal Name
|
||||
"Header": subject, # Subject Line
|
||||
# "OurRef": {"AssociateId": my_associate_id}, # Omitted, hoping SO uses API User context
|
||||
"Name": f"Outreach: {email_address}", # Internal Name with Email for visibility
|
||||
"Header": subject, # Subject Line
|
||||
"Contact": {"ContactId": contact_id},
|
||||
"Person": {"PersonId": person_id},
|
||||
"DocumentTemplate": {"DocumentTemplateId": template_id},
|
||||
"Content": body
|
||||
}
|
||||
|
||||
print(f"📤 Sending POST /Document payload...")
|
||||
print(f"📤 Creating E-Mail draft for {email_address}...")
|
||||
try:
|
||||
doc = client._post("Document", payload)
|
||||
if doc:
|
||||
doc_id = doc.get('DocumentId')
|
||||
print(f"✅ Document Created Successfully!")
|
||||
print(f" ID: {doc_id}")
|
||||
print(f" Name: {doc.get('Name')}")
|
||||
print(f" Template: {doc.get('DocumentTemplate', {}).get('Name')}")
|
||||
print(f" Recipient: {email_address}")
|
||||
print(f" Subject: {subject}")
|
||||
|
||||
# Construct direct link
|
||||
# Format: https://online3.superoffice.com/Cust26720/default.aspx?document_id=334050
|
||||
env = settings.SO_ENVIRONMENT
|
||||
cust_id = settings.SO_CONTEXT_IDENTIFIER
|
||||
# Note: This is a best-guess link format for SO Online
|
||||
link = f"https://{env}.superoffice.com/{cust_id}/default.aspx?document_id={doc_id}"
|
||||
print(f"🔗 Direct Link: {link}")
|
||||
print(f"\n--- WICHTIG ---")
|
||||
print(f"Das Dokument wurde im Archiv von {contact.get('Name')} angelegt.")
|
||||
print(f"Da der automatisierte Versand via API in diesem Mandanten (500 Error) blockiert ist,")
|
||||
print(f"muss der Versand aktuell MANUELL über diesen Link gestartet werden:")
|
||||
print(f"🔗 {link}")
|
||||
print(f"----------------\n")
|
||||
|
||||
# 4. Create Linked Appointment (Activity)
|
||||
print("📅 Creating Linked Appointment (Email Sent Activity)...")
|
||||
|
||||
Reference in New Issue
Block a user