private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result) { var message = await result; if (message.Value != null && message.Value.ToString().Trim().Length > 0) { // Cancel appointment var obj = JsonConvert.DeserializeObject <Appointment>(message.Value.ToString()); AppointmentData.CancelAppointment(obj); await context.PostAsync("Appointment cancelled for the date : " + obj.AppointmentDateTime.ToString(DateTimeFormatInfo.InvariantInfo)); context.Done("Cancelled Appointment"); } else if (SelectedOption != null && SelectedOption.Trim().Length > 0) { await HandleAppointment(context, SelectedOption); } else { await context.PostAsync("Getting patient details"); context.Wait(this.MessageReceivedAsync); } }