prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  NumberPrompt doesn't accept retry value
  ## Version
  v4.5
  
  ## Describe the bug
  When you send an invalid number to a `NumberPrompt`, it sends out a retry prompt.
  When attempting to send a 2nd response after being reprompted, you get a timeout error.
  
  
  
  ## To Reproduce
  1. Create a `NumberPrompt` object
  2. When it prompts you for a number, send in a non-numeric value (e.g. `"hello"`)
      * this will trigger a retry prompt (e.g. `"You must enter a number."`)
  3. Try sending in another value--no matter what type of value, you get a timeout error
  
  ![image](https://user-images.githubusercontent.com/35248895/62598200-7000fd00-b89d-11e9-9b02-cc04beb609d4.png)
  
  ![image](https://user-images.githubusercontent.com/35248895/62598223-8444fa00-b89d-11e9-918b-8578efd179ac.png)
  
  
  
  
  ## Expected behavior
  To be able to send in a 2nd value when reprompted
  
  ## Additional context
  ```python
  async def test_number_prompt_retry(self):
          async def exec_test(turn_context: TurnContext) -> None:
              dialog_context: DialogContext = await dialogs.create_context(turn_context)
  
              results: DialogTurnResult = await dialog_context.continue_dialog()
  
              if results.status == DialogTurnStatus.Empty:
                  options = PromptOptions(
                      prompt=Activity(type=ActivityTypes.message, text="Enter a number."),
                      retry_prompt=Activity(
                          type=ActivityTypes.message, text="You must enter a number."
                      ),
                  )
                  await dialog_context.prompt("NumberPrompt", options)
              elif results.status == DialogTurnStatus.Complete:
                  number_result = results.result
                  await turn_context.send_activity(
                      MessageFactory.text(f"Bot received the number '{number_result}'.")
                  )
  
              await convo_state.save_changes(turn_context)
  
          adapter = TestAdapter(exec_test)
  
          convo_state = ConversationState(MemoryStorage())
          dialog_state = convo_state.create_property("dialogState")
          dialogs = DialogSet(dialog_state)
          number_prompt = NumberPrompt(
              dialog_id="NumberPrompt", validator=None, default_locale=Culture.English
          )
          dialogs.add(number_prompt)
  
          step1 = await adapter.send("hello")
          step2 = await step1.assert_reply("Enter a number.")
          # TODO: something is breaking in the validators or retry prompt
          # where it does not accept the 2nd answer after reprompting the user
          # for another value
          step3 = await step2.send("hello")
          step4 = await step3.assert_reply("You must enter a number.")
          step5 = await step4.send("64")
          await step5.assert_reply("Bot received the number '64'.")
  ```
  
  [bug]
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/number_prompt.py`
  Content:
  ```
  1 # Copyright (c) Microsoft Corporation. All rights reserved.
  2 # Licensed under the MIT License.
  3 
  4 from typing import Callable, Dict
  5 
  6 from recognizers_number import recognize_number
  7 from recognizers_text import Culture, ModelResult
  8 from babel.numbers import parse_decimal
  9 
  10 from botbuilder.core.turn_context import TurnContext
  11 from botbuilder.schema import ActivityTypes
  12 
  13 from .prompt import Prompt, PromptValidatorContext
  14 from .prompt_options import PromptOptions
  15 from .prompt_recognizer_result import PromptRecognizerResult
  16 
  17 
  18 class NumberPrompt(Prompt):
  19     # TODO: PromptValidator needs to be fixed
  20     # Does not accept answer as intended (times out)
  21     def __init__(
  22         self,
  23         dialog_id: str,
  24         validator: Callable[[PromptValidatorContext], bool] = None,
  25         default_locale: str = None,
  26     ):
  27         super(NumberPrompt, self).__init__(dialog_id, validator)
  28         self.default_locale = default_locale
  29 
  30     async def on_prompt(
  31         self,
  32         turn_context: TurnContext,
  33         state: Dict[str, object],
  34         options: PromptOptions,
  35         is_retry: bool,
  36     ):
  37         if not turn_context:
  38             raise TypeError("NumberPrompt.on_prompt(): turn_context cannot be None.")
  39         if not options:
  40             raise TypeError("NumberPrompt.on_prompt(): options cannot be None.")
  41 
  42         if is_retry and options.retry_prompt is not None:
  43             turn_context.send_activity(options.retry_prompt)
  44         elif options.prompt is not None:
  45             await turn_context.send_activity(options.prompt)
  46 
  47     async def on_recognize(
  48         self,
  49         turn_context: TurnContext,
  50         state: Dict[str, object],
  51         options: PromptOptions,
  52     ) -> PromptRecognizerResult:
  53         if not turn_context:
  54             raise TypeError("NumberPrompt.on_recognize(): turn_context cannot be None.")
  55 
  56         result = PromptRecognizerResult()
  57         if turn_context.activity.type == ActivityTypes.message:
  58             message = turn_context.activity
  59             culture = self._get_culture(turn_context)
  60             results: [ModelResult] = recognize_number(message.text, culture)
  61 
  62             if results:
  63                 result.succeeded = True
  64                 result.value = parse_decimal(
  65                     results[0].resolution["value"], locale=culture.replace("-", "_")
  66                 )
  67 
  68         return result
  69 
  70     def _get_culture(self, turn_context: TurnContext):
  71         culture = (
  72             turn_context.activity.locale
  73             if turn_context.activity.locale
  74             else self.default_locale
  75         )
  76 
  77         if not culture:
  78             culture = Culture.English
  79 
  80         return culture
  81
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/number_prompt.py b/libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/number_prompt.py
  --- a/libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/number_prompt.py
  +++ b/libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/number_prompt.py
  @@ -40,7 +40,7 @@
               raise TypeError("NumberPrompt.on_prompt(): options cannot be None.")
   
           if is_retry and options.retry_prompt is not None:
  -            turn_context.send_activity(options.retry_prompt)
  +            await turn_context.send_activity(options.retry_prompt)
           elif options.prompt is not None:
               await turn_context.send_activity(options.prompt)
  
verification_info: {"golden_diff": "diff --git a/libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/number_prompt.py b/libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/number_prompt.py\n--- a/libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/number_prompt.py\n+++ b/libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/number_prompt.py\n@@ -40,7 +40,7 @@\n             raise TypeError(\"NumberPrompt.on_prompt(): options cannot be None.\")\n \n         if is_retry and options.retry_prompt is not None:\n-            turn_context.send_activity(options.retry_prompt)\n+            await turn_context.send_activity(options.retry_prompt)\n         elif options.prompt is not None:\n             await turn_context.send_activity(options.prompt)\n", "issue": "NumberPrompt doesn't accept retry value\n## Version\r\nv4.5\r\n\r\n## Describe the bug\r\nWhen you send an invalid number to a `NumberPrompt`, it sends out a retry prompt.\r\nWhen attempting to send a 2nd response after being reprompted, you get a timeout error.\r\n\r\n\r\n\r\n## To Reproduce\r\n1. Create a `NumberPrompt` object\r\n2. When it prompts you for a number, send in a non-numeric value (e.g. `\"hello\"`)\r\n    * this will trigger a retry prompt (e.g. `\"You must enter a number.\"`)\r\n3. Try sending in another value--no matter what type of value, you get a timeout error\r\n\r\n![image](https://user-images.githubusercontent.com/35248895/62598200-7000fd00-b89d-11e9-9b02-cc04beb609d4.png)\r\n\r\n![image](https://user-images.githubusercontent.com/35248895/62598223-8444fa00-b89d-11e9-918b-8578efd179ac.png)\r\n\r\n\r\n\r\n\r\n## Expected behavior\r\nTo be able to send in a 2nd value when reprompted\r\n\r\n## Additional context\r\n```python\r\nasync def test_number_prompt_retry(self):\r\n        async def exec_test(turn_context: TurnContext) -> None:\r\n            dialog_context: DialogContext = await dialogs.create_context(turn_context)\r\n\r\n            results: DialogTurnResult = await dialog_context.continue_dialog()\r\n\r\n            if results.status == DialogTurnStatus.Empty:\r\n                options = PromptOptions(\r\n                    prompt=Activity(type=ActivityTypes.message, text=\"Enter a number.\"),\r\n                    retry_prompt=Activity(\r\n                        type=ActivityTypes.message, text=\"You must enter a number.\"\r\n                    ),\r\n                )\r\n                await dialog_context.prompt(\"NumberPrompt\", options)\r\n            elif results.status == DialogTurnStatus.Complete:\r\n                number_result = results.result\r\n                await turn_context.send_activity(\r\n                    MessageFactory.text(f\"Bot received the number '{number_result}'.\")\r\n                )\r\n\r\n            await convo_state.save_changes(turn_context)\r\n\r\n        adapter = TestAdapter(exec_test)\r\n\r\n        convo_state = ConversationState(MemoryStorage())\r\n        dialog_state = convo_state.create_property(\"dialogState\")\r\n        dialogs = DialogSet(dialog_state)\r\n        number_prompt = NumberPrompt(\r\n            dialog_id=\"NumberPrompt\", validator=None, default_locale=Culture.English\r\n        )\r\n        dialogs.add(number_prompt)\r\n\r\n        step1 = await adapter.send(\"hello\")\r\n        step2 = await step1.assert_reply(\"Enter a number.\")\r\n        # TODO: something is breaking in the validators or retry prompt\r\n        # where it does not accept the 2nd answer after reprompting the user\r\n        # for another value\r\n        step3 = await step2.send(\"hello\")\r\n        step4 = await step3.assert_reply(\"You must enter a number.\")\r\n        step5 = await step4.send(\"64\")\r\n        await step5.assert_reply(\"Bot received the number '64'.\")\r\n```\r\n\r\n[bug]\r\n\n", "before_files": [{"content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nfrom typing import Callable, Dict\n\nfrom recognizers_number import recognize_number\nfrom recognizers_text import Culture, ModelResult\nfrom babel.numbers import parse_decimal\n\nfrom botbuilder.core.turn_context import TurnContext\nfrom botbuilder.schema import ActivityTypes\n\nfrom .prompt import Prompt, PromptValidatorContext\nfrom .prompt_options import PromptOptions\nfrom .prompt_recognizer_result import PromptRecognizerResult\n\n\nclass NumberPrompt(Prompt):\n    # TODO: PromptValidator needs to be fixed\n    # Does not accept answer as intended (times out)\n    def __init__(\n        self,\n        dialog_id: str,\n        validator: Callable[[PromptValidatorContext], bool] = None,\n        default_locale: str = None,\n    ):\n        super(NumberPrompt, self).__init__(dialog_id, validator)\n        self.default_locale = default_locale\n\n    async def on_prompt(\n        self,\n        turn_context: TurnContext,\n        state: Dict[str, object],\n        options: PromptOptions,\n        is_retry: bool,\n    ):\n        if not turn_context:\n            raise TypeError(\"NumberPrompt.on_prompt(): turn_context cannot be None.\")\n        if not options:\n            raise TypeError(\"NumberPrompt.on_prompt(): options cannot be None.\")\n\n        if is_retry and options.retry_prompt is not None:\n            turn_context.send_activity(options.retry_prompt)\n        elif options.prompt is not None:\n            await turn_context.send_activity(options.prompt)\n\n    async def on_recognize(\n        self,\n        turn_context: TurnContext,\n        state: Dict[str, object],\n        options: PromptOptions,\n    ) -> PromptRecognizerResult:\n        if not turn_context:\n            raise TypeError(\"NumberPrompt.on_recognize(): turn_context cannot be None.\")\n\n        result = PromptRecognizerResult()\n        if turn_context.activity.type == ActivityTypes.message:\n            message = turn_context.activity\n            culture = self._get_culture(turn_context)\n            results: [ModelResult] = recognize_number(message.text, culture)\n\n            if results:\n                result.succeeded = True\n                result.value = parse_decimal(\n                    results[0].resolution[\"value\"], locale=culture.replace(\"-\", \"_\")\n                )\n\n        return result\n\n    def _get_culture(self, turn_context: TurnContext):\n        culture = (\n            turn_context.activity.locale\n            if turn_context.activity.locale\n            else self.default_locale\n        )\n\n        if not culture:\n            culture = Culture.English\n\n        return culture\n", "path": "libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/number_prompt.py"}], "after_files": [{"content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nfrom typing import Callable, Dict\n\nfrom recognizers_number import recognize_number\nfrom recognizers_text import Culture, ModelResult\nfrom babel.numbers import parse_decimal\n\nfrom botbuilder.core.turn_context import TurnContext\nfrom botbuilder.schema import ActivityTypes\n\nfrom .prompt import Prompt, PromptValidatorContext\nfrom .prompt_options import PromptOptions\nfrom .prompt_recognizer_result import PromptRecognizerResult\n\n\nclass NumberPrompt(Prompt):\n    # TODO: PromptValidator needs to be fixed\n    # Does not accept answer as intended (times out)\n    def __init__(\n        self,\n        dialog_id: str,\n        validator: Callable[[PromptValidatorContext], bool] = None,\n        default_locale: str = None,\n    ):\n        super(NumberPrompt, self).__init__(dialog_id, validator)\n        self.default_locale = default_locale\n\n    async def on_prompt(\n        self,\n        turn_context: TurnContext,\n        state: Dict[str, object],\n        options: PromptOptions,\n        is_retry: bool,\n    ):\n        if not turn_context:\n            raise TypeError(\"NumberPrompt.on_prompt(): turn_context cannot be None.\")\n        if not options:\n            raise TypeError(\"NumberPrompt.on_prompt(): options cannot be None.\")\n\n        if is_retry and options.retry_prompt is not None:\n            await turn_context.send_activity(options.retry_prompt)\n        elif options.prompt is not None:\n            await turn_context.send_activity(options.prompt)\n\n    async def on_recognize(\n        self,\n        turn_context: TurnContext,\n        state: Dict[str, object],\n        options: PromptOptions,\n    ) -> PromptRecognizerResult:\n        if not turn_context:\n            raise TypeError(\"NumberPrompt.on_recognize(): turn_context cannot be None.\")\n\n        result = PromptRecognizerResult()\n        if turn_context.activity.type == ActivityTypes.message:\n            message = turn_context.activity\n            culture = self._get_culture(turn_context)\n            results: [ModelResult] = recognize_number(message.text, culture)\n\n            if results:\n                result.succeeded = True\n                result.value = parse_decimal(\n                    results[0].resolution[\"value\"], locale=culture.replace(\"-\", \"_\")\n                )\n\n        return result\n\n    def _get_culture(self, turn_context: TurnContext):\n        culture = (\n            turn_context.activity.locale\n            if turn_context.activity.locale\n            else self.default_locale\n        )\n\n        if not culture:\n            culture = Culture.English\n\n        return culture\n", "path": "libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/number_prompt.py"}]}