AI chat
Multi-turn AI chat textbox embedded in the form, the user converses, the model can write back to form fields.
The AI chat component embeds a multi-turn chat window into the form. Unlike the single-shot AI button, AI chat keeps a conversation history, the user can ask follow-ups, refine a draft, or have the model walk them through filling out the form step by step.
Properties
| Property | Description |
|---|---|
aiPlaceholderstring default: Ask the AI… | Placeholder text for the user input box. |
aiSendLabelstring default: Send | Label on the send button. |
aiGreetingstring default: Hi! Ask me anything about this form, or tell me what to do. | Greeting bubble shown when the chat first mounts. Leave empty for no greeting. |
aiMaxTurnsnumber default: 10 | Max conversation turns kept in memory before older turns are trimmed. |
aiSuccessToaststring | Toast text shown after the AI successfully runs an action. |
aiErrorToaststring | Toast text shown when the AI call fails. Defaults to a generic "couldn't run the AI right now" message. |
aiAiConfig | The AI configuration object, see the sub-properties below. Set in the Properties pane via the AI config editor. |
The ai object (configured in the Properties pane, serialised with the
component) carries:
| Property | Description |
|---|---|
ai.promptTemplatestring | The prompt sent before each user message. Supports the {{form.allFields}} placeholder to inline current form state. |
ai.allowedActionsstring[] | Allow-list of actions the model may call, e.g. reply, set_field_value, set_field_values, show_toast, append_linked_list_row, append_linked_list_rows. See docs/ai-form-actions.md. |
ai.includeAllFieldsboolean default: true | Send the full form field set to the model as context. |
JavaScript recipes
AI chat writes back to the form through the same field-value path as any other
control, so you react to its actions with ordinary f365.events, there is no
separate AI event surface.
React when the chat fills a field
f365.events.onChange((e) => {
// The chat sets fields via set_field_value, observe it like any change.
if (e.fieldKey === 'Summary' && e.newValue) {
f365.field('Status').value = 'Drafted by AI';
}
});
Seed context the chat can read before the user types
f365.events.onLoad(() => {
// includeAllFields sends every field to the model, so pre-filling here
// gives the chat richer starting context.
if (!f365.field('RequestType').value) {
f365.field('RequestType').value = 'General enquiry';
}
});
Validate AI-populated fields before save
f365.events.onBeforeSave(async () => {
const summary = String(f365.field('Summary').value ?? '');
if (summary.length < 20) {
await f365.ui.showAlert('Ask the AI to expand the summary before submitting.');
return false; // cancels save, keeps the form open
}
return true;
});
Related
Related articles
- AI button
Single-shot AI action, runs a prompt against the form's current values and applies the model's tool calls back to the form.