# Methods

## Instance

### Embed

Embed the AI form instance into your application. The **selector** is required, and is document querySelector to find the HTML-tag into which you want to embed the form.

<pre class="language-typescript"><code class="lang-typescript"><strong>aiForm.embed({ selector: "#embed" })
</strong></code></pre>

### isLoaded

Returns `true` if the instance has been loaded and embedded into your application.

<pre class="language-typescript"><code class="lang-typescript"><strong>aiForm.isLoaded()
</strong></code></pre>

### getVersion

Returns the current version of the SDK

```typescript
aiForm.getVersion()
```

### destroy

Remove the form interface from your application.

```typescript
aiForm.destroy();
```

## Styling

### getColorScheme

Get the current colorScheme.

```typescript
aiForm.getColorScheme();
```

### setColorScheme

Sets your preferred color theme choices. `auto` will use your OS color scheme.

```typescript
aiForm.setColorScheme("auto" | "light" | "dark");
```

### getTheme

Get the theme configuration that has been set

```typescript
aiForm.getTheme();
```

### setTheme

Set or change the theme of your interface. *More info about* [*theme configuration*](/sdk/ai-form/configuration.md#css-customization)

```typescript
aiForm.setTheme({
    light: ThemeObject,
    dark: ThemeObject,
});
```

## Settings

### isFileUploadAllowed

Check if file upload has been allowed

```javascript
aiForm.isFileUploadAllowed
```

### setIsFileUploadAllowed

Change if customers are allowed to upload files into the conversation. Will only work if file upload has been enabled in the project.

```javascript
aiForm.setIsFileUploadAllowed(allowed: boolean);
```

## Text

Most static text that you see in the form can be customised

### getText

Get the text configuration that has been set

```typescript
aiForm.getText();
```

### setText

Set or change the text of your interface. *More info about* [*text configuration*](/sdk/ai-form/configuration.md#text-customization)

```typescript
aiForm.setText(TextObject);
```

## Language

### getLanguage

Get the current language that is used. By default we will use the language that has been set as default in your project

```typescript
aiForm.getLanguage();
```

### setLanguage

Set or change the language of your interface. We support all [ISO 639-1 language codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).

```typescript
aiForm.setLanguage("nl");
```

## Context

Context allows you to supply pre-existing information to the form, helping the assistant avoid asking your customer unnecessary questions.

### getContext

Get the context that have been set in the form instance.

```typescript
aiForm.getContext();
```

### updateContextField

Set or update a new key in the form instance context. \
If you set a value to `undefined` this key will be removed from the context.

```typescript
aiForm.updateContextField(
    { key: "value" }: Record<string, Boolean | number | string | undefined>
);
```

## Customer data

Customer data helps you to identify the customer behind a form session.

### getCustomer

Returns the data we known about your customer.

```typescript
aiForm.getCustomer();
```

### setCustomer

Set or update customer data for the current form interface.

```typescript
aiForm.setCustomer(CustomerData | undefined);
```

*More info about* [*customerData*](/sdk/attributes.md#customer-data)

## Timezone

Customize the timezone for your conversation. By default, the project's timezone will be used.

### getTimezone

Returns the current timezone

```typescript
aiForm.getTimezone();
```

### setTimezone

Set or update timezone for the current form interface.

```typescript
aiForm.setTimezone("Europe/Brussel");
```

## Static methods

### generateSessionId

Generate a unique session id

```typescript
Chathive.AIForm.generateSessionId()
```


---

# Agent Instructions: 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:

```
GET https://developers.chathive.app/sdk/ai-form/methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
