Пример #1
0
        public async Task GetSpaPlaces(IDialogContext context, IAwaitable <string> result)
        {
            var selectedCard = await result;
            var type         = "";
            await context.PostAsync("You have selected " + selectedCard);

            switch (selectedCard)
            {
            case BeautyParlour:
                type = "beauty parlours";
                break;

            case Salons:
                type = "salons";
                break;

            case Gym:
                type = "gyms";
                break;
            }
            TextSearch ts         = new TextSearch();
            var        attachment = ts.makeRequest(placename, type);
            Activity   msg        = (Activity)context.MakeMessage();

            msg.Recipient        = msg.Recipient;
            msg.Type             = "message";
            msg.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            msg.Attachments      = attachment;
            await context.PostAsync(msg);

            context.Wait(MessageReceived);
        }
Пример #2
0
        public async Task GetDevotionalPlaces(IDialogContext context, IAwaitable <string> result)
        {
            var selectedCard = await result;
            var type         = "";
            await context.PostAsync("You have selected " + selectedCard);

            switch (selectedCard)
            {
            case Temples: type = "temple";
                break;

            case Churches: type = "church";
                break;

            case Mosques: type = "mosque";
                break;
            }
            TextSearch ts         = new TextSearch();
            var        attachment = ts.makeRequest(placename, type);
            Activity   msg        = (Activity)context.MakeMessage();

            msg.Recipient        = msg.Recipient;
            msg.Type             = "message";
            msg.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            msg.Attachments      = attachment;
            await context.PostAsync(msg);

            context.Wait(MessageReceived);
        }
Пример #3
0
        public async Task SuggestPlaces(IDialogContext context, LuisResult result)
        {
            if (placename != "" && category != "")
            {
                TextSearch ts          = new TextSearch();
                var        attachments = ts.makeRequest(placename, category);
                if (attachments.Count == 0)
                {
                    context.PostAsync("Sorry!!! No " + category + " available..." + Environment.NewLine + Environment.NewLine +
                                      "You can try some of these...");
                    PromptCategories(context, result);
                    return;
                }

                Activity msg = (Activity)context.MakeMessage();
                msg.Recipient        = msg.Recipient;
                msg.Type             = "message";
                msg.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                msg.Attachments      = attachments;

                await context.PostAsync(msg);
            }
            else if (placename != "" && category == "")
            {
                PromptCategories(context, result);
                return;
            }
            else
            {
                await context.PostAsync("Please enter your place");
            }
            context.Wait(MessageReceived);
        }
Пример #4
0
        public async Task DisplaySelectedCard(IDialogContext context, IAwaitable <string> result)
        {
            var selectedCard = await result;
            var type         = "";
            await context.PostAsync("You have selected " + selectedCard);

            switch (selectedCard)
            {
            case DevotionalPlaces: DevotionalPrompt(context);
                break;

            case Education: EducationPrompt(context);
                break;

            case Shopping: ShoppingPrompt(context);
                break;

            case Spa: SpaPrompt(context);
                break;

            case TouristPlaces: TourismPrompt(context);
                break;

            case FoodCourts:
                TextSearch ts         = new TextSearch();
                var        attachment = ts.makeRequest(placename, "restaurants");
                Activity   msg        = (Activity)context.MakeMessage();
                msg.Recipient        = msg.Recipient;
                msg.Type             = "message";
                msg.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                msg.Attachments      = attachment;
                await context.PostAsync(msg);

                context.Wait(MessageReceived);
                break;

            case Hospitals:
                TextSearch tsh         = new TextSearch();
                var        attachmenth = tsh.makeRequest(placename, "hospitals");
                Activity   msgh        = (Activity)context.MakeMessage();
                msgh.Recipient        = msgh.Recipient;
                msgh.Type             = "message";
                msgh.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                msgh.Attachments      = attachmenth;
                await context.PostAsync(msgh);

                context.Wait(MessageReceived);
                break;
            }
            //context.Wait(MessageReceived);
        }
Пример #5
0
        public async Task GetEducationPlaces(IDialogContext context, IAwaitable <string> result)
        {
            var selectedCard = await result;
            var type         = "";
            await context.PostAsync("You have selected " + selectedCard);

            switch (selectedCard)
            {
            case Schools:
                type = "schools";
                break;

            case Inter:
                type = "intermediate colleges";
                break;

            case Engineering:
                type = "engineering colleges";
                break;

            case Medical:
                type = "medical colleges";
                break;

            case Polytechnic:
                type = "polytehnic colleges";
                break;

            case Library:
                type = "libraries";
                break;

            case BookStores:
                type = "book stores";
                break;
            }
            TextSearch ts         = new TextSearch();
            var        attachment = ts.makeRequest(placename, type);
            Activity   msg        = (Activity)context.MakeMessage();

            msg.Recipient        = msg.Recipient;
            msg.Type             = "message";
            msg.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            msg.Attachments      = attachment;
            await context.PostAsync(msg);

            context.Wait(MessageReceived);
        }
Пример #6
0
        public async Task GetTourismPlaces(IDialogContext context, IAwaitable <string> result)
        {
            var selectedCard = await result;
            var type         = "";
            await context.PostAsync("You have selected " + selectedCard);

            switch (selectedCard)
            {
            case Museums:
                type = "museums";
                break;

            case Zoos:
                type = "zoos";
                break;

            case ArtGalleries:
                type = "art galleries";
                break;

            case Parks:
                type = "parks";
                break;

            case Resorts:
                type = "resorts";
                break;

            case FamousPlaces:
                type = "famous places";
                break;
            }
            TextSearch ts         = new TextSearch();
            var        attachment = ts.makeRequest(placename, type);
            Activity   msg        = (Activity)context.MakeMessage();

            msg.Recipient        = msg.Recipient;
            msg.Type             = "message";
            msg.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            msg.Attachments      = attachment;
            await context.PostAsync(msg);

            context.Wait(MessageReceived);
        }
Пример #7
0
 public Attachment displayPlaceDetails(string placeName)
 {
     System.Diagnostics.Debug.WriteLine(placeName);
     Random rnd = new Random();
     int rk = rnd.Next(keys.Count);
     string key = keys[rk];
     List<string> initialDetails = new List<string>();
     TextSearch ts = new TextSearch();
     initialDetails = ts.searchPlace(placeName);
     System.Diagnostics.Debug.WriteLine(placeName);
     string placeId = initialDetails[0];
     placeName = initialDetails[1];
     System.Diagnostics.Debug.WriteLine(placeName);
     string address = initialDetails[2];
     string photoRef = "https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&key=" + key +"&photoreference=" + initialDetails[3];
     makeRequest(placeId);
     CardImage cardImage = new CardImage(url: photoRef);
     CardAction cardButton = new CardAction(ActionTypes.OpenUrl, " Get directions to visit place ", value: url);
     Attachment detailsCard = GetHeroCard(placeName, "CONTACT NUMBER : " + phoneNum, address, cardImage, cardButton);
     return detailsCard;
 }
Пример #8
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)
            {
                ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
                Activity        reply     = activity.CreateReply($"");
                Activity        reply1    = activity.CreateReply($"");
                if (activity.Text.Contains("Place Id : "))
                {
                    var        place_id = activity.Text.ToString().Substring(11, activity.Text.ToString().Length - 11);
                    int        index    = (int)Char.GetNumericValue(place_id[0]);
                    TextSearch ts       = new TextSearch();

                    string       refe       = ts.getReference(index);
                    PlaceDetails pd         = new PlaceDetails();
                    Attachment   attachment = pd.makeCard(refe, place_id.Substring(1, place_id.Length - 1));
                    reply.Attachments = new List <Attachment>();
                    reply.Attachments.Add(attachment);
                    await connector.Conversations.ReplyToActivityAsync(reply);

                    string review = pd.GetReviews(place_id.Substring(1, place_id.Length - 1));
                    reply1 = activity.CreateReply($"" + review);
                    await connector.Conversations.ReplyToActivityAsync(reply1);

                    var res = Request.CreateResponse(HttpStatusCode.OK);
                    return(res);
                }

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

            return(response);
        }
Пример #9
0
        public async Task GetShoppingPlaces(IDialogContext context, IAwaitable <string> result)
        {
            var selectedCard = await result;
            var type         = "";
            await context.PostAsync("You have selected " + selectedCard);

            switch (selectedCard)
            {
            case ShoppingMalls:
                type = "shopping malls";
                break;

            case JewelryStores:
                type = "jewelry stores";
                break;

            case MobileStores:
                type = "mobile stores";
                break;

            case CarLeasing:
                type = "car leasing";
                break;
            }
            TextSearch ts         = new TextSearch();
            var        attachment = ts.makeRequest(placename, type);
            Activity   msg        = (Activity)context.MakeMessage();

            msg.Recipient        = msg.Recipient;
            msg.Type             = "message";
            msg.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            msg.Attachments      = attachment;
            await context.PostAsync(msg);

            context.Wait(MessageReceived);
        }