Beispiel #1
0
        public async Task <string> ResolveMessage(Activity activity)
        {
            var messageString = "";

            if (activity.Type == ActivityTypes.Message)
            {
                messageString = "Sorry, I am not getting you...";

                var entity = await _luisService.GetEntity(activity.Text);

                if (entity.intents.Any())
                {
                    switch (entity.intents[0].intent)
                    {
                    case "Introduction":
                        messageString = await _messagesService.CreateIntroMessage();

                        break;

                    case "CountPackages":
                        var packageListCount = await _packagesService.GetPackages();

                        messageString = await _messagesService.CreateCountPackagesMessage(packageListCount);

                        break;

                    case "ListPackages":
                        var packageList = await _packagesService.GetPackages();

                        messageString = await _messagesService.CreateListPackagesMessage(packageList);

                        break;

                    case "SearchPackage":
                        if (!entity.entities.Any())
                        {
                            break;
                        }

                        var package = await _packagesService.GetPackage(entity.entities[0].entity);

                        messageString = await _messagesService.CreatePackageMessage(package);

                        break;

                    default:
                        messageString = "Sorry, I am not getting you...";

                        break;
                    }
                }
            }
            else
            {
                await _messagesService.HandleSystemMessage(activity);
            }

            return(messageString);
        }