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.

The AI button runs a one-shot AI prompt when the user clicks it. The current form values are sent to the backend along with the configured prompt template and a list of allowed tool calls; the model returns a sequence of tool calls (set field value, append row to a linked list, show toast, etc.) which the form runtime applies.

Use it for actions like "Summarise this complaint", "Suggest a customer reply", "Categorise this incident", or "Fill in a starter description from the title".

Common properties

PropertyDescription
label
string
default: "Ask AI"
Button text.
visibleIf
expression
Hide unless the expression returns true.
enableIf
expression
Disable until prerequisites are met.

Type-specific properties

PropertyDescription
prompt
string template
The prompt sent to the model. Supports {{FieldName}} token replacement, drawing from the current form values.
allowedActions
enum[]
Allow-list of tool calls the model may make. Available: set_field_value, append_linked_list_rows, show_toast, show_alert, set_fields_bulk.
allowedFields
string[]
Restrict which fields the model may write. Empty array = none; omitted = any field on the form.
busyLabel
string
default: "Thinking…"
Shown while the model is running.
systemPrompt
string
Optional system prompt prepended to the conversation.

JavaScript recipes

Pre-flight: bail if a required input is missing

f365.events.onBeforeSave(() => {
  /* normal submit */
});

// Per-control onClick on the AI button:
f365.control('SuggestReplyBtn').on('click', () => {
  if (!f365.field('CustomerMessage').value) {
    f365.ui.showAlert('Type the customer message first, then ask AI for a reply.');
    return { cancel: true };
  }
});

Listen for completion

f365.control('SuggestReplyBtn').on('ai-complete', ({ actionsApplied, error }) => {
  if (error) f365.ui.showToast('AI run failed: ' + error.message, 'error');
  else f365.ui.showToast(`AI updated ${actionsApplied} field(s).`, 'success');
});

Reset after a run

f365.control('SuggestReplyBtn').on('ai-complete', () => {
  f365.field('AiNotes').value = ''; // clear any scratch state
});

Related articles

  • AI chat

    Multi-turn AI chat textbox embedded in the form, the user converses, the model can write back to form fields.

  • Submit button

    The form's primary action button, triggers validation, the save flow, and any onBeforeSave / onSave handlers.