Edit

Share via


executePrompt (Client API reference) (preview)

Important

  • This is a preview feature.
  • Preview features aren’t meant for production use and might have restricted functionality. These features are subject to supplemental terms of use, and are available before an official release so that customers can get early access and provide feedback.

Executes a Microsoft Copilot Studio topic based on the trigger queries registered in the topic. Returns the array of type MCSResponse.

Syntax

Xrm.Copilot.executePrompt(promptText).then(successCallback, errorCallback);

Parameters

Parameter Name Type Required Description
promptText string Yes The text that is registered as a trigger query in the MCS topic.
successCallback Function Yes A function to call when the operation succeeds.
errorCallback Function Yes A function to call when the operation fails.

Return Value

An array of MCSResponse

Example

In Microsoft Copilot Studio, a topic is triggered by queries like "hello" or "hi." When executePrompt runs with matching promptText, it activates the topic and returns a Message activity with the response text.

const response = await Xrm.Copilot.executePrompt("hello"); 

Response

This is an example of the response that may be returned.

[
    {
        "type": "message",
        "timestamp": "2025-02-05T16:46:07.7799759+00:00",
        "replyToId": "aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb",
        "attachments": [],
        "textFormat": "markdown",
        "text": "Hello, how can I help you today?",
        "speak": "Hello, <break strength=\"medium\" /> how can I help?"
    }
]

Xrm.Copilot (Client API reference)