title: Bot Framework Context.Wait does not wait for input
body: <p>I have three dialog that works as explained below</p>
  
  <p>I have a Receipt Dialog, but when the dialog is called it first goes to Onboarding dialog to check if the user has onboarded if the user has to onboarded it start the onboarding process, and then calls an OTP Dialog to complete the transcation. But when it gets to the OTP Dialog it does not wait for the user to enter the generated token.</p>
  
  <p>Below is the code</p>
  
  <p>OnBoarding Dialog</p>
  
  <pre><code>    private async Task AccountNumberEnteredAsync(IDialogContext context, IAwaitable&lt;object&gt; result)
      {
          try
          {
              if (await result is IMessageActivity resp)
              {
                  var userID = context.Activity.From.Id;
                  var channelID = context.Activity.ChannelId;
  
                  var customerEnquiry = DialogFactory.Create&lt;ICustomerEnquiry&gt;();
                  string phoneNum = await customerEnquiry.GetCustomerPhoneNumberAsync(resp.Text);
  
                  context.PrivateConversationData.SetValue(StringConstants.TEMP_ACCOUNT_NUMBER, resp.Text);
                  context.PrivateConversationData.SetValue(StringConstants.PHONE_NUMBER, phoneNum);
                  context.Call(DialogFactory.Create&lt;OTPDialog&gt;(), ResumeAfterOTPAsync);
              }
          }
          catch (Exception ex)
          {
              Telemetry.TrackException(ex);
              await context.PostAsync(L("FORM_ERROR"));
              context.Done(false);
          }
      }
  </code></pre>
  
  <p>OTP Dialog</p>
  
  <pre><code>    private async Task InitiateOTP(IDialogContext context)
      {
          try
          {
              if (!context.UserData.TryGetValue(StringConstants.USER_OTP_KEY, out this.secret))
              {
                  var username = context.UserData.GetValueOrDefault&lt;string&gt;(StringConstants.ACCESS_MOBILE_USERNAME);
                  context.Fail(new AppException(L("OTPGENERATIONERROR", new object[] { username })));
              }
              else
              {
                  context.PrivateConversationData.TryGetValue(StringConstants.PHONE_NUMBER, out string phoneNum);
                  var otp = await TwoFactorAuth.GetOTPAsync(this.secret);
                  await SendTokenSMSAsync(otp, new List&lt;string&gt;() { phoneNum });
                  await context.PostAsync(L("OTP_SENT_MESSAGE") + " " + otp);
                  context.Wait(this.OTPEnteredAsync);
              }
          }
          catch (TooManyAttemptsException ex)
          {
              Telemetry.TrackException(ex);
              await context.PostAsync(L("HERO_CARD_TRIALS_EXCEEDED"));
              context.Done(false);
          }
          catch (InvalidOperationException ex)
          {
              Telemetry.TrackException(ex);
              await context.PostAsync(L("FORM_ERROR"));
              context.Done(false);
          }
          finally
          {
              Telemetry.TrackTrace(nameof(StartAsync));
          }
      }
  </code></pre>
  
  <p>Resumed after OTP has been entered (but it does not wait for the user to enter OTP)</p>
  
  <pre><code>     private async Task OTPEnteredAsync(IDialogContext context, IAwaitable&lt;object&gt; result)
      {
          try
          {
              var response = await result as Activity;
              var yesy = await result;
  
              if (response != null &amp;&amp; !string.IsNullOrEmpty(response.Text) &amp;&amp; response.Text.Equals(RESEND, StringComparison.InvariantCultureIgnoreCase))
              {
                  context.PrivateConversationData.TryGetValue(StringConstants.PHONE_NUMBER, out string phoneNum);
                  var otp = await TwoFactorAuth.GetOTPAsync(this.secret);
                  await SendTokenSMSAsync(otp, new List&lt;string&gt;() { phoneNum });
                  await context.PostAsync(L("OTP_SENT_MESSAGE"));
                  context.Wait(OTPEnteredAsync);
              }
              else
              {
                  if (response != null &amp;&amp;  !response.Text.IsNullOrEmpty())
                  {
                      var isValidated = await TwoFactorAuth.ValidateOTPAsync(this.secret, response.Text);
  
                      if (!isValidated &amp;&amp; authTrialCount++ &lt; int.Parse(await SettingManager.GetSettingValueAsync(BotEngineConsts.SettingNames.AuthTrialLimit)))
                      {
                          await context.PostAsync(L("OTP_INVALID"));
                          context.Wait(OTPEnteredAsync);
                      }
                      else
                      {
                          context.Done(isValidated);
                      } 
                  }
                  else
                  {
                      context.Wait(OTPEnteredAsync);
                  }
              }
          }
          catch (Exception ex)
          {
  
              throw;
          }
  
          context.Wait(OTPEnteredAsync);
      }
  </code></pre>
  
  <p>How do i make it wait for the user to enter OTP before continuing. Am Makeing use of Autofac for DI</p>