public ConversationContext(
     IMicrosoftCognitiveServicesApiKeys apiKeys,
     IConversationFactory conversationFactory,
     IConversationHistory conversationHistory,
     IIntentProvider intentProvider)
 {
     ApiKeys             = apiKeys;
     ConversationFactory = conversationFactory;
     ConversationHistory = conversationHistory;
     IntentProvider      = intentProvider;
 }
 public LuisConversationService(
     IIntentProvider intentProvider,
     IMicrosoftCognitiveServicesApiKeys apiKeys,
     IConversationResponseFactory responseFactory,
     IParameterResultFactory resultFactory)
 {
     IntentProvider = intentProvider;
     ApiKeys        = apiKeys;
     ConversationResponseFactory = responseFactory;
     ResultFactory = resultFactory;
 }
示例#3
0
        public OleChatController(
            ILuisService luisService,
            ILuisConversationService luisConversationService,
            IWebUtilWrapper webUtil,
            ISitecoreDataWrapper dataWrapper,
            IOleSettings chatSettings,
            ISetupInformationFactory setupFactory,
            ISetupService setupService,
            ISpeechService speechService,
            ISearchService searcher,
            IConversationContextFactory conversationContextFactory,
            ISpellCheckService spellCheckService,
            IIntentProvider intentProvider)
        {
            LuisService             = luisService;
            LuisConversationService = luisConversationService;
            WebUtil       = webUtil;
            DataWrapper   = dataWrapper;
            ChatSettings  = chatSettings;
            SetupFactory  = setupFactory;
            SetupService  = setupService;
            SpeechService = speechService;
            Searcher      = searcher;
            ConversationContextFactory = conversationContextFactory;
            SpellCheckService          = spellCheckService;
            IntentProvider             = intentProvider;
            ThemeManager.GetImage("Office/32x32/man_8.png", 32, 32);

            var lang = WebUtil.GetQueryString("language");

            if (string.IsNullOrWhiteSpace(lang))
            {
                lang = Sitecore.Context.Language.Name;
            }

            var db = WebUtil.GetQueryString("db");

            if (string.IsNullOrWhiteSpace(db))
            {
                db = "master";
            }

            Parameters = new ItemContextParameters()
            {
                Id       = WebUtil.GetQueryString("id"),
                Language = lang,
                Database = db
            };
        }
        public ConversationService(
            IIntentProvider intentProvider,
            ILuisService luisService,
            IOleSettings oleSettings,
            IConversationHistory convoHistory,
            IConversationFactory convoFactory,
            IConversationResponseFactory responseFactory,
            ITextAnalyticsService textAnalyticsService)
        {
            IntentProvider              = intentProvider;
            LuisService                 = luisService;
            OleSettings                 = oleSettings;
            ConversationHistory         = convoHistory;
            ConversationFactory         = convoFactory;
            ConversationResponseFactory = responseFactory;
            TextAnalyticsService        = textAnalyticsService;

            AppId = OleSettings.OleApplicationId;
        }
示例#5
0
        public async Task <OkResult> Post([FromServices] IIntentProvider intentProvider, [FromServices] IIntentRouter intentRouter, [FromBody] Activity activity)
        {
            var appCredentials = new MicrosoftAppCredentials(
                configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppIdKey)?.Value,
                configuration.GetSection(MicrosoftAppCredentials.MicrosoftAppPasswordKey)?.Value);
            var client = new ConnectorClient(new Uri(activity.ServiceUrl), appCredentials);

            var reply = activity.CreateReply();

            if (activity.Type == ActivityTypes.Message)
            {
                Console.WriteLine($"Calling intent provider '{intentProvider.GetType().FullName}' with '{activity.Text}'");
                var intent = await intentProvider.GetIntentAsync(activity.Text);

                Console.WriteLine($"Intent provider returned '{intent.Name}'");

                // TODO: Add real user data to request
                // TODO: Add real source data to request
                var request = new IntentBot.UserRequestBuilder()
                              .AddIntent(intent)
                              .AddUser("FakeUserId", "PHX")
                              .AddSource("FakeRequestSource")
                              .Build();

                Console.WriteLine($"Routing request to '{intentRouter.GetType().FullName}'");
                var routingResult = await intentRouter.RouteToHandlerAsync(request);

                Console.WriteLine($"Service returned '{routingResult.ResponseText}'");

                reply.Text = routingResult.ResponseText;
            }
            else
            {
                reply.Text = $"activity type: {activity.Type}";
            }

            await client.Conversations.ReplyToActivityAsync(reply);

            return(Ok());
        }
示例#6
0
 public AlexaController(IIntentProvider intentProvider)
 {
     this.intentProvider = intentProvider;
 }