public static async Task Run(payload flightStatusQueue, TraceWriter log)
        {
            log.Info($"Starting to retrieve flight info for {flightStatusQueue.Text}.");

            string flightNumber = flightStatusQueue.Text.ToUpper();
            string airlineIata  = flightNumber.Substring(0, 2);

            //convert the airline's IATA code to ICAO
            var        uri    = "http://avcodes.co.uk/airlcoderes.asp";
            HttpClient client = new HttpClient();
            var        values = new Dictionary <string, string>
            {
                { "status", "Y" },
                { "iataairl", airlineIata }
            };

            var content = new FormUrlEncodedContent(values);

            var response = await client.PostAsync(uri, content);

            var    responseContent = response.Content;
            string result          = null;

            using (var reader = new StreamReader(await responseContent.ReadAsStreamAsync()))
            {
                result = await reader.ReadToEndAsync();
            }

            var regex   = new Regex(@"ICAO Code:<br />&nbsp;\D{3}");
            var matches = regex.Matches(result);

            string icaoCode = $"{(matches[0].Value).Split(';')[1].Substring(0, 3)}";

            log.Info(icaoCode);

            // get the flight number from the input string
            string flightno = flightNumber.Substring(2);
            Int32  today    = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            Int32  tomorrow = (Int32)(DateTime.UtcNow.AddDays(1).Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            var uriAirlineFlightSchedules =
                $"https://flightxml.flightaware.com/json/FlightXML2/AirlineFlightSchedules?startDate={today}&endDate={tomorrow}&airline={icaoCode}&flightno={flightno}";

            string airlineFlightSchedules = await GenericHelper.FlightAwareGet(uriAirlineFlightSchedules);

            log.Info(airlineFlightSchedules);
            JObject jsonAirlineFlightSchedules    = JObject.Parse(airlineFlightSchedules);
            JArray  airlineFlightSchedulesResults = jsonAirlineFlightSchedules["AirlineFlightSchedulesResult"]
                                                    .SelectToken("data")
                                                    .Value <JArray>();
            JArray actualFlights = Flights.FilterFlights(airlineFlightSchedulesResults, $"{icaoCode}{flightno}");

            foreach (JToken flight in actualFlights)
            {
                string flightident =
                    $"{icaoCode}{flightno}@{flight.SelectToken("departuretime").Value<string>()}";
                var uriFlightInfoEx =
                    $"https://flightxml.flightaware.com/json/FlightXML2/FlightInfoEx?ident={flightident}&howMany=2";
                string flightInfoExs = await GenericHelper.FlightAwareGet(uriFlightInfoEx);

                JObject jsonFlightInfoEx = JObject.Parse(flightInfoExs);
                JArray  flightInfo       = jsonFlightInfoEx["FlightInfoExResult"].SelectToken("flights").Value <JArray>();
                string  faFlightId       = flightInfo[0].SelectToken("faFlightID").Value <string>();
                string  flightIdent      = flight.SelectToken("ident").Value <string>();
                string  origin           = flight.SelectToken("origin").Value <string>();
                string  destination      = flight.SelectToken("destination").Value <string>();
                string  typeOfAircraft   = flight.SelectToken("aircrafttype").Value <string>();
                string  route            = null;
                ;
                if (flight.SelectToken("route").IsNullOrEmpty())
                {
                    route = "Route not provided";
                }
                else
                {
                    route = flight.SelectToken("route").Value <string>();
                }

                var uriAirlineFlightInfo =
                    $"https://flightxml.flightaware.com/json/FlightXML2/AirlineFlightInfo?faFlightID={faFlightId}";
                string airlineFlightInfo = await GenericHelper.FlightAwareGet(uriAirlineFlightInfo);

                JObject jsonAirlineFlightInfo = JObject.Parse(airlineFlightInfo);
                JObject arrAirlineFlightInfo  = jsonAirlineFlightInfo["AirlineFlightInfoResult"].Value <JObject>();

                DateTime filedDepartureTime   = GenericHelper.FromUnixTime(flightInfo[0].SelectToken("filed_departuretime").Value <long>());
                DateTime estimatedArrivalTime =
                    GenericHelper.FromUnixTime(flightInfo[0].SelectToken("estimatedarrivaltime").Value <long>());
                string   estimatedTimeEnroute         = flightInfo[0].SelectToken("filed_ete").Value <string>();
                TimeSpan estimatedTimeEnrouteTimeSpan = TimeSpan.Parse(estimatedTimeEnroute);

                DateTime estimatedDepartureTime = estimatedArrivalTime.Add(-estimatedTimeEnrouteTimeSpan);
                TimeSpan delay = estimatedDepartureTime - filedDepartureTime;

                var slackResponseUri = HttpUtility.UrlDecode(flightStatusQueue.Response_Url);
                //{GenericHelper.ConvertFromUtcToLocal(GenericHelper.FromUnixTime(flightInfo[0].SelectToken("filed_departuretime").Value<long>()))}"
                // if you haven't set your Azure Web App time zone
                var jsonPayload = new
                {
                    text =
                        $"*{flightStatusQueue.User_Name} here is your flight info for Flight # {icaoCode}{flightno} / {flightIdent}* \n" +
                        $"From = {origin} / {flightInfo[0].SelectToken("originName").Value<string>()}\n" +
                        $"To = {destination} / {flightInfo[0].SelectToken("destinationName").Value<string>()} \n" +
                        $"Type of Aircraft = {typeOfAircraft} \n" +
                        $"Filed Departure time = {GenericHelper.FromUnixTime(flightInfo[0].SelectToken("filed_departuretime").Value<long>())} \n" +
                        $"Estimated Departure time = {estimatedDepartureTime} \n" +
                        $"Estimated Arrival time = {GenericHelper.FromUnixTime(flightInfo[0].SelectToken("estimatedarrivaltime").Value<long>())} \n" +
                        $"Current delay = {delay} \n" +
                        $"Estimated Flight time = {estimatedTimeEnroute} \n" +
                        $"Filed route = {route} \n" +
                        $"Departure Terminal = {arrAirlineFlightInfo.SelectToken("terminal_orig").Value<string>()} \n" +
                        $"Departure Gate = {arrAirlineFlightInfo.SelectToken("gate_orig").Value<string>()} "
                };

                GenericHelper.SendMessageToSlack(slackResponseUri, jsonPayload);
                log.Info(jsonPayload.ToString());
            }
        }