# Patterns

> Workflow shapes that work well in production, with the JSON for each.

Source: https://voxio.in/docs/workflows-patterns · voxioagent 2.0.0 · Index: https://voxio.in/docs/llms.txt

## Fast, natural chat

Listen → **AI reply** → back to Listen. The AI speaks as it writes, so the caller hears the first words soonest. The AI can still end the call by returning `hangup`.

```json
"ask_for_input": { "type": "input", "parameters": { "input_variables": { "user_input": "str" } }, "next": "chat" },
"chat": {
  "type": "llm-streaming",
  "parameters": { "system_prompt": "…", "service": "groq", "model": "openai/gpt-oss-120b", "history_key": "conversation_history" },
  "next": "ask_for_input"
}
```

## Instant acknowledgement

Run a tiny model and the main model side by side. The tiny one says “Sure, one moment” almost at once; the main answer follows. Give each its own `history_key` so they don't mix memories, and a `stream_timeout` on the main one so a very late answer is dropped. The **Quick ack + main LLM** template builds this.

```json
"ask_for_input": { "type": "input", "parameters": { "input_variables": { "user_input": "str" } }, "next": ["ack", "main"] },
"ack":  { "type": "llm-streaming", "parameters": { "model": "openai/gpt-oss-20b",  "history_key": "conversation_history_ack", "system_prompt": "Reply with a two to four word acknowledgement only." } },
"main": { "type": "llm-streaming", "parameters": { "model": "openai/gpt-oss-120b", "history_key": "conversation_history", "stream_timeout": 8, "system_prompt": "…" }, "next": "ask_for_input" }
```

## Decide, then branch

An **AI decision** fills in fields; a **Say** speaks the reply; a **Branch** picks the path from a field.

```json
"decide": {
  "type": "llm",
  "parameters": {
    "system_prompt": "Work out what the caller wants.",
    "llm_return_type": {
      "speak":  { "type": "str", "description": "What to say." },
      "intent": { "type": "str", "description": "book, cancel or other" }
    }
  },
  "next": "say_it"
},
"say_it": { "type": "out", "parameters": { "variables": ["speak"] }, "next": "route" },
"route": {
  "type": "conditional",
  "parameters": {
    "input_variables": { "intent": "str" },
    "mappings": { "book": "booking", "cancel": "cancelling", "default": "ask_for_input" }
  }
}
```

## End the call

Send `hangup: true` with the last line. The line is spoken first, then the call ends:

```json
"goodbye": { "type": "out", "parameters": { "out_dict": { "speak": "Thanks for calling. Goodbye!", "hangup": true } } }
```

To let the AI decide, include `hangup` in its decided fields and pass it on with `"variables": ["speak", "hangup"]`.

## Show what the caller said

A Say step with only `"variables": ["user_input"]`, run beside the AI step, puts the caller's words in the transcript without speaking them back. The templates call it `transcription`.

## Next steps

- [Import, export and code](https://voxio.in/docs/workflows-share.md): reuse a workflow elsewhere.
- [Steps](https://voxio.in/docs/steps.md): every setting of every step.
