Konfiguratu agentearen testuingurua Azure agenteetan

Oharra

Copilot Studio bot-a Copilot agente (agentea edo AI agente) izena hartzen du. Bezeroarentzako arreta-zerbitzuko ordezkari gisa (zerbitzu-ordezkaria edo ordezkaria) izendatzen da orain giza-agentea. Baliteke termino zahar eta berriei buruzko erreferentziak topatzea produktuaren interfazea, dokumentazioa eta prestakuntza-edukia eguneratzen ditugun bitartean.

Azure agenteen kasuan, agentearen SDK instalatu behar duzu eta Omnichannel middleware-a instantziatu behar duzu agentearen testuingurua konfiguratu aurretik.

Bot-eko SDK-aren instalazioa proiektuan

  1. NuGet Package Manager irekitzeko, egin klik eskuineko botoiarekin proiektuan, eta hautatu Kudeatu NuGet paketeak.

  2. NuGet Package Manager, hautatu paketearen iturburua nuget.org gisa eta arakatu "Microsoft.Dynamics. AgentsSDK.Middleware". Hautatu paketea, eta hautatu Instalatu. Informazio gehiago Nuget orrian.

    Hautabide gisa, nuGet-eko KLEn hurrengo komandoa erabil dezakezu.

    Install-Package Microsoft.Dynamics.AgentsSDK.Middleware
    

Agentearen SDK instalatuta orain eta kanal omnikanaleko middlewarea eskuragarri zure proiektuan.

Erabili kanal omnikoitzeko middlewarea agentearen kodean

  1. Ireki artxiboa AdapterWithErrorHandler.cs .

  2. Instrukzio inport-a egin eta middleware omnicanalaren instantzia bat sortzen du.

    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;
        }
    }
    

Hurrengo urratsak

Jardueraren JSON aztertzea, agentearen testuingurua lortzeko

Testuinguru pertsonalizatua bidaltzea
setContextProvider
Integratu Azure agente bat