Methods

The AI form instance offers various methods to help you interact with and customize it.

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.

aiForm.embed({ selector: "#embed" })

isLoaded

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

aiForm.isLoaded()

getVersion

Returns the current version of the SDK

aiForm.getVersion()

destroy

Remove the form interface from your application.

aiForm.destroy();

Styling

getColorScheme

Get the current colorScheme.

aiForm.getColorScheme();

setColorScheme

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

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

getTheme

Get the theme configuration that has been set

aiForm.getTheme();

setTheme

Set or change the theme of your interface. More info about theme configuration

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

Text

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

getText

Get the text configuration that has been set

aiForm.getText();

setText

Set or change the text of your interface. More info about text configuration

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

aiForm.getLanguage();

setLanguage

Set or change the language of your interface. We support all ISO 639-1 language codes.

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.

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.

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.

aiForm.getCustomer();

setCustomer

Set or update customer data for the current form interface.

aiForm.setCustomer(CustomerData | undefined);

More info about customerData

Static methods

generateSessionId

Generate a unique session id

Chathive.AIForm.generateSessionId()

Last updated