treethought / flask-assistant

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

Adding message from event is not working #143

Closed SouravMalliK closed 4 years ago

SouravMalliK commented 4 years ago

Adding message from event is not working. event is triggering but the message is not showing up


def welcome():
    try:
        if profile:
            event_name = search_event(profile['name'])
            return  event(event_name).add_msg(speech=f"<speak>Welcome back "
                                                    f"{profile['name']}.<break time=\"2\" /> </speak>",
                       display_text="Welcome aboard {profile['name']}", is_ssml=True)
    except Exception as e:
        log.error(e)
        exit(1)
    return sign_in("To learn more about you")
treethought commented 4 years ago

hi @SouravMalliK, events do not actually allow setting a message in this way. Events directly trigger a new intent to be invoked, which means a response is not returned to the user until after that event intent's response is returned. In other words, the event response "skips" returning a response to the user.

To accomplish what you are trying to do, add a "sys.any" parameter to your event's intent, with its value set to #<EVENT_NAME>.<PARAM_NAME>, and pass your message as a parameter to the event.

Then in the action function for the event's intent, use the passed parameter to return your message.