Esempio n. 1
0
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            var connector = new ConnectorClient(new Uri(activity.ServiceUrl));

            var attributes = new LuisModelAttribute(
                ConfigurationManager.AppSettings["LuisId"],
                ConfigurationManager.AppSettings["LuisSubscriptionKey"]);
            var service = new LuisService(attributes);

            switch (activity.Type)
            {
            case ActivityTypes.Message:
                await Conversation.SendAsync(activity, () => new LuisDialog(service));

                break;

            case ActivityTypes.ConversationUpdate:
                if (activity.MembersAdded.Any(o => o.Id == activity.Recipient.Id))
                {
                    var reply = activity.CreateReply();
                    reply.Text = "Olá, eu sou o **James Bot**. Olha abaixo o que eu posso fazer:\n\n" +
                                 "* **Falar que nem gente**\n" +
                                 "* **Realizar cotação de moedas**\n" +
                                 "* **Pesquisar sobre filmes e séries**\n";

                    await connector.Conversations.ReplyToActivityAsync(reply);
                }
                break;
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Esempio n. 2
0
        private static IContainer RegisterDependencies(ContainerBuilder builder)
        {
            builder.Register(c =>
            {
                var kbid = ConfigurationManager.AppSettings["QnaKnowledgeBaseId"];
                var key  = ConfigurationManager.AppSettings["QnaSubscriptionKey"];

                var qnaAttribute = new QnAMakerAttribute(key, kbid, "I don't know what you're talking about!", 0.3);
                return(new QnAMakerService(qnaAttribute));
            }).As <IQnAService>().InstancePerLifetimeScope();

            builder.Register(c =>
            {
                var luisAppId = ConfigurationManager.AppSettings["LuisAppId"];
                var luisKey   = ConfigurationManager.AppSettings["LuisSubscriptionKey"];

                var luisModel = new LuisModelAttribute(luisAppId, luisKey, threshold: 0.8D);
                return(new LuisService(luisModel));
            }).As <ILuisService>().InstancePerLifetimeScope();

            builder.Register(c =>
            {
                var wechatOutgoingUri = ConfigurationManager.AppSettings["WechatOutgoingURI"];
                return(new MessageDispatcher(wechatOutgoingUri));
            }).As <IMessageDispatcher>().InstancePerLifetimeScope();

            return(builder.Build());
        }
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            if (activity.Type == ActivityTypes.Message)
            {
                if (IsSpellCorrectionEnabled)
                {
                    try
                    {
                        activity.Text = await this.spellService.GetCorrectedTextAsync(activity.Text);
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError(ex.ToString());
                    }
                }

                var rootModelAttribute = new LuisModelAttribute(WebConfigurationManager.AppSettings["LuisModelId"], WebConfigurationManager.AppSettings["LuisSubscriptionKey"]);
                await Conversation.SendAsync(activity, () => new RootLuisDialog(rootModelAttribute));
            }
            else
            {
                this.HandleSystemMessage(activity);
            }

            var response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }
Esempio n. 4
0
        private static ILuisService GetLuisService(string ModelId, string SubscriptionKey)
        {
            var          luisModel   = new LuisModelAttribute(ModelId, SubscriptionKey, LuisApiVersion.V2, "westus.api.cognitive.microsoft.com");
            ILuisService luisService = new LuisService(luisModel);

            return(luisService);
        }
Esempio n. 5
0
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            var connector = new ConnectorClient(new Uri(activity.ServiceUrl));

            var attributes = new LuisModelAttribute(
                ConfigurationManager.AppSettings["LuisId"],
                ConfigurationManager.AppSettings["LuisSubscriptionKey"]);
            var service = new LuisService(attributes);

            if (activity.Type == ActivityTypes.Message)
            {
                var isTypingActivity = activity.CreateReply();
                isTypingActivity.Type = ActivityTypes.Typing;
                await connector.Conversations.ReplyToActivityAsync(isTypingActivity);

                await Conversation.SendAsync(activity, () => new MainDialog(service));
            }
            else
            {
                HandleSystemMessage(activity);
            }
            var response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            var Connector  = new ConnectorClient(new Uri(activity.ServiceUrl));
            var Attributes = new LuisModelAttribute(ConfigurationManager.AppSettings["LuisId"], ConfigurationManager.AppSettings["LuisSubscriptionKey"]);
            var Service    = new LuisService(Attributes);

            switch (activity.Type)
            {
            case ActivityTypes.Message:
                await Conversation.SendAsync(activity, () => new RootDialog(Service));

                break;

            case ActivityTypes.ConversationUpdate:
                if (activity.MembersAdded.Any(o => o.Id == activity.Recipient.Id))
                {
                    var reply = activity.CreateReply();
                    reply.Text = Welcome();

                    await Connector.Conversations.ReplyToActivityAsync(reply);
                }
                break;
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Esempio n. 7
0
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            builder
            .Register(c => new ListSongs())
            .As <ILuisIntentHandlerDialog>();

            builder
            .Register(c => new LuisIntentHandlerDialogFactory(c.Resolve <IEnumerable <ILuisIntentHandlerDialog> >()))
            .InstancePerLifetimeScope();

            LuisModelAttribute luisModelAttribute = new LuisModelAttribute("329382da-1aff-4671-9be4-e0d9bd1144e0", "9aceb8ad11e04e1d82c880bd16f4525f", LuisApiVersion.V2, "southeastasia.api.cognitive.microsoft.com");

            builder
            .Register(c => new LuisService(luisModelAttribute))
            .As <ILuisService>()
            .InstancePerLifetimeScope();

            builder
            .Register(c => new LuisScorable(c.Resolve <ILuisService>(), c.Resolve <IDialogTask>(), c.Resolve <ILogger>(), c.Resolve <LuisIntentHandlerDialogFactory>()))
            .As <IScorable <IActivity, double> >()
            .InstancePerLifetimeScope();

            builder
            .Register(c => new GlobalMessageScorable(c.Resolve <IDialogTask>()))
            .As <IScorable <IActivity, double> >()
            .InstancePerLifetimeScope();
        }
Esempio n. 8
0
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        /// <param name="activity"></param>
        /// <returns></returns>
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            using (var connector = new ConnectorClient(new Uri(activity.ServiceUrl)))
            {
                var attributes = new LuisModelAttribute(ConfigurationManager.AppSettings["LuisId"], ConfigurationManager.AppSettings["LuisSubscriptionKey"]);
                var service    = new LuisService(attributes);

                switch (activity.Type)
                {
                case ActivityTypes.Message:
                    await Conversation.SendAsync(activity, () => new RootDialog(service));

                    break;

                case ActivityTypes.ConversationUpdate:
                    if (activity.MembersAdded.Any(o => o.Id == activity.Recipient.Id))
                    {
                        var reply = activity.CreateReply();
                        reply.Text = "Olá, eu sou o **Bot Inteligentão**. Curte ai o que eu posso fazer:\n" +
                                     "* **Descrever a capa de um livro**\n" +
                                     "* **Traduzir textos**\n" +
                                     "* **Recomendar liveos que eu gosto**\n" +
                                     "* **Recomendar liveos por categoria**\n";

                        await connector.Conversations.ReplyToActivityAsync(reply);
                    }
                    break;
                }
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
        }
Esempio n. 9
0
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            var conn = new ConnectorClient(new Uri(activity.ServiceUrl));

            var attributes = new LuisModelAttribute(
                ConfigurationManager.AppSettings["LuisId"],
                ConfigurationManager.AppSettings["LuisSubscriptionKey"]);
            var service = new LuisService(attributes);

            switch (activity.Type)
            {
            case ActivityTypes.Message:
                await Conversation.SendAsync(activity, () => new LuisTranslatorDialog(service));

                break;

            case ActivityTypes.ConversationUpdate:
                if (activity.MembersAdded.Any(o => o.Id == activity.Recipient.Id))
                {
                    var reply = activity.CreateReply();
                    reply.Text = "Olá, Eu sou o Bot Tranlator Unicorn que eu posso fazer é ** TRADUZIR ** algo e ** DESCREVER ** uma imagem de uma URL passada para você, e como a minha lingua nativa é o inglês, traduzir a descrição da imagem sem você solicitar.";

                    await conn.Conversations.ReplyToActivityAsync(reply);
                }
                break;
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Esempio n. 10
0
        private static ILuisService CreateLuisService()
        {
            string appId     = ConfigurationManager.AppSettings["LuisAppId"];
            string apiKey    = ConfigurationManager.AppSettings["LuisAPIKey"];
            var    luisModel = new LuisModelAttribute(appId, apiKey);

            return(new LuisService(luisModel));
        }
Esempio n. 11
0
        public RootDialog()
        {
            var settings = WebApiApplication.Container.GetInstance <ISettingsReader>();

            var luisModel = new LuisModelAttribute(settings["LUIS:Topics:AppId"], settings["LUIS:Topics:AppKey"]);

            _luisService = new LuisService(luisModel);
        }
Esempio n. 12
0
        public TripleDDialog(ILuisService service = null) : base(service)
        {
            var modelId         = ConfigurationManager.AppSettings.Get("LuisModelId");
            var subscriptionKey = ConfigurationManager.AppSettings.Get("LuisSubscriptionKey");
            var luisAttribute   = new LuisModelAttribute(modelId, subscriptionKey);

            service = new LuisService(luisAttribute);
        }
Esempio n. 13
0
 private static ILuisService GetLuisService()
 {
     var modelId = //Luis modelID;
     var subscriptionKey = //Luis subscription key
     var staging = //whether point to staging or production LUIS
     var luisModel = new LuisModelAttribute(modelId, subscriptionKey) { Staging = staging };
     return new LuisService(luisModel);
 }
        private static ILuisService[] GetNewService()
        {
            var modelId         = ConfigurationManager.AppSettings.Get("LuisModelID");
            var subscriptionKey = ConfigurationManager.AppSettings.Get("LuisSubscriptionKey");
            var luisModel       = new LuisModelAttribute(modelId, subscriptionKey);

            return(new ILuisService[] { new LuisService(luisModel) });
        }
Esempio n. 15
0
        static MessagesController()
        {
            var settings = new SettingsReader();
            var appId    = settings["LUIS:AppId"];
            var appKey   = settings["LUIS:AppKey"];
            var model    = new LuisModelAttribute(appId, appKey);

            _service = new LuisService(model);
        }
        private static ILuisService[] GetNewService()
        {
            var modelId         = ConfigurationManager.AppSettings.Get("LuisModelId");
            var subscriptionKey = ConfigurationManager.AppSettings.Get("LuisSubscriptionKey");
            var staging         = Convert.ToBoolean(ConfigurationManager.AppSettings.Get("LuisStaging") ?? "false");
            var luisModel       = new LuisModelAttribute(modelId, subscriptionKey, staging: staging);

            return(new ILuisService[] { new LuisService(luisModel) });
        }
Esempio n. 17
0
        private static ILuisService GetLuisService()
        {
            var appId  = ConfigurationManager.AppSettings["LuisAppId"];
            var apiKey = ConfigurationManager.AppSettings["LuisAPIKey"];

            var attribute = new LuisModelAttribute(appId, apiKey, threshold: SCORE_THRESHOLD);

            return(new LuisService(attribute));
        }
Esempio n. 18
0
        /// <summary>
        ///     Setup any values of the LuisModelAttribute that you cannot set in the constructor
        /// </summary>
        /// <returns>The LuisService to use in the base constructor of this LuisDialog</returns>
        public static LuisService SetupLuisService()
        {
            LuisModelAttribute attribute = new LuisModelAttribute(
                ConfigurationManager.AppSettings["LuisAppId"],
                ConfigurationManager.AppSettings["LuisAPIKey"],
                domain: ConfigurationManager.AppSettings["LuisAPIHostName"]);

            return(new LuisService(attribute));
        }
Esempio n. 19
0
        private static ILuisService[] GetNewService()
        {
            var modelId         = ConfigurationManager.AppSettings.Get("LuisModelId");
            var subscriptionKey = ConfigurationManager.AppSettings.Get("LuisSubscriptionKey");
            var domain          = ConfigurationManager.AppSettings.Get("LuisDomain");
            var luisModel       = new LuisModelAttribute(modelId, subscriptionKey, LuisApiVersion.V2, domain);

            return(new ILuisService[] { new LuisService(luisModel) });
        }
Esempio n. 20
0
        private static ILuisService[] GetNewService()
        {
            var modelId         = ConfigurationManager.AppSettings.Get("Luis.ModelId");
            var subscriptionKey = ConfigurationManager.AppSettings.Get("Luis.SubscriptionKey");
            var domain          = ConfigurationManager.AppSettings.Get("Luis.Domain");
            var luisModel       = new LuisModelAttribute(modelId, subscriptionKey, domain: string.IsNullOrEmpty(domain) ? null : domain);

            return(new ILuisService[] { new LuisService(luisModel) });
        }
Esempio n. 21
0
        private static LuisModelAttribute GetLuisModelAttribute()
        {
            var attribute = new LuisModelAttribute(
                ConfigurationManager.AppSettings["LuisAppId"],
                ConfigurationManager.AppSettings["LuisAPIKey"]);

            attribute.SpellCheck = true;
            attribute.BingSpellCheckSubscriptionKey = ConfigurationManager.AppSettings["BingSpellCheckAPIKey"];
            return(attribute);
        }
        private void ConfigureLuis(IWindsorContainer container, ISettingsReader settings)
        {
            var appId  = settings["LUIS:AppId"];
            var appKey = settings["LUIS:AppKey"];
            var model  = new LuisModelAttribute(appId, appKey);

            container.Register(Component.For <ILuisService>().ImplementedBy <LuisService>()
                               .DependsOn(Dependency.OnValue("model", model))
                               .LifestyleSingleton());
        }
Esempio n. 23
0
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            var culturaUI = Thread.CurrentThread.CurrentUICulture;
            var cultura   = Thread.CurrentThread.CurrentCulture;
            var connector = new ConnectorClient(new Uri(activity.ServiceUrl));

            //Configurar o EndPoint no LUIS
            var attributes = new LuisModelAttribute(
                ConfigurationManager.AppSettings["LuisId"],
                ConfigurationManager.AppSettings["LuisSubscriptionKey"]);
            var service = new LuisService(attributes);

            // codigo para a COTACAO
            if (activity.Type == ActivityTypes.Message)
            {
                //Colocar os '...' que está digitando
                var reply = activity.CreateReply();
                reply.Type = ActivityTypes.Typing;
                reply.Text = null;
                await connector.Conversations.ReplyToActivityAsync(reply);

                await Conversation.SendAsync(activity, () => new Dialogs.CotacaoDialog(service));
            }
            else
            {
                HandleSystemMessage(activity);
            }

            // codigo para o FORMULARIO
            //if (activity.Type == ActivityTypes.Message)
            //{
            //    await this.SendConversation(activity);
            //}
            //else if (activity.Type == ActivityTypes.ConversationUpdate)
            //{
            //    if (activity.MembersAdded != null && activity.MembersAdded.Any())
            //    {
            //        foreach (var member in activity.MembersAdded)
            //        {
            //            if (member.Id != activity.Recipient.Id)
            //            {
            //                await this.SendConversation(activity);
            //            }
            //        }
            //    }
            //}
            //else
            //{
            //    HandleSystemMessage(activity);
            //}

            var response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }
Esempio n. 24
0
        public static ILuisService CreateService(string serviceUrl)
        {
            var connector = new ConnectorClient(new Uri(serviceUrl));

            var attributes = new LuisModelAttribute(
                ConfigurationManager.AppSettings["LuisId"],
                ConfigurationManager.AppSettings["LuisSubscriptionKey"],
                LuisApiVersion.V2);

            return(new LuisService(attributes));
        }
        /// <summary>
        /// Create a LuisService using configuration settings.
        /// </summary>
        /// <param name="configuration">IConfiguration used to retrieve app settings for
        /// creating the LuisModelAttribute.</param>
        /// <returns>A LuisService constructed from configuration settings.</returns>
        static ILuisService GetLuisService(IConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var luisModel = new LuisModelAttribute(configuration["LuisModelId"], configuration["LuisSubscriptionKey"], domain: configuration["LuisHostDomain"]);

            return(new LuisService(luisModel));
        }
Esempio n. 26
0
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            var connector = new ConnectorClient(new Uri(activity.ServiceUrl));

            var attributes = new LuisModelAttribute(
                ConfigurationManager.AppSettings["LuisId"],
                ConfigurationManager.AppSettings["LuisSubscriptionKey"]);
            var service = new LuisService(attributes);

            switch (activity.Type)
            {
            case ActivityTypes.Message:
                if (activity.Attachments?.Any() == true)
                {
                    var reply      = activity.CreateReply();
                    var contentUrl = activity.Attachments[0].ContentUrl;

                    AnalyzeResult analyze = await new VisaoComputacionalService().AnaliseDetalhadaAsync(contentUrl, activity.ServiceUrl);

                    if (analyze.tags.Select(t => t.name).Contains("coffee") || analyze.tags.Select(t => t.name).Contains("cup") ||
                        analyze.description.captions.FirstOrDefault().text.Contains("coffee") ||
                        analyze.description.captions.FirstOrDefault().text.Contains("cup"))
                    {
                        reply.Text = "Pela foto entendo que você queira um café, estou certo?";
                    }
                    else
                    {
                        var description = analyze.description.captions.FirstOrDefault()?.text;
                        var confidence  = analyze.description.captions.FirstOrDefault()?.confidence *100;

                        reply.Text = $"Não achei nenhum café na sua foto, mas tenho {(int)confidence}% de certeza que isso é *{description}*";
                    }
                    await connector.Conversations.ReplyToActivityAsync(reply);
                }
                else
                {
                    await Conversation.SendAsync(activity, () => new LuisDialog(service, activity.ServiceUrl));
                }
                break;

            case ActivityTypes.ConversationUpdate:
                if (activity.MembersAdded.Any(o => o.Id == activity.Recipient.Id))
                {
                    var reply = activity.CreateReply();
                    reply.Text = "Olá, eu sou o **Coffee Bot**. Eu faço um café muito bom, qualquer dúvida é só me pedir **ajuda**";

                    await connector.Conversations.ReplyToActivityAsync(reply);
                }
                break;
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            switch (activity.GetActivityType())
            {
            // all messages pass through one dialog for now
            case ActivityTypes.Message:
                LuisModelAttribute attr    = new LuisModelAttribute(ConfigurationManager.AppSettings[Constants.LuisModelIdKey], ConfigurationManager.AppSettings[Constants.LuisSubscriptionKey]);
                LuisService        luisSvc = new LuisService(attr);
                await Conversation.SendAsync(activity, () => new GitHubLuisDialog(luisSvc));

                break;

            // send a "hello" to someone who just joined the conversation (not all channels support this)
            case ActivityTypes.ConversationUpdate:
                IConversationUpdateActivity update = activity;
                using (ILifetimeScope scope = DialogModule.BeginLifetimeScope(Conversation.Container, activity))
                {
                    IConnectorClient client = scope.Resolve <IConnectorClient>();
                    if (update.MembersAdded.Any())
                    {
                        Activity reply = activity.CreateReply();
                        IEnumerable <ChannelAccount> newMembers = update.MembersAdded?.Where(t => t.Id != activity.Recipient.Id);
                        foreach (var newMember in newMembers)
                        {
                            reply.Text = Constants.DemoText + $"Welcome {newMember.Name}! I can help you with getting information about your GitHub repos.";

                            IBotData data = scope.Resolve <IBotData>();
                            await data.LoadAsync(CancellationToken.None);

                            if (data.UserData.ContainsKey(Constants.AuthTokenKey))
                            {
                                reply.Text += " It looks like you're already logged in, so what can I help you with?";
                            }
                            else
                            {
                                reply.Text += " To get started, type **login** to authorize me to talk to GitHub on your behalf, or type **help** to get more information.";
                            }

                            await client.Conversations.ReplyToActivityAsync(reply);
                        }
                    }
                }
                break;
            }

            return(new HttpResponseMessage(HttpStatusCode.Accepted));
        }
Esempio n. 28
0
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            if (activity.Type == ActivityTypes.Message)
            {
                var attributes = new LuisModelAttribute(
                    ConfigurationManager.AppSettings["LUISModelID"],
                    ConfigurationManager.AppSettings["LUISSubscriptionKey"]);
                var service = new LuisService(attributes);
                await Conversation.SendAsync(activity, () => new MyFirstLuisDialog(service));
            }
            else
            {
                HandleSystemMessage(activity);
            }
            var response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            #region Register LUIS Dialog plus attributed, etc

            var luisModalAttr = new LuisModelAttribute(ConfigurationManager.AppSettings["luis:ModelId"],
                                                       ConfigurationManager.AppSettings["luis:SubscriptionId"],
                                                       LuisApiVersion.V2,
                                                       ConfigurationManager.AppSettings["luis:Domain"]
                                                       )
            {
                BingSpellCheckSubscriptionKey = ConfigurationManager.AppSettings["luis:BingSpellCheckSubScriptionId"],
                SpellCheck = true
            };

            builder.Register(c => luisModalAttr).AsSelf().AsImplementedInterfaces().SingleInstance();

            builder.Register(c => new MyLuisDialog(c.Resolve <ILuisService>(), c.Resolve <ILanguageUtilities>()))
            .As <MyLuisDialog>()
            .InstancePerDependency();

            builder.RegisterType <LuisService>()
            .Keyed <ILuisService>(FiberModule.Key_DoNotSerialize)
            .AsImplementedInterfaces()
            .SingleInstance();

            #endregion

            builder.Register(c => new RootDialog(c.Resolve <ILanguageUtilities>()))
            .As <RootDialog>()
            .InstancePerDependency();

            builder.RegisterType <LanguageUtilities>()
            .As <ILanguageUtilities>()
            .AsImplementedInterfaces()
            .SingleInstance();

            // replace the type ChannelSpecificMapper here with your class that implements IMessageActivityMapper
            builder.Register(c => new TranslatorMessageActivityMapper(c.Resolve <ILanguageUtilities>(), c.Resolve <IBotDataStore <BotData> >()))
            .As <IMessageActivityMapper>()
            .InstancePerLifetimeScope();
        }
Esempio n. 30
0
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            var connector = new ConnectorClient(new Uri(activity.ServiceUrl));

            var luisAttributes = new LuisModelAttribute(
                ConfigurationManager.AppSettings["LuisID"],
                ConfigurationManager.AppSettings["LuisSubscriptionKey"]);
            var luisService = new LuisService(luisAttributes);

            switch (activity.Type)
            {
            case ActivityTypes.Message:
                // If receive a start command from Telegram...
                if (activity.Text == "/start")
                {
                    var telegram = activity.CreateReply();
                    telegram.Text = "Olá, que bom ver você por aqui no Telegram!";

                    await connector.Conversations.ReplyToActivityAsync(telegram);

                    break;
                }
                // Send to Luis consideration...
                await Conversation.SendAsync(activity, () => new RootDialog(luisService));

                break;

            case ActivityTypes.ConversationUpdate:
                if (activity.MembersAdded.Any(o => o.Id == activity.Recipient.Id))
                {
                    var reply = activity.CreateReply();
                    reply.Text = "Olá, que bom ver você por aqui!";

                    await connector.Conversations.ReplyToActivityAsync(reply);
                }
                break;
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }