English
FxAiInsight
About 1366 wordsAbout 5 min
2026-08-20
Displays AI insight results generated from a prompt template or an AI Agent on a Web page.
Component API
Attributes
| Parameter | Description | Type | Optional Values | Default |
|---|---|---|---|---|
objectApiName | API Name of the object that owns the insight (required). Use this name for new frontend integrations. | String | — | '' |
objectDataId | ID of the current record. Required when record data, template fields, or record context is used. | String | — | '' |
id | Unique identifier of the insight component instance (required). Keep it stable for the same business location and do not reuse it for different instances. | String | Number | — | '' |
header | Component title (required). | String | — | '' |
i18nInfoList | Localized title data. The first value takes precedence over header when it is not empty. Example: [{ value: 'Account Insight' }]. | Array | — | [] |
ai_mode | Insight execution mode. The two values use mutually exclusive parameters described below. | String | prompt | agent | prompt |
trigger_mode | auto generates automatically when there is no historical result; manual shows a manual generation entry. | String | auto | manual | auto |
background | Component background style. | String | white | gradient | white |
maxHeight | Maximum height of the result area in px. Pass a number or digits-only string without px. | Number | String | — | 600 |
For record-based scenarios, pass objectDataId directly. Without a record ID, the Runtime creates a runtime identity from the current login context:
- In CRM, it reads
window.CRM.eaandwindow.CRM.curEmpId. - In Portal, it reads
window.Portal.upstreamEaandwindow.Portal.EROuterUid. - Prepare the identity before mounting the component. An incomplete identity prevents insight lookup and generation.
- Agent mode also requires this identity to create a session. Agent cannot start even when
objectDataIdis provided if the identity is incomplete.
Prompt and Agent Parameters
ai_mode="prompt" and ai_mode="agent" are mutually exclusive. Pass only the parameters for the active mode.
| Parameter | Prompt mode | Agent mode | Description |
|---|---|---|---|
promptApiname | Required | Do not pass | API Name of the prompt template. Prompt input comes from the template, template variables, and record context. |
agent_api_name | Do not pass | Required | Agent API Name. |
topic_api_name | Do not pass | Optional | Agent topic or skill API Name. |
default_message | Do not pass | Optional | Default Agent input. Defaults to ''. Supports plain text and ${ObjectApi.FieldApi} template fields. |
prefer_ai_product | Do not pass | Optional | Whether to prioritize the HTML product returned by the Agent. Only an explicit false disables it; enabled by default. |
The modes are mutually exclusive as follows:
- Prompt: use
ai_mode="prompt"together withpromptApiname. - Agent: use
ai_mode="agent"together withagent_api_name;topic_api_name,default_message, andprefer_ai_productmay also be passed. - Do not pass
promptApinameandagent_api_nametogether. default_messageis sent only in the Agent request and does not change the prompt template content.
Agent Default Input
default_message is the Agent input, not a historical insight result. Before sending the Agent request, the Runtime processes it in this order:
default_message
-> Resolve ${ObjectApi.FieldApi} template fields
-> [{ type: 'text', text: 'Calculated input text' }]
-> Agent request contentPlain text is passed through as-is. For example:
<FxAiInsight
ai_mode="agent"
agent_api_name="AccountInsightAgent"
default_message="Analyze the current account"
/>When using template fields, provide a real objectDataId as well:
<FxAiInsight
ai_mode="agent"
agent_api_name="AccountInsightAgent"
object-api-name="AccountObj"
:object-data-id="accountId"
default_message="Analyze account ${AccountObj.name}"
/>The Agent input differs between the first generation, a no-argument rerun, and a rerun with new input:
| Scenario | Agent input used |
|---|---|
| First generation | Current default_message prop |
rerunInsight() | The latest default_message prop at call time |
rerunInsight('new content') | The content passed for this run |
New content passed to rerunInsight only applies to that run. It does not update the parent data or the default_message prop. An explicit empty string '' is also a valid new input.
Methods
rerunInsight
The frontend component exposes the following method:
rerunInsight(updatedDefaultMessage?: string): Promise<boolean>Usage:
// Both Prompt and Agent modes support rerunning with the current configuration.
const accepted = await this.$refs.insight.rerunInsight();
// Agent mode only: rerun with an updated default input for this run.
const acceptedWithNewInput = await this.$refs.insight.rerunInsight(
'Generate insight from the latest business data'
);Parameters and return values:
| Item | Description |
|---|---|
updatedDefaultMessage | Optional string supported only in Agent mode. When provided, it is used as the default Agent input for this run. An empty string is supported. |
Returns true | The Runtime accepted and started this generation. |
Returns false | The generation did not start. Common reasons include missing identity, an unfinished history lookup, an active generation, an unavailable generator, template calculation failure, passing an input to Prompt mode, or a non-string argument. |
Promise<boolean> only indicates whether generation started. It does not wait for the final AI content or confirm that the result was saved. Do not call it repeatedly during generation. rerunInsight('text') returns false in Prompt mode because Prompt does not accept an arbitrary default input.
Events
The component does not expose public events. The current frontend API does not return the final result or expose a public completion event. Do not add unsupported listeners such as @success or @finished.
Slots
The component does not provide configurable public slots.
Examples
Basic Usage
Get the component through the global Cmpt loader. The return value is a Vue 2 asynchronous component factory that can be registered directly in components:
const AiInsight = window.Cmpt.get_paas('AiInsight');<template>
<FxAiInsight
id="account-prompt-insight"
object-api-name="AccountObj"
:object-data-id="accountId"
header="Account Insight"
ai_mode="prompt"
prompt-apiname="AccountInsightPrompt"
/>
</template>
<script>
const AiInsight = window.Cmpt.get_paas('AiInsight');
export default {
components: {
FxAiInsight: AiInsight
},
props: {
accountId: String
}
};
</script>Prompt Mode Demo
<template>
<div>
<FxAiInsight
ref="insight"
id="account-prompt-insight"
object-api-name="AccountObj"
:object-data-id="accountId"
header="Account Insight"
ai_mode="prompt"
trigger_mode="auto"
prompt-apiname="AccountInsightPrompt"
background="white"
:max-height="600"
/>
<fx-button @click="rerun">Run again</fx-button>
</div>
</template>
<script>
const AiInsight = window.Cmpt.get_paas('AiInsight');
export default {
components: {
FxAiInsight: AiInsight
},
props: {
accountId: String
},
methods: {
async rerun() {
const accepted = await this.$refs.insight.rerunInsight();
if (!accepted) {
return;
}
// The insight component renders the final content internally.
}
}
};
</script>Agent Mode Demo
<template>
<div>
<FxAiInsight
ref="insight"
id="account-agent-insight"
object-api-name="AccountObj"
:object-data-id="accountId"
header="Account Insight"
ai_mode="agent"
trigger_mode="auto"
agent_api_name="AccountInsightAgent"
topic_api_name="AccountOperationAnalysis"
:default_message="defaultMessage"
:prefer_ai_product="true"
:max-height="600"
/>
<fx-button @click="rerunWithLatestInput">Rerun with latest input</fx-button>
</div>
</template>
<script>
const AiInsight = window.Cmpt.get_paas('AiInsight');
export default {
components: {
FxAiInsight: AiInsight
},
props: {
accountId: String
},
data() {
return {
defaultMessage: 'Analyze the current account ${AccountObj.name}'
};
},
methods: {
async rerunWithLatestInput() {
const latestInput =
'Analyze the account ${AccountObj.name} using the latest data';
const accepted = await this.$refs.insight.rerunInsight(
latestInput
);
if (!accepted) {
return;
}
// latestInput applies only to this run and does not update defaultMessage.
}
}
};
</script>Traditional JavaScript Mount Demo
async function mountInsight(container, accountId) {
const AiInsight = window.Cmpt.get_paas('AiInsight');
const componentModule = await AiInsight();
const Component = Vue.extend(componentModule.default || componentModule);
const instance = new Component({
propsData: {
id: 'account-agent-insight',
objectApiName: 'AccountObj',
objectDataId: accountId,
header: 'Account Insight',
ai_mode: 'agent',
agent_api_name: 'AccountInsightAgent',
default_message: 'Analyze the current account'
}
});
instance.$mount();
container.appendChild(instance.$el);
const accepted = await instance.rerunInsight(
'Generate insight from the latest business data'
);
return {
instance,
accepted,
destroy() {
instance.$destroy();
instance.$el.remove();
}
};
}Notes
Result and Lifecycle
- After mounting, the Runtime first queries the current instance's historical insight. If one exists, it is displayed without starting another generation.
- Without a historical result,
trigger_mode="auto"starts generation automatically, whiletrigger_mode="manual"waits for the user to trigger it. rerunInsightskips the historical result and runs generation again. The component continues to own result rendering and persistence after the run completes.- The current frontend API does not return the final result or expose a public completion event. Do not add unsupported listeners such as
@successor@finished. - When the record ID or login identity is not ready, update the corresponding prop first and wait for the current lookup to complete before calling the rerun method.
Integration Checklist
- Keep
idstable for the same business location and unique within the global calling scope. - Use the real object API Name for
objectApiName. - Pass a real
objectDataIdwhen record context is required. - In Prompt mode, pass only
promptApiname; in Agent mode, passagent_api_nameand its mode-specific parameters. - Provide a real
objectDataIdwhen Agent template fields are used. - Prepare the login identity before mounting the component.
- Call
rerunInsightthrough arefonly after the component is mounted. - Handle
falsecorrectly and avoid duplicate calls during generation.
