Nota
L-aċċess għal din il-paġna jeħtieġ l-awtorizzazzjoni. Tista’ tipprova tidħol jew tibdel id-direttorji.
L-aċċess għal din il-paġna jeħtieġ l-awtorizzazzjoni. Tista’ tipprova tibdel id-direttorji.
Returns the currently active Microsoft 365 Copilot agent, or undefined if the agent state is not yet known.
Syntax
Xrm.Copilot.getCurrentAgent().then(successCallback, errorCallback);
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
successCallback |
Function | Yes | A function to call when the operation succeeds. |
errorCallback |
Function | Yes | A function to call when the operation fails. |
Return Value
Type: Promise<M365CopilotAgent | undefined> — Resolves to an M365CopilotAgent object describing the active agent, or undefined if the agent state isn't determined yet.
Remarks
Does nothing if Microsoft 365 Copilot isn't enabled.
The returned object's agentId and mode properties are paired:
agentIdis a non-null string andmodeis"agentPage"or"mentioned": an agent is active.agentIdisnullandmodeisnull: the user is on mainline Microsoft 365 Copilot (no agent active).
Example
const agent = await Xrm.Copilot.getCurrentAgent();
if (agent && agent.agentId) {
console.log(`Active agent: ${agent.agentId}, mode: ${agent.mode}`);
} else if (agent) {
console.log("User is on mainline M365 Copilot (no agent).");
} else {
console.log("Agent state not yet determined.");
}
Related articles
M365CopilotAgent interface
Xrm.Copilot (Client API reference)