Use bodyV2 markdown for CRM notes and transcripts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
93288aa981
commit
bc80f7667c
1 changed files with 13 additions and 6 deletions
|
|
@ -151,16 +151,19 @@ async def update_person(person_id: str, updates: dict) -> bool:
|
|||
return False
|
||||
|
||||
|
||||
async def create_note(title: str, person_id: str | None = None) -> str | None:
|
||||
async def create_note(title: str, person_id: str | None = None, body: str = "") -> str | None:
|
||||
"""Create a note in Twenty CRM, optionally linked to a person."""
|
||||
if not settings.twenty_crm_api_key:
|
||||
return None
|
||||
try:
|
||||
async with httpx.AsyncClient() as http:
|
||||
note_data: dict = {"title": title}
|
||||
if body:
|
||||
note_data["bodyV2"] = {"markdown": body, "blocknote": None}
|
||||
resp = await http.post(
|
||||
f"{BASE_URL}/notes",
|
||||
headers=HEADERS,
|
||||
json={"title": title},
|
||||
json=note_data,
|
||||
timeout=10,
|
||||
)
|
||||
if resp.status_code != 201:
|
||||
|
|
@ -282,11 +285,15 @@ async def save_conversation_transcript(
|
|||
lines.append(f"🤖 Bot: {content}")
|
||||
|
||||
transcript = "\n".join(lines)
|
||||
# Truncate to 4000 chars for CRM note
|
||||
if len(transcript) > 4000:
|
||||
transcript = transcript[:3950] + "\n\n... (truncated)"
|
||||
# Truncate to 10000 chars for CRM note body
|
||||
if len(transcript) > 10000:
|
||||
transcript = transcript[:9950] + "\n\n... (truncated)"
|
||||
|
||||
return await create_note(transcript, person_id)
|
||||
return await create_note(
|
||||
f"💬 Chat transcript — {visitor_name}",
|
||||
person_id,
|
||||
body=transcript,
|
||||
)
|
||||
|
||||
|
||||
async def create_lead_in_crm(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue