# crewaiinc/template_conversational_example architecture

> Architecture diagram of the GitHub repository crewaiinc/template_conversational_example, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/crewaiinc/template_conversational_example
- Repository: https://github.com/crewaiinc/template_conversational_example

## Overview

#### Purpose and Entry Points
This repository demonstrates a persistent CrewAI conversational-routing crew intended for CrewAI Enterprise deployment. Primary local entry points are terminal chat in `terminal_chat.py`, flow execution in `src/conversational_routing/main.py`, and a Streamlit polling client in `demo_streamlit_poll/streamlit_app.py`. Separate Slack and webhook integrations are deployable examples rather than dependencies of the core crew.

#### Crew Flow and Conversation State
The central flow receives `current_message` and optionally a conversation `id`, then routes the message to a single assistant crew. CrewAI flow persistence retains history keyed by the returned conversation ID, allowing subsequent kickoff requests to continue the same session. Core flow package paths are `src/conversational_routing/main.py` and `src/conversational_routing/__init__.py`.

#### Assistant Crew Definition
The assistant behavior is defined as a CrewAI crew with agent/task configuration rather than application-layer routing code. The crew implementation is at `src/conversational_routing/crews/assistant_crew/assistant_crew.py`; its declarative agent and task contracts reside in `src/conversational_routing/crews/assistant_crew/config/agents.yaml` and `src/conversational_routing/crews/assistant_crew/config/tasks.yaml`. This is the principal boundary for changing prompts, responsibilities, and response structure.

#### Model Provider Boundary
LLM provider selection is isolated behind model modules, enabling the crew to use OpenAI, Google Gemini, or Vertex-backed configurations without placing provider logic in the UI/integration clients. Relevant paths are `src/conversational_routing/models/openai.py`, `src/conversational_routing/models/gemini.py`, and `src/conversational_routing/models/vertex.py`. Provider credentials and runtime settings are environment-supplied, with example variables in `.env.sample`.

#### Enterprise API Interaction
When deployed to CrewAI Enterprise, clients initiate work through `/kickoff`, receive a kickoff ID, and poll `/status/{kickoff_id}` until completion. The completed result contains the assistant response plus the persistent conversation ID to use on later messages. Thus, Enterprise is both the asynchronous execution boundary and the stateful conversation-access boundary; local clients should not assume synchronous crew completion.

#### User-Facing and Integration Clients
`demo_streamlit_poll/streamlit_app.py` is the interactive client for the Enterprise kickoff/status polling lifecycle. `terminal_chat.py` provides a local terminal interaction path, and `test_chat.py` exercises consecutive-message behavior. Additional adapters expose the same conversational capability to external channels: Slack via `demo_slackbot/app.py` and HTTP/webhook hosting via `demo_webhooks/app.py`. The webhook demo includes a simple browser surface at `demo_webhooks/templates/index.html`.

#### Runtime and Deployment
The Python project/dependency definition is `pyproject.toml`, with locked resolution in `uv.lock`. The Slack and webhook demos include Procfiles (`demo_slackbot/Procfile`, `demo_webhooks/Procfile`) and requirements files for independently hosted processes. The knowledge artifact `knowledge/freedom_benefits.pdf` is repository content available for crew-oriented knowledge use, though its ingestion behavior is defined by the crew/runtime configuration rather than the clients.

Main entry points: [`src/conversational_routing/crews/assistant_crew/assistant_crew.py`](https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/crews/assistant_crew/assistant_crew.py) (Assistant crew), [`src/conversational_routing/main.py`](https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/main.py) (Persistent conversation flow), [`demo_webhooks/app.py`](https://github.com/crewaiinc/template_conversational_example/blob/main/demo_webhooks/app.py) (Webhook adapter), [`demo_streamlit_poll/streamlit_app.py`](https://github.com/crewaiinc/template_conversational_example/blob/main/demo_streamlit_poll/streamlit_app.py) (Polling chat client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Conversation Core"]
  node_flow["Persistent conversation flow<br/>CrewAI Flow<br/>[main.py]"]
  node_flow_package["Flow package<br/>Python package<br/>[__init__.py]"]
  node_assistant_crew["Assistant crew<br/>CrewAI crew<br/>[assistant_crew.py]"]
  node_agents_config["Agent contracts<br/>YAML config<br/>[agents.yaml]"]
  node_tasks_config["Task contracts<br/>YAML config<br/>[tasks.yaml]"]
  node_knowledge["Benefits knowledge<br/>Knowledge artifact"]
end

subgraph group_providers["Model Providers"]
  node_openai["OpenAI model<br/>Model adapter<br/>[openai.py]"]
  node_gemini["Gemini model<br/>Model adapter<br/>[gemini.py]"]
  node_vertex["Vertex model<br/>Model adapter<br/>[vertex.py]"]
end

subgraph group_enterprise["Enterprise Runtime"]
  node_enterprise_api{{"CrewAI Enterprise API<br/>Async execution API"}}
  node_conversation_state[("Conversation history<br/>Persistent state")]
end

subgraph group_clients["Clients and Adapters"]
  node_streamlit["Polling chat client<br/>Streamlit app<br/>[streamlit_app.py]"]
  node_terminal["Terminal chat<br/>CLI client<br/>[terminal_chat.py]"]
  node_slack["Slack adapter<br/>Channel adapter<br/>[app.py]"]
  node_webhook["Webhook adapter<br/>HTTP app<br/>[app.py]"]
  node_web_surface["Webhook browser surface<br/>HTML page<br/>[index.html]"]
end

node_streamlit -->|"POST /kickoff; poll /status"| node_enterprise_api
node_slack -->|"initiates conversations"| node_enterprise_api
node_webhook -->|"initiates conversations"| node_enterprise_api
node_web_surface -->|"browser interface"| node_webhook
node_enterprise_api -->|"runs kickoff"| node_flow
node_enterprise_api -->|"stores and returns ID"| node_conversation_state
node_flow -->|"routes each message"| node_assistant_crew
node_flow -.->|"package entry"| node_flow_package
node_terminal -->|"local interaction"| node_flow
node_assistant_crew -->|"loads agents"| node_agents_config
node_assistant_crew -->|"loads tasks"| node_tasks_config
node_assistant_crew -.->|"uses knowledge"| node_knowledge
node_assistant_crew -.->|"selects provider"| node_openai
node_assistant_crew -.->|"selects provider"| node_gemini
node_assistant_crew -.->|"selects provider"| node_vertex

click node_flow "https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/main.py"
click node_flow_package "https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/__init__.py"
click node_assistant_crew "https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/crews/assistant_crew/assistant_crew.py"
click node_agents_config "https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/crews/assistant_crew/config/agents.yaml"
click node_tasks_config "https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/crews/assistant_crew/config/tasks.yaml"
click node_knowledge "https://github.com/crewaiinc/template_conversational_example/blob/main/knowledge/freedom_benefits.pdf"
click node_openai "https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/models/openai.py"
click node_gemini "https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/models/gemini.py"
click node_vertex "https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/models/vertex.py"
click node_streamlit "https://github.com/crewaiinc/template_conversational_example/blob/main/demo_streamlit_poll/streamlit_app.py"
click node_terminal "https://github.com/crewaiinc/template_conversational_example/blob/main/terminal_chat.py"
click node_slack "https://github.com/crewaiinc/template_conversational_example/blob/main/demo_slackbot/app.py"
click node_webhook "https://github.com/crewaiinc/template_conversational_example/blob/main/demo_webhooks/app.py"
click node_web_surface "https://github.com/crewaiinc/template_conversational_example/blob/main/demo_webhooks/templates/index.html"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_flow,node_flow_package,node_assistant_crew,node_agents_config,node_tasks_config,node_knowledge toneBlue
class node_openai,node_gemini,node_vertex toneAmber
class node_enterprise_api,node_conversation_state toneMint
class node_streamlit,node_terminal,node_slack,node_webhook,node_web_surface toneRose
```

## Components

### Conversation Core

- [Persistent conversation flow](https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/main.py): CrewAI Flow · Accepts a message and optional conversation ID. · `src/conversational_routing/main.py`
- [Flow package](https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/__init__.py): Python package · `src/conversational_routing/__init__.py`
- [Assistant crew](https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/crews/assistant_crew/assistant_crew.py): CrewAI crew · Single routed assistant execution boundary. · `src/conversational_routing/crews/assistant_crew/assistant_crew.py`
- [Agent contracts](https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/crews/assistant_crew/config/agents.yaml): YAML config · `src/conversational_routing/crews/assistant_crew/config/agents.yaml`
- [Task contracts](https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/crews/assistant_crew/config/tasks.yaml): YAML config · `src/conversational_routing/crews/assistant_crew/config/tasks.yaml`
- [Benefits knowledge](https://github.com/crewaiinc/template_conversational_example/blob/main/knowledge/freedom_benefits.pdf): Knowledge artifact · Crew-oriented source material. · `knowledge/freedom_benefits.pdf`

### Model Providers

- [OpenAI model](https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/models/openai.py): Model adapter · `src/conversational_routing/models/openai.py`
- [Gemini model](https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/models/gemini.py): Model adapter · `src/conversational_routing/models/gemini.py`
- [Vertex model](https://github.com/crewaiinc/template_conversational_example/blob/main/src/conversational_routing/models/vertex.py): Model adapter · `src/conversational_routing/models/vertex.py`

### Enterprise Runtime

- **CrewAI Enterprise API**: Async execution API · Provides kickoff, status polling, and persistent conversation access.
- **Conversation history**: Persistent state · Keyed by the returned conversation ID.

### Clients and Adapters

- [Polling chat client](https://github.com/crewaiinc/template_conversational_example/blob/main/demo_streamlit_poll/streamlit_app.py): Streamlit app · `demo_streamlit_poll/streamlit_app.py`
- [Terminal chat](https://github.com/crewaiinc/template_conversational_example/blob/main/terminal_chat.py): CLI client · `terminal_chat.py`
- [Slack adapter](https://github.com/crewaiinc/template_conversational_example/blob/main/demo_slackbot/app.py): Channel adapter · Independently deployable example. · `demo_slackbot/app.py`
- [Webhook adapter](https://github.com/crewaiinc/template_conversational_example/blob/main/demo_webhooks/app.py): HTTP app · Independently deployable example. · `demo_webhooks/app.py`
- [Webhook browser surface](https://github.com/crewaiinc/template_conversational_example/blob/main/demo_webhooks/templates/index.html): HTML page · `demo_webhooks/templates/index.html`

## Connections

- Polling chat client → CrewAI Enterprise API: POST /kickoff; poll /status
- Slack adapter → CrewAI Enterprise API: initiates conversations
- Webhook adapter → CrewAI Enterprise API: initiates conversations
- Webhook browser surface → Webhook adapter: browser interface
- CrewAI Enterprise API → Persistent conversation flow: runs kickoff
- CrewAI Enterprise API → Conversation history: stores and returns ID
- Persistent conversation flow → Assistant crew: routes each message
- Persistent conversation flow → Flow package: package entry
- Terminal chat → Persistent conversation flow: local interaction
- Assistant crew → Agent contracts: loads agents
- Assistant crew → Task contracts: loads tasks
- Assistant crew → Benefits knowledge: uses knowledge · Runtime ingestion is configuration-driven.
- Assistant crew → OpenAI model: selects provider
- Assistant crew → Gemini model: selects provider
- Assistant crew → Vertex model: selects provider
