Saltar a contenido

Rendered notebook

Generated from 05_multilang_chat.ipynb. Run it yourself with make docs-up — see Run locally.

05 — Multi-language customer messages

Globaltrust customers receive notifications in their preferred language. This notebook simulates a small router that picks the right template per language.

In the real bank, message generation is handled by an apogee-ai agent with a Jinja-style template fallback for deterministic copy.

05_multilang_chat.ipynb · cell 1
TEMPLATES = {
    'transfer.confirmed': {
        'en': 'Your transfer of {amount} to {recipient} was confirmed. Reference: {ref}.',
        'pt': 'Sua transferência de {amount} para {recipient} foi confirmada. Referência: {ref}.',
        'es': 'Tu transferencia de {amount} a {recipient} fue confirmada. Referencia: {ref}.',
        'zh': '您向 {recipient} 转账 {amount} 已确认。参考号:{ref}。',
    },
    'kyc.expiring': {
        'en': 'Your KYC documents will expire in {days} days. Please re-submit them in your customer portal.',
        'pt': 'Seus documentos KYC expiram em {days} dias. Reenvie-os no portal do cliente.',
        'es': 'Tus documentos KYC vencen en {days} días. Por favor reenvíalos en el portal.',
        'zh': '您的 KYC 文件将在 {days} 天后过期。请在客户门户重新提交。',
    },
}

def render(event: str, lang: str, **kwargs) -> str:
    tmpl = TEMPLATES[event].get(lang, TEMPLATES[event]['en'])
    return tmpl.format(**kwargs)
05_multilang_chat.ipynb · cell 2
customers = [
    {'name': 'Alice Müller',   'lang': 'en'},
    {'name': 'Carlos da Silva', 'lang': 'pt'},
    {'name': 'María García',    'lang': 'es'},
    {'name': '李明',             'lang': 'zh'},
]
for c in customers:
    msg = render(
        'transfer.confirmed', c['lang'],
        amount='€2,500.00', recipient='Banco do Brasil', ref='TX-7782',
    )
    print(f"[{c['lang']}] {c['name']:<20}{msg}")
05_multilang_chat.ipynb · cell 3
for c in customers:
    print(f"[{c['lang']}] ", render('kyc.expiring', c['lang'], days=14))

Hooking up an LLM

When a template doesn't exist (one-off messages, replies to support tickets), the bank falls back to apogee-ai's AgentBuilder with an instruction like "Reply in {lang}, tone formal, max 80 words.". The apogee-ai-providers layer routes to OpenRouter / Anthropic / Gemini transparently.

Compliance keeps a copy of each generated message in MongoDB via the audit middleware (apogee-auth).