← All SmartAdapters Conversation

SmartChatBoxAdapter

Turns an ordinary ChatBox into a grounded assistant that answers questions and calls your own methods when it needs to.

Attaches to ChatBox

Drop a ChatBox on a form, attach the adapter, and the control becomes a working chat agent. Questions go to the configured endpoint, answers come back formatted with citation sources, and the conversation keeps its context across turns.

The real leverage is tools. Any method you decorate with [SmartTool.Tool] becomes something the model can invoke mid-conversation — look up an order, change a header color, fetch the current date. The adapter handles the round trip, so the assistant can act on the running application instead of only talking about it.

Behind the scenes the adapter manages the prompt window, trims history to fit the model's context, and resolves tool calls before composing the final answer. The result reads like a chat, but each turn is a fully managed pipeline — context, tools, citations — that you never have to orchestrate yourself.

What it gives you

  • Keeps conversation history; set AutoReset to clear it after each answer.
  • Formats answers with clickable citation sources via the SourceClicked event.
  • Configurable BotName and BotAvatar for the assistant identity.
  • Works across OpenAI, Azure, Anthropic Claude, Google Gemini and Llama models.

Use it for

  • A support assistant that answers from your own knowledge base
  • An in-app helpdesk that can look up orders, accounts and tickets
  • A conversational front end for internal line-of-business data

Like every adapter, it runs through a SmartHub and inherits its SmartEndpoint — switching the model or provider never changes this code.

csharp
// Wire a ChatBox to an AI assistant
var hub = new SmartHub(this) {
    Endpoint = new OpenAIEndpoint { Model = "gpt-4o" }
};

var chat = new SmartChatBoxAdapter {
    ChatBox = chatBox1,
    BotName = "Atlas"
};

// Expose an application method to the assistant
[SmartTool.Tool]
[Description("Looks up the status of an order by its id.")]
public string GetOrderStatus(int orderId) =>
    Orders.Find(orderId).Status;

Read the SmartChatBoxAdapter docs ↗