Nota
Capaian ke halaman ini memerlukan kebenaran. Anda boleh cuba mendaftar masuk atau menukar direktori.
Capaian ke halaman ini memerlukan kebenaran. Anda boleh cuba menukar direktori.
Nota
Copilot Studio bot dinamakan semula sebagai ejen Copilot (ejen atau ejen AI). Ejen manusia kini dinamakan semula sebagai wakil perkhidmatan pelanggan (wakil atau wakil perkhidmatan). Anda mungkin menemui rujukan kepada istilah lama dan baharu semasa kami mengemas kini UI produk, dokumentasi dan kandungan latihan.
Untuk ejen Azure, anda mesti memasang SDK ejen dan membuat perisian tengah Omnichannel sebelum anda mengkonfigurasikan konteks ejen.
Pasang bot SDK dalam projek anda
Untuk membuka NuGet Package Manager, klik kanan projek anda dan kemudian pilih Urus Pakej NuGet.
Dalam Package Manager NuGet, pilih sumber pakej sebagai nuget.org dan semak imbas "Microsoft.Dynamics. EjenSDK.Perisian Tengah". Pilih pakej, dan kemudian pilih Pasang. Ketahui lebih lanjut dalam halaman Nuget.
Sebagai alternatif, anda boleh menggunakan arahan berikut dalam NuGet CLI.
Install-Package Microsoft.Dynamics.AgentsSDK.Middleware
SDK ejen kini dipasang dan perisian tengah Omnichannel tersedia dalam projek anda.
Gunakan perisian tengah Omnichannel dalam kod ejen anda
Buka fail AdapterWithErrorHandler.cs .
Tambahkan pernyataan import dan wujudkan perisian tengah Omnichannel.
using Microsoft.Dynamics.AgentsSDK.Middleware.Core; Use(new OmnichannelMiddleware());using System.Globalization; using System.Text; using Microsoft.Agents.Connector; using Microsoft.Agents.Core; using Microsoft.Agents.Core.Errors; using Microsoft.Extensions.Logging; using Microsoft.Dynamics.AgentsSDK.Middleware.Core; namespace Microsoft.CCaaS.MessagingRuntime.TestAgent; public class AdapterWithErrorHandler : CloudAdapter { public AdapterWithErrorHandler( IChannelServiceClientFactory channelServiceClientFactory, IActivityTaskQueue activityTaskQueue, ILogger<CloudAdapter> logger) : base(channelServiceClientFactory, activityTaskQueue, logger) { // OmnichannelMiddleware has special handling for OC event messages Use(new OmnichannelMiddleware()); OnTurnError = async (turnContext, exception) => { var exceptionInfo = GetExceptionInfo(exception); logger.LogAppException(exceptionInfo, exception); // Send a message to the user await turnContext.SendActivityAsync($"The bot encountered an error or bug.{Environment.NewLine}{exceptionInfo}"); await turnContext.SendActivityAsync("To continue to run this bot, please fix the bot source code."); // Send a trace activity, which will be displayed in the Bot Framework Emulator await turnContext.TraceActivityAsync("OnTurnError Trace", exception.Message, "https://www.botframework.com/schemas/error", "TurnError"); }; } private static string GetExceptionInfo(Exception exception) { var sb = new StringBuilder(); // Pull some well known info from ErrorResponse.Exception if available. if (exception is ErrorResponseException responseException) { sb.AppendLine(CultureInfo.InvariantCulture, $"Error code: {responseException.Body?.Error?.Code ?? "NA"}"); sb.AppendLine(CultureInfo.InvariantCulture, $"Error message: {responseException.Body?.Error?.Message ?? "NA"}"); } sb.AppendLine(CultureInfo.InvariantCulture, $"Exception message: {exception.Message}"); sb.AppendLine(); sb.AppendLine(exception.ToString()); var exceptionInfo = sb.ToString(); return exceptionInfo; } }
Langkah-langkah berikutnya
Huraikan JSON aktiviti untuk mendapatkan konteks ejen
Maklumat berkaitan
Hantar konteks tersuai
setContextProvider
Sepadukan ejen Azure