Skip to main content
Lola Send uses a Gemini-powered pipeline to transform raw AI text responses into structured, channel-appropriate messages. Agents produce text; the enhancer formats that text into interactive WhatsApp components — buttons, selection lists, links — and applies emoji context for the target channel.

Pipeline stages

The message enhancer runs a two-stage pipeline on every complete agent response:
1

Language detection

Gemini identifies the conversation language from the raw response text, returning an ISO 2-letter code (e.g., es, en, pt). The detected language is used to enforce linguistic consistency in the formatted output.If language detection fails, the enhancer defaults to Spanish (es).
2

Structured formatting

The raw text is converted into a structured JSON object matching one of four component types. Gemini evaluates the content and selects the appropriate format:
TypeWhen usedKey fields
textStandard messages, phone number requestscontent
buttons1–3 discrete choicescontent, options
select4–10 options (lists up to 10 in options; >10 listed in content)content, options, list_title, button
linkMessages containing URLs for external actionscontent, links (array of text + url)
The enhancer enforces the detected language across all output fields — content, options, list_title, button, and link text.

Output constraints

The enhancer enforces WhatsApp Business API field limits:
FieldMaximum length
content1,024 characters
list_title24 characters
options (each)20 characters
button20 characters
Link text20 characters
If any field exceeds its limit, Gemini summarizes the content to fit within the constraint. Options and button labels do not include emojis.

WhatsApp-specific formatting

The enhancer applies contextual emoji hints for financial operations:
ContextEmoji
Cash pickup💸
Bank account🏦
Card payment💳
Bold text is converted from markdown double-asterisk (**) to WhatsApp single-asterisk (*) format. Newlines are stripped from the structured output.

Model configuration

SettingValue
ModelGemini 2.5 Flash Lite
ProviderGoogle Cloud Vertex AI
Temperature1
Top-p0
StreamingDisabled
Only full messagesTrue
The message enhancer runs on Gemini 2.5 Flash Lite via Google Cloud Vertex AI. Vertex AI supports VPC Service Controls, which allows all inference traffic to remain within the bank’s GCP perimeter — conversation data sent for enhancement never leaves the controlled network boundary. The only_full_messages=True setting ensures enhancement runs only on complete responses, not on streaming fragments. This guarantees the enhancer has the full message context before selecting a component type.
Gemini on Vertex AI operates under Google Cloud’s enterprise data processing terms: zero data retention, no model training on customer data, and full compliance with VPC Service Controls for network isolation.

Fallback behavior

If the enhancer fails for any reason — model error, invalid JSON output, parsing failure — the response falls back to a plain OutgoingTextMessage with the original text. No message is lost.
except Exception as e:
    return OutgoingTextMessage(
        lead=lead,
        content=text
    )
The message enhancer operates independently of agent logic. Agents produce text responses; the enhancer formats them for the target channel. Changes to formatting do not require modifications to agent prompts or tool functions.

Security considerations

  • No data generation: The enhancer reformats existing text — it does not generate new content, invoke tool functions, or access backend services.
  • Language enforcement: The two-stage pipeline detects and enforces the conversation language, preventing mixed-language responses that could confuse senders.
  • Deterministic output: Temperature and top-p settings are configured for consistent, structured output rather than creative variation.

Configuration and control

ControlDescription
Model selectionThe Gemini model can be changed without affecting agent logic
Output schemaThe structured JSON schema defines available component types
Full message modeonly_full_messages controls whether partial messages are enhanced
FallbackPlain text fallback ensures no messages are lost on enhancer failure