コード例 #1
0
    def create():
        return Folder(
            label="UI ACTIONS",
            children=[
                Input(
                    Grammar(watson_items=["USER CLICKS BOX"]),
                    children=[
                        Output(
                            prompt=Prompt(
                                items=["{Selected_Movie}."]
                            ),
                            children=[
                                If(
                                    elements=[
                                        Condition(name="Popularity_Score", operator="GREATER_THEN", root_text="6.9"),
                                        Output(
                                            Prompt(
                                                items=[
                                                    "Great choice! That gets fabulous ratings.",
                                                    "That's a good one! You will love it.",
                                                    " I hear that's a really good movie!"
                                                ]
                                            ),
                                            children=[AfterSearchResults.goto()]
                                        )
                                    ]
                                ),
                                If(
                                    elements=[
                                        Condition(name="Popularity_Score", operator="LESS_THEN", root_text="4"),
                                        Output(
                                            Prompt(
                                                items=[
                                                    "Hmm, I hear that's not such a great movie.",
                                                    "Um, that one gets low ratings.",
                                                    "Are you sure about that? The ratings are terrible."
                                                ]
                                            ),
                                            children=[AfterSearchResults.goto()]
                                        )

                                    ]
                                ),
                                Output(
                                    prompt=Prompt(
                                        items=[
                                            "Okay.",
                                            "All right.",
                                            "Sure thing!",
                                            "Coming right up!"
                                        ]
                                    ),
                                    children=[AfterSearchResults.goto()]
                                )
                            ]
                        )
                    ]
                )
            ]
        )
コード例 #2
0
    def create():
        from dialog.schema.factories.inputs import AfterSearchResults

        return Output(
            _id=AnythingElseCanHelpWith.__id(),
            prompt=Prompt(
                items=["Is there anything else I can help you with?"]
            ),
            children=[
                GetUserInput(
                    children=[
                        Input(
                            Grammar(
                                watson_items=[
                                    "Go back",
                                    "$ go back",
                                    "$ wait",
                                    "$ not done",
                                    "$ not finished"
                                ]
                            ),
                            children=[
                                Output(
                                    GenericPrompt.ok(),
                                    children=[AfterSearchResults.goto()]
                                )
                            ]
                        ),
                        Input(
                            GenericGrammar.yes(),
                            children=[
                                RequestSuccessAction.set_to_blank(),
                                TerminalExchangeAction.set_to_blank(),
                                TopicAction.set_to_blank(),
                                StylePreferenceAction.set_to_blank(),
                                ColorPreferenceAction.set_to_blank(),
                                RecencyPreferenceAction.set_to_blank()
                            ]
                        ),
                        Input(
                            GenericGrammar.no(),
                            children=[
                                Output(
                                    GenericGrammar.ok(),
                                    children=[Goto(ref="output_did_find_what_looking_for")]
                                )
                            ]
                        ),
                        Goto(ref="input_2456878")
                    ]

                )
            ]
        )