async def initial_step(
        self, step_context: WaterfallStepContext
    ) -> DialogTurnResult:
        timex = step_context.options

        prompt_msg_text = "On what date would you like to travel?"
        prompt_msg = MessageFactory.text(
            prompt_msg_text, prompt_msg_text, InputHints.expecting_input
        )

        reprompt_msg_text = "I'm sorry, for best results, please enter your travel date " \
                            "including the month, day and year."
        reprompt_msg = MessageFactory.text(
            reprompt_msg_text, reprompt_msg_text, InputHints.expecting_input
        )

        if timex is None:
            # We were not given any date at all so prompt the user.
            return await step_context.prompt(
                DateTimePrompt.__name__,
                PromptOptions(prompt=prompt_msg, retry_prompt=reprompt_msg),
            )
        # We have a Date we just need to check it is unambiguous.
        if "definite" not in Timex(timex).types:
            # This is essentially a "reprompt" of the data we were given up front.
            return await step_context.prompt(
                DateTimePrompt.__name__, PromptOptions(prompt=reprompt_msg)
            )

        return await step_context.next(DateTimeResolution(timex=timex))
Ejemplo n.º 2
0
    async def initial_step(
        self, step_context: WaterfallStepContext
    ) -> DialogTurnResult:
        """Prompt for the date."""
        timex = step_context.options

        prompt_msg = "On what date would you like to travel?"
        reprompt_msg = (
            "I'm sorry, for best results, please enter your travel "
            "date including the month, day and year."
        )

        if timex is None:
            # We were not given any date at all so prompt the user.
            return await step_context.prompt(
                DateTimePrompt.__name__,
                PromptOptions(  # pylint: disable=bad-continuation
                    prompt=MessageFactory.text(prompt_msg),
                    retry_prompt=MessageFactory.text(reprompt_msg),
                ),
            )
        else:
            # We have a Date we just need to check it is unambiguous.
            if "definite" in Timex(timex).types:
                # This is essentially a "reprompt" of the data we were given up front.
                return await step_context.prompt(
                    DateTimePrompt.__name__, PromptOptions(prompt=reprompt_msg)
                )
            else:
                return await step_context.next(DateTimeResolution(timex=timex))
    async def initialStep(self,step_context: WaterfallStepContext) -> DialogTurnResult:
        timex = step_context.options.date

        prompt_msg = 'On what date would you like to travel?'
        reprompt_msg = "I'm sorry, for best results, please enter your travel date including the month, day and year."

        if timex is None:
            # We were not given any date at all so prompt the user.
            return await step_context.prompt(DateTimePrompt.__name__ ,
                PromptOptions(
                    prompt= MessageFactory.text(prompt_msg),
                    retry_prompt= MessageFactory.text(reprompt_msg)
                ))
        else:
            # We have a Date we just need to check it is unambiguous.
            if 'definite' in TimexProperty(timex).types:
                # This is essentially a "reprompt" of the data we were given up front.
                return await step_context.prompt(DateTimePrompt.__name__, PromptOptions(prompt= reprompt_msg))
            else:
                return await step_context.next(DateTimeResolution(timex= timex))