/// <summary>
        /// Called after the user has entered in the name of their preferred weather location.
        /// Searches for cities with that name.
        /// </summary>
        /// <param name="context">Mandatory. The context for the execution of a dialog's conversational process.</param>
        /// <param name="result">Mandatory. The name of the city the user wants to update as their preferred weather location. </param>
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            IMessageActivity cityChoice = await result;

            WeatherHelper weatherHelper = new WeatherHelper();
            City          extractedCity = weatherHelper.ExtractCityFromMessagePrompt(cityChoice.Text);

            _botDataService.setPreferredWeatherLocation(context, extractedCity);

            context.Done(extractedCity.Name);
        }
Example #2
0
        /// <summary>
        /// Method called after the user has selected a specific city from the HeroCard selection.
        /// </summary>
        /// <param name="context">Mandatory. The context for the execution of a dialog's conversational process.</param>
        /// <param name="result">Mandatory. The specific city the user wants the weather for.</param>
        private async Task ResumeAfterHeroCardCitySelect(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            var message = await result;

            WeatherHelper weatherHelper = new WeatherHelper();
            City          city          = weatherHelper.ExtractCityFromMessagePrompt(message.Text);

            var weatherForecast = await _weatherService.GetWeather(city);

            context.Done(weatherForecast != string.Empty
                ? $"Currently the weather in {message.Text} is {weatherForecast}"
                : "🤧⛅ - I'm having trouble accessing weather reports. We'll have to try again later!");
        }