コード例 #1
0
        private async Task <string> GetLuisIntent(ITurnContext turnContext, bool enableLuis, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (!enableLuis)
            {
                return("None");
            }

            try
            {
                var luisResult = await _services.LuisServices[LuisKey].RecognizeAsync(turnContext, cancellationToken);
                var topIntent  = luisResult?.GetTopScoringIntent();
                TelemetryUtils.LogLuisResponse(this._services.TelemetryClient, TelemetryConstants.LuisEvent, turnContext.Activity, topIntent.Value.intent + " score : " + topIntent.Value.score.ToString());
                return(topIntent.Value.intent);
            }
            catch (Exception e)
            {
                TelemetryUtils.LogException(this._services.TelemetryClient, turnContext.Activity, e, "luis", "expection while getting luis intent");
                return("None");
            }
        }