UNPKG

@microsoft/agents-copilotstudio-client

Version:

Microsoft Copilot Studio Client for JavaScript. Copilot Studio Client.

57 lines (56 loc) 2.65 kB
/** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { ConnectionSettings } from './connectionSettings'; import { Activity } from '@microsoft/agents-activity'; /** * Client for interacting with Microsoft Copilot Studio services. * Provides functionality to start conversations and send messages to Copilot Studio bots. */ export declare class CopilotStudioClient { /** Header key for conversation ID. */ private static readonly conversationIdHeaderKey; /** Island Header key */ private static readonly islandExperimentalUrlHeaderKey; /** The ID of the current conversation. */ private conversationId; /** The connection settings for the client. */ private readonly settings; /** The Axios instance used for HTTP requests. */ private readonly client; /** * Returns the scope URL needed to connect to Copilot Studio from the connection settings. * This is used for authentication token audience configuration. * @param settings Copilot Studio connection settings. * @returns The scope URL for token audience. */ static scopeFromSettings: (settings: ConnectionSettings) => string; /** * Creates an instance of CopilotStudioClient. * @param settings The connection settings. * @param token The authentication token. */ constructor(settings: ConnectionSettings, token: string); private postRequestAsync; /** * Appends this package.json version to the User-Agent header. * - For browser environments, it includes the user agent of the browser. * - For Node.js environments, it includes the Node.js version, platform, architecture, and release. * @returns A string containing the product information, including version and user agent. */ private static getProductInfo; /** * Starts a new conversation with the Copilot Studio service. * @param emitStartConversationEvent Whether to emit a start conversation event. Defaults to true. * @returns A promise that resolves to the initial activity of the conversation. */ startConversationAsync(emitStartConversationEvent?: boolean): Promise<Activity>; /** * Sends a question to the Copilot Studio service and retrieves the response activities. * @param question The question to ask. * @param conversationId The ID of the conversation. Defaults to the current conversation ID. * @returns A promise that resolves to an array of activities containing the responses. */ askQuestionAsync(question: string, conversationId?: string): Promise<Activity[]>; }