public static async Task SearchSessionsAndPostResults(IDialogContext context, SessionSelectionOptions state)
        {
            string message = "Sorry, I can't understand what type of session you're looking for.";

            var speakerName = state.SpeakerName == null ? null : new string[] { state.SpeakerName };

            var topic       = CodeCamp.Topics.Where(t => t.Name.Equals(state.Topic, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
            var topicValues = (topic == null ?
                               String.IsNullOrWhiteSpace(state.Topic) ? null : new string[] { state.Topic }
                                : topic.Terms);

            // perform the session search
            var sessions = CodeCamp.FindSessions(speakerName, topicValues, state.CompanyName, state.Level).ToArray();

            if (sessions.Count() > 0)
            {
                message  = $"I've found some sessions.\n";
                message += GetSessionsListDisplayMessage(sessions);
                message += $"To see more details about a session, type its number.\nOr, type **add n** to add the session at index **n** to your schedule.";

                // save info about sessions
                context.ConversationData.SetValue("sessionsList", sessions.Select(s => s.Id).ToArray());
            }
            else
            {
                message = $"Sorry, I can't find any sessions of interest for you.";
            }
            await context.PostAsync(message);
        }
        public async Task FindSession(IDialogContext context, LuisResult result)
        {
            var entity = result.Entities.FirstOrDefault();

            if (entity != null)
            {
                switch (entity.Type)
                {
                case "Speaker":
                    var speakerName = entity.Entity;
                    var speakers    = CodeCamp.FindSpeakers(speakerName);
                    switch (speakers.Count())
                    {
                    case 0:
                        await context.PostAsync($"Sorry, I can't find any speakers named {speakerName}.");

                        context.Wait(MessageReceived);
                        break;

                    case 1:
                        await SessionSelectionOptions.SearchSessionsAndPostResults(
                            context, new SessionSelectionOptions()
                        {
                            SpeakerName = speakerName
                        });

                        context.Wait(MessageReceived);
                        break;

                    default:
                        await context.PostAsync($"I've found {speakers.Count()} speakers named {speakerName}.");

                        var options1 = new SessionSelectionOptions()
                        {
                            CandidateSpeakers = speakers.ToArray()
                        };
                        var sessionDialog1 = new FormDialog <SessionSelectionOptions>(
                            options1,
                            SessionSelectionOptions.BuildFormForSpeakerDisambiguation,
                            FormOptions.PromptInStart
                            );

                        context.Call(sessionDialog1, SearchFormComplete);

                        break;
                    }

                    break;

                case "Topic":
                    var topic   = entity.Entity;
                    var options = new SessionSelectionOptions()
                    {
                        Topic = topic
                    };
                    var sessionDialog = new FormDialog <SessionSelectionOptions>(
                        options,
                        SessionSelectionOptions.BuildFormForGeneralSearch,
                        FormOptions.PromptInStart
                        );

                    context.Call(sessionDialog, SearchFormComplete);

                    break;

                case "Company":
                    var company = entity.Entity;

                    await SessionSelectionOptions.SearchSessionsAndPostResults(
                        context, new SessionSelectionOptions()
                    {
                        CompanyName = company
                    });

                    context.Wait(MessageReceived);

                    break;

                default:
                    await context.PostAsync("Sorry, I can't understand what type of session you're looking for.");

                    context.Wait(MessageReceived);
                    break;
                }
            }
            else
            {
                // general session search
                var options       = new SessionSelectionOptions();
                var sessionDialog = new FormDialog <SessionSelectionOptions>(
                    options,
                    SessionSelectionOptions.BuildFormForGeneralSearch,
                    FormOptions.PromptInStart
                    );

                context.Call(sessionDialog, SearchFormComplete);
            }
        }