> For the complete documentation index, see [llms.txt](https://docs.wisej.com/ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/ai/components/api/smartadapter/wisej.ai.adapters.smartchatboxadapter.md).

# SmartChatBoxAdapter

Namespace: **Wisej.AI.Adapters**

Assembly: **Wisej.AI** (3.5.0.0)

* [SmartAdapter](/ai/components/api/smartadapter.md)
  * [SmartChatBoxAdapter](/ai/components/api/smartadapter/wisej.ai.adapters.smartchatboxadapter.md)

Turns the [ChatBox](#chatbox) control into a AI-powered bot. It can answer any question (depending on the AI model being used) and can invoke methods in your applications as needed (see [SmartTool](/ai/components/api/smarttool.md)).

{% tabs %}
{% tab title="C#" %}

```csharp
public class SmartChatBoxAdapter : SmartAdapter
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class SmartChatBoxAdapter
    Inherits SmartAdapter
```

{% endtab %}
{% endtabs %}

Works with:

* AzureAI/OpenAI gpt-4
* AzureAI/OpenAI gpt-4o
* AzureAI/OpenAI gpt-3.5
* AzureAI/Anthropic Claude
* Google Gemini
* Llama3:8b and 70b

You are not limited to what the model can answer. When you add a method decorated with the [ToolAttribute](/ai/components/api/smarttool/wisej.ai.smarttool.toolattribute.md) the AI can invoke it when necessary in order to retrieve any information or take any action.\
This is a simple example that provides current date/time knowledge to the AI bot, including the name of the day:

```csharp

    [SmartTool.Tool]
    [Description("Returns the current date and time.")]
    public DateTime GetCurrentDateTime() {
      return DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
    }
  
```

When the AI needs to know the current date/time it will invoke this method. For example: "When is the next national holiday in {country}?".\
In this example you can see how to allow the AI to take an action.

```csharp

  [SmartTool.Tool]
  [Description("Changes the background color of the application header.")]
  public void SetHeaderColor(
      [Description("Name of the new color. Use @toolbar to reset to the original color.")]
      string color)
  {
    ((MainPage)Application.MainPage).panelHeader.BackColor = Color.FromName(color);
  }

```

When the AI wants to change the header color it will invoke this method with the correct parameter.\
Use this feature with a lot of caution! A method like "LaunchThermonuclearStrike()" is not allowed.

## Constructors

### ![](/files/ptrKjmmRoQB76pvrIqh0) SmartChatBoxAdapter()

Initializes a new instance of [SmartChatBoxAdapter](/ai/components/api/smartadapter/wisej.ai.adapters.smartchatboxadapter.md).

## Properties

### ![](/files/ptrKjmmRoQB76pvrIqh0) AutoReset

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Gets or sets a value indicating whether the history of the conversation is cleared after each response. (Default: `False`)

### ![](/files/ptrKjmmRoQB76pvrIqh0) BotAvatar

[String](https://docs.microsoft.com/dotnet/api/system.string): Icon of the AI bot. (Default: `"resource.wx/Wisej.AI/Icons/wisej-avatar.svg"`)

### ![](/files/ptrKjmmRoQB76pvrIqh0) BotName

[String](https://docs.microsoft.com/dotnet/api/system.string): Name of the AI bot. (Default: `"Wisej.AI"`)

### ![](/files/ptrKjmmRoQB76pvrIqh0) ChatBox

[ChatBox](https://docs.wisej.com/api?q=wisej.web.ext.chatcontrol.chatbox):

### ![](/files/ptrKjmmRoQB76pvrIqh0) User

[User](https://docs.wisej.com/api?q=wisej.web.ext.chatcontrol.user): The User associated to the AI bot. It's created using [BotName](#botname) and [BotAvatar](#botavatar).

## Methods

### ![](/files/KL0Ik37djZRr8a07Wopd) FormatAnswer(answer, sources)

| Parameter   | Type                                                              | Description |
| ----------- | ----------------------------------------------------------------- | ----------- |
| **answer**  | [String](https://docs.microsoft.com/dotnet/api/system.string)     |             |
| **sources** | [String\[\]](https://docs.microsoft.com/dotnet/api/system.string) |             |

**Returns:** [String](https://docs.microsoft.com/dotnet/api/system.string).

### ![](/files/KL0Ik37djZRr8a07Wopd) OnAnswerReceived(args)

| Parameter | Type                                                                                                                  | Description |
| --------- | --------------------------------------------------------------------------------------------------------------------- | ----------- |
| **args**  | [AnswerReceivedEventArgs](https://docs.wisej.com/api?q=wisej.ai.adapters.smartchatboxadapter+answerreceivedeventargs) |             |

### ![](/files/KL0Ik37djZRr8a07Wopd) OnControlCreated(control)

| Parameter   | Type                                                      | Description |
| ----------- | --------------------------------------------------------- | ----------- |
| **control** | [Control](https://docs.wisej.com/api?q=wisej.web.control) |             |

### ![](/files/KL0Ik37djZRr8a07Wopd) OnControlDisposed(control)

| Parameter   | Type                                                      | Description |
| ----------- | --------------------------------------------------------- | ----------- |
| **control** | [Control](https://docs.wisej.com/api?q=wisej.web.control) |             |

### ![](/files/KL0Ik37djZRr8a07Wopd) OnSourceClicked(args)

| Parameter | Type                                                                                                                | Description |
| --------- | ------------------------------------------------------------------------------------------------------------------- | ----------- |
| **args**  | [SourceClickedEventArgs](https://docs.wisej.com/api?q=wisej.ai.adapters.smartchatboxadapter+sourceclickedeventargs) |             |

### ![](/files/KL0Ik37djZRr8a07Wopd) ParseAnswer(text)

| Parameter | Type                                                          | Description |
| --------- | ------------------------------------------------------------- | ----------- |
| **text**  | [String](https://docs.microsoft.com/dotnet/api/system.string) |             |

**Returns:** [String](https://docs.microsoft.com/dotnet/api/system.string).

### ![](/files/KL0Ik37djZRr8a07Wopd) ParseSources(text)

| Parameter | Type                                                          | Description |
| --------- | ------------------------------------------------------------- | ----------- |
| **text**  | [String](https://docs.microsoft.com/dotnet/api/system.string) |             |

**Returns:** [String\[\]](https://docs.microsoft.com/dotnet/api/system.string).

### ![](/files/ptrKjmmRoQB76pvrIqh0) ResetSession(removeMessages)

Resets the conversation history.

| Parameter          | Type                                                            | Description                                                                     |
| ------------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| **removeMessages** | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) | Indicates whether all messages from the ChatBox control should also be removed. |

### ![](/files/KL0Ik37djZRr8a07Wopd) RunAsyncCore(control)

| Parameter   | Type                                                      | Description |
| ----------- | --------------------------------------------------------- | ----------- |
| **control** | [Control](https://docs.wisej.com/api?q=wisej.web.control) |             |

**Returns:** [Task\<Message>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1).

## Events

### ![](/files/ptrKjmmRoQB76pvrIqh0) AnswerReceived

[AnswerReceivedEventHandler](https://docs.wisej.com/api?q=wisej.ai.adapters.smartchatboxadapter+answerreceivedeventhandler)

### ![](/files/ptrKjmmRoQB76pvrIqh0) SourceClicked

[SourceClickedEventHandler](https://docs.wisej.com/api?q=wisej.ai.adapters.smartchatboxadapter+sourceclickedeventhandler)

## Implements

| Name                                                                              | Description                                |
| --------------------------------------------------------------------------------- | ------------------------------------------ |
| [IToolProvider](/ai/components/api/smarttool/wisej.ai.smarttool.itoolprovider.md) | Represents a provider that supplies tools. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wisej.com/ai/components/api/smartadapter/wisej.ai.adapters.smartchatboxadapter.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
