treethought / flask-assistant

Framework for Building Virtual Assistants with Dialogflow and python
Apache License 2.0
380 stars 100 forks source link

Using pre #131

Open valgaze opened 4 years ago

valgaze commented 4 years ago

Hi there--

DialogFlow is definitely a "team sport" and one of the best parts is being able to come across libraries/tooling like this one!

Question: If one uses flask-assistant to implement a conversation flow with a yes/no branch, is there any existing pattern with this library to integrate DialogFlow's "pre-defined" intents?

Only reason to do this is because the pre-defined intents come "for free" w/ many excellent natural language samples for negative (this is page 1/5):

image

I'm presuming the answer is no, but curious if this has come up before

Ex. in the pizza-shop sample, there's a check for no by inspecting if the letter n exists (which is probably pretty good match for English-speaking commerce case): https://github.com/treethought/flask-assistant/blob/master/samples/pizza_contexts/agent.py#L37

image

treethought commented 4 years ago

Hi @valgaze. To use these "pre-defined" followup intents with flask-assistant, you can simply enable webhook for the intent. Given, a "parent" intent Sample-Intent that has yes and no followup intents Sample-Intent-Yes and Sample-Intent-No, you can implement action functions for all three as usual.

...
@assist.action("Sample-Intent")
def parent_intent_logic():
    pass

@assist.action("Sample-Intent-Yes")
def logic_for_yes():
    pass

@assist.action("Sample-Intent-No")
def logic_for_no():
    pass