IChatProps interface
đ Descriptionâ
Properties interface for the ChatRunner
React component.
đ Type declarationâ
interface IChatProps { definition?: IDefinition | Promise<IDefinition | undefined>;Optional snapshot?: ISnapshot | Promise<ISnapshot | undefined>;Optional styles?: IChatStyles | Promise<IChatStyles | undefined>;Optional license?: string | Promise<string | undefined>;Optional l10n?: IL10n | Promise<IL10n | undefined>;Optional view?: "live" | "test" | "preview";Optional display?: "inline" | "button" | "page";Optional removeBranding?: boolean;Optional persistent?: boolean;Optional className?: string;Optional customStyle?: CSSProperties;Optional customCSS?: string;Optional attachments?: IRunnerAttachments;Optional language?: string;Optional locale?: L10n.ILocale | ((locale: string) => L10n.ILocale | Promise<L10n.ILocale | undefined> | undefined);Optional translations?: L10n.TTranslation | L10n.TTranslation[] | ((language: string, name: string, version: string) => L10n.TTranslation | L10n.TTranslation[] | Promise<L10n.TTranslation | L10n.TTranslation[] | undefined> | undefined);Optional loader?: JSX.Element;Optional controller?: MutableRefObject<IChatController | undefined>;Optional builder?: MutableRefObject<Builder | undefined>;Optional onReady?: (instance: Instance | undefined) => void;EventOptional onTouch?: () => void;EventOptional onAction?: ( type: "start" | "stage" | "unstage" | "focus" | "blur" | "pause" | "complete", definition: { fingerprint: string; name: string; }, block?: { id: string; name: string; alias?: string; } ) => void;EventOptional onImport?: (instance: Instance) => void;EventOptional onChange?: (instance: Instance) => void;EventOptional onData?: (instance: Instance) => void;EventOptional onPause?: { recipe: "email"; onPause: ( emailAddress: string, snapshot: ISnapshot, language: string, locale: string, namespace: string ) => Promise<void> | boolean | void; } | ((snapshot: ISnapshot, language: string, locale: string, namespace: string) => Promise<void> | boolean | void);EventOptional onSubmit?: (instance: Instance, language: string, locale: string, namespace: string) => Promise<string | undefined> | boolean | void;EventOptional onComplete?: (instance: Instance, id?: string) => void;EventOptional onReload?: () => IDefinition | Promise<IDefinition>;EventOptional onEdit?: (type: "prologue" | "epilogue" | "styles" | "l10n" | "block", id?: string) => void;EventOptional onDestroy?: () => void;EventOptional }
đī¸ Propertiesâ
đˇī¸ attachments
â
Specifies the attachments handler used by blocks that support file uploads. If your form does not need file upload support, you can omit this property.
Typeâ
If your form uses file uploads and no attachments handler is defined, the uploaded files are included in the dataset using Base64 encoding.
Have a look at the Handling file uploads guide to learn how to use this feature.
đˇī¸ builder
â
Property to receive a reference to a Builder
instance. This will bind the runner with the builder and allows the builder to use the runner as a live form preview.
Typeâ
MutableRefObject<Builder
| undefined>
Have a look at the Live preview guide to learn more about this feature.
đˇī¸ className
â
Specifies a custom class name for the HTML element that holds the runner.
Typeâ
string
Have a look at the Style forms guide to learn more about this feature.
đˇī¸ controller
â
Property to receive a controller reference to the runner. This controller reference can be used to perform actions (like start, stop, pause) and retrieve status information from the runner.
Typeâ
MutableRefObject<IChatController
| undefined>
Have a look at the Controlling the runner guide to learn more about this feature.
đˇī¸ customCSS
â
Specifies custom CSS rules for blocks used in the runner. Multiple CSS rules can be separated with a new line and nesting within CSS rules is supported. Each block is referenced by its block identifier (for the stock blocks, this identifier is always prefixed with @tripetto/block-
followed by the lowercase name of the block).
Typeâ
string
Have a look at the Style forms guide to learn more about this feature.
đˇī¸ customStyle
â
Specifies the inline style for the HTML element that holds the runner.
Typeâ
CSSProperties
Have a look at the Style forms guide to learn more about this feature.
đˇī¸ definition
â
Specifies the definition to run. This property also accepts a Promise
. That's useful when you want to load the definition dynamically from an external source.
Typeâ
IDefinition
| Promise<IDefinition
| undefined>
đˇī¸ display
â
Specifies the display mode of the runner. It can be one of the following values:
inline
: Chat content shown inline with other page content (this is the default mode);button
: Chat window is behind a chat button (displayed in the bottom right corner of the page) and shown when the button is clicked;page
: Chat uses the whole page (viewport).
Typeâ
"inline" | "button" | "page"
Have a look at the Display guide to learn more about the runner display modes.
đˇī¸ l10n
â
Specifies the localization (locale and translation) information. This property also accepts a Promise
. That's useful when you want to load the l10n data dynamically from an external source.
Typeâ
IL10n
| Promise<IL10n
| undefined>
Have a look at the Localization guide for more information about locales and translations.
đˇī¸ language
â
Specifies the preferred language to use for the form locale and translation. This property is only used for form definitions that don't have a specified language. If a language is specified in the form definition, that language is always used.
Typeâ
string
Make sure to implement dynamic loading of locales and translations to let this feature work. Dynamic loading allows the runner to load the appropriate locale and translation based on the form language or the language specified by this property.
đˇī¸ license
â
Specifies a license code for the runner. This property also accepts a Promise
. That's useful when you want to load the license code dynamically from an external source.
Typeâ
string | Promise<string | undefined>
Have a look at the License guide for more information about applying licenses.
đˇī¸ loader
â
Specifies a loader that is shown when the runner is loading (e.g., awaiting any promises).
Typeâ
JSX.Element
đˇī¸ locale
â
Specifies the locale or the locale loader function to use. The locale data contains the number and date/time formats the runner uses.
Typeâ
L10n.ILocale
| ((locale: string) => L10n.ILocale
| Promise<L10n.ILocale
| undefined> | undefined)
Have a look at the Localization guide to learn more about this feature.
đˇī¸ persistent
â
Specifies if the runner should try to store sessions in the local store to preserve persistency on navigation between multiple pages that host the runner.
Typeâ
boolean
Have a look at the Form data persistency guide to learn more about this feature.
đˇī¸ removeBranding
â
Removes all visual Tripetto branding from the runner (a valid license is required).
Typeâ
boolean
Have a look at the Disable Tripetto branding guide to learn more about removing the branding.
đˇī¸ snapshot
â
Specifies the snapshot that should be restored. This property also accepts a Promise
. That's useful when you want to load the snapshot dynamically from an external source.
Typeâ
ISnapshot
| Promise<ISnapshot
| undefined>
Have a look at the Pause and resume guide to learn more about pausing and resuming.
đˇī¸ styles
â
Specifies the styles (colors, font, size, etc.) for the runner. This property also accepts a Promise
. That's useful when you want to load the styles dynamically from an external source.
Typeâ
IChatStyles
| Promise<IChatStyles
| undefined>
Have a look at the Style forms guide to learn more about styling the runner.
đˇī¸ translations
â
Specifies the translations or the translations loader function to use.
Typeâ
L10n.TTranslation
| L10n.TTranslation[]
| (language: string, name: string, version: string) => L10n.TTranslation
| L10n.TTranslation[]
| Promise<L10n.TTranslation
| L10n.TTranslation[]
| undefined> | undefined
Have a look at the Localization guide to learn more about this feature.
đˇī¸ view
â
Specifies the initial view mode of the runner. It can be one of the following values:
live
: The form is running in normal (production) mode (this is the default value);test
: The form is running in test mode (no response data is submitted);preview
: The form is running in preview mode, which shows all blocks in a single view.
Typeâ
"live" | "test" | "preview"
đĸ Eventsâ
đ onAction
â
Specifies a function that is invoked when the user performs an action. This is useful when you need to implement a tracking service like Google Analytics, Google Tag Manager, or FaceBook Pixel.
Have a look at the Tracking guide to learn more about this feature.
Signatureâ
(
type: "start" | "stage" | "unstage" | "focus" | "blur" | "pause" | "complete",
definition: {
fingerprint: string;
name: string;
},
block?: {
id: string;
name: string;
alias?: string;
}
) => void
Parametersâ
Name | Type | Optional | Description |
---|---|---|---|
type | "start" | "stage" | "unstage" | "focus" | "blur" | "pause" | "complete" | No | Contains the action type. It can be one of the following values: - start : A form is started;- stage : A block gets activated;- unstage : A block gets deactivated;- focus : An input element gains focus;- blur : An input element loses focus;- pause : A form is paused;- complete : A form is completed. |
definition | object | No | Contains information about the form definition. |
block | object | Yes | Contains information about the blocks. |
đ onChange
â
Specifies a function that is invoked when there is a change in the runner. This change can be anything from a data update to a UI rendering cycle.
If you only need updates on data changes, use the onData
event.
Signatureâ
(instance: Instance) => void
Parametersâ
Name | Type | Optional | Description |
---|---|---|---|
instance | Instance | No | Reference to the runner instance. |
đ onComplete
â
Specifies a function that is invoked when the runner is completed (after the data is submitted).
Have a look at the Collecting response data guide to learn how to feed an identifier or reference associated with the submitted response data back to the runner.
Signatureâ
(instance: Instance, id?: string) => void
Parametersâ
Name | Type | Optional | Description |
---|---|---|---|
instance | Instance | No | Reference to the runner instance. |
id | string | Yes | Contains an optional identifier or reference returned by the server. |
đ onData
â
Specifies a function that is invoked when there is a data change.
Signatureâ
(instance: Instance) => void
Parametersâ
Name | Type | Optional | Description |
---|---|---|---|
instance | Instance | No | Reference to the runner instance. |
đ onDestroy
â
Specifies a function that is invoked when the component unmounts.
Signatureâ
() => void
đ onEdit
â
Specifies a function that is invoked when an edit action is requested. This event is useful in a live preview setup where the builder can open the properties panel of the referenced item.
Read the Live form preview guide for an example.
Signatureâ
(type: "prologue" | "epilogue" | "styles" | "l10n" | "block", id?: string) => void
Parametersâ
Name | Type | Optional | Description |
---|---|---|---|
type | "prologue" | "epilogue" | "styles" | "l10n" | "block" | No | Specifies the type of item being edited. |
id | string | Yes | Specifies the item identifier. |
đ onImport
â
Specifies a function that is invoked when data can be imported into the instance. To import form data, you need to use one of the Import
functions from the Runner library as shown in the Prefilling forms guide.
Have a look at the Prefilling forms guide to learn more about importing data.
Signatureâ
(instance: Instance) => void
Parametersâ
Name | Type | Optional | Description |
---|---|---|---|
instance | Instance | No | Reference to the runner instance. |
đ onPause
â
Specifies a function or recipe that is invoked when the runner wants to pause. The recipe email
can be used if you want to collect the email address of the respondent before pausing the form. Read the Pause and resume guide for more information about this feature.
Once you implement the onPause
event, a pause button will appear in the runner's UI. When the respondent clicks this button, the pause event fires. When the email
recipe is used, the runner will first ask for the respondent's email address and then invoke the event.
Have a look at the Pause and resume guide to learn more about this feature.
Signatureâ
{
recipe: "email";
onPause: (
emailAddress: string,
snapshot: ISnapshot,
language: string,
locale: string,
namespace: string
) => Promise<void> | boolean | void;
} | ((snapshot: ISnapshot, language: string, locale: string, namespace: string) => Promise<void> | boolean | void)
Parametersâ
Name | Type | Optional | Description |
---|---|---|---|
emailAddress | string | No | Contains the email address when the email recipe is used. |
snapshot | ISnapshot | No | Contains the snapshot data. |
language | string | No | Contains the language used in the runner (default is en ). |
locale | string | No | Contains the locale identifier used in the runner (default is en ). |
namespace | string | No | Contains the namespace identifier for the runner. |
Return valueâ
Returns true
when the pause succeeded, false
if it failed or a Promise
that resolves in case the pause succeeded or rejects in case of an error.
đ onReady
â
Specifies a function that is invoked when the runner is ready.
The onReady
event is invoked after all the resources (form definition, styles, locales, and translations) are loaded.
Signatureâ
(instance: Instance | undefined) => void
Parametersâ
Name | Type | Optional | Description |
---|---|---|---|
instance | Instance | undefined | No | Reference to the runner instance or undefined if no form has started. |
đ onReload
â
Specifies a function that is invoked when the runner wants to reload the definition. The definition returned by this event handler is loaded, preserving the data already entered by the user.
This event will be automatically invoked when data is submitted to an endpoint, but the endpoint indicates the form is outdated. To indicate this, the onSubmit
event can reject with status outdated
. See the Collecting response data guide for more information about this feature.
Signatureâ
() => IDefinition | Promise<IDefinition>
Return valueâ
Returns the reloaded IDefinition
or a Promise
that resolves with the IDefinition
.
đ onSubmit
â
Specifies a function that is invoked when the runner submits data. This event is the one to use to submit the form data to an endpoint. To retrieve the form data, you need to use one of the Export
functions from the Runner library as shown in the Collecting response data guide.
This event supports different return types. First of all, you can return a boolean value to indicate if the submission was successful or not. That's only useful for synchronous operations. If you need async operation, you can return a Promise
which resolves in case of a successful operation or rejects when the submission fails.
Have a look at the Collecting response data guide to learn more about submitting data, async operation, and handling errors. To learn more about validating the response data, read the Validating response data guide. If you need spam protection for your forms, the Prevent form spamming guide is of interest to you.
Signatureâ
(instance: Instance, language: string, locale: string, namespace: string) =>
Promise<string | undefined> | boolean | void
Name | Type | Optional | Description |
---|---|---|---|
instance | Instance | No | Reference to the runner instance. |
language | string | No | Contains the language used in the runner (default is en ). |
locale | string | No | Contains the locale identifier used in the runner (default is en ). |
namespace | string | No | Contains the namespace identifier for the runner. |
Return valueâ
Returns true
when the submission succeeded, false
if it failed or a Promise
that resolves with an optional reference string (in case it succeeds) or rejects (in case of an error).
đ onTouch
â
Specifies a function that is invoked when the runner is "touched" by a user. This is an interaction by the user with the runner by either the mouse, touch input, or keyboard.
Signatureâ
() => void