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:
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).
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:| Type | When used | Key fields |
|---|
text | Standard messages, phone number requests | content |
buttons | 1–3 discrete choices | content, options |
select | 4–10 options (lists up to 10 in options; >10 listed in content) | content, options, list_title, button |
link | Messages containing URLs for external actions | content, 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:
| Field | Maximum length |
|---|
content | 1,024 characters |
list_title | 24 characters |
options (each) | 20 characters |
button | 20 characters |
Link text | 20 characters |
If any field exceeds its limit, Gemini summarizes the content to fit within the constraint. Options and button labels do not include emojis.
The enhancer applies contextual emoji hints for financial operations:
| Context | Emoji |
|---|
| 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
| Setting | Value |
|---|
| Model | Gemini 2.5 Flash Lite |
| Provider | Google Cloud Vertex AI |
| Temperature | 1 |
| Top-p | 0 |
| Streaming | Disabled |
| Only full messages | True |
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
| Control | Description |
|---|
| Model selection | The Gemini model can be changed without affecting agent logic |
| Output schema | The structured JSON schema defines available component types |
| Full message mode | only_full_messages controls whether partial messages are enhanced |
| Fallback | Plain text fallback ensures no messages are lost on enhancer failure |