Coder Social home page Coder Social logo

afg's People

Contributors

dgtony avatar elveskevtar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

afg's Issues

Alexa response with reprompt message always

Hi @dgtony ,
I was trying to implement alexa-afg for one of my sample skill.
Scenario looks like below,
`first_step: init
last_step: done
default_help:

  • "You are talking to Alexa. What you want to know?"
  • "Hi, you can ask your network status or alert messages?"

steps:
init:
reprompt:
- "What you want to know?"
events:
welcome_message:
next: user_choice

user_choice:
reprompt:
- "Sorry, I didn't understand, would you like to know network status or alert messages?"
- "Please, please choose either network status or alert messages"
help:
- "You need to decide what you want. Say: tell me network status or tell me alert messages"
events:
networkStatus:
next: more_net_choice
alertsStatus:
next: more_ale_choice

more_net_choice:
reprompt:
- "Sorry, I didn't understand, do you want to know more about network information?"
help:
- "Please tell 'yes' to get to know more information about network"
events:
yesStatus:
next: done

more_ale_choice:
reprompt:
- "Sorry, I didn't understand, do you want to know more about alert messages?"
help:
- "Please tell 'yes' to get to know more information about alerts"
events:
yesStatus:
next: done

done:
Skill looks like below,from flask_ask import Ask, statement, question, request, session, convert_errors
from flask import Flask, render_template
import logging
from afg import Supervisor

app = Flask(name)
ask = Ask(app, "/")
sup = Supervisor("scenario.yaml")
logging.getLogger("flask_ask").setLevel(logging.DEBUG)
yesCall = None

@ask.on_session_started
@sup.start
def new_session():
app.logger.debug('new user session started')

@sup.stop
def close_user_session():
app.logger.debug('user session stopped')

@ask.session_ended
def session_ended():
close_user_session()
return "", 200

@ask.intent('AMAZON.HelpIntent')
def help_user():
context_help = sup.get_help()
return question(context_help)

@ask.launch
@sup.guide
def welcome_message():
welcome_msg = render_template('welcome')
return question(welcome_msg)

@ask.intent("netStatus")
@sup.guide
def networkStatus():
global yesCall
network_status_msg = render_template('network_status')
yesCall = moreNetworkStatus
return question(network_status_msg)

@ask.intent("aleStatus")
@sup.guide
def alertsStatus():
global yesCall
ale_status_msg = render_template('ale_status')
yesCall = moreAlertStatus
return question(ale_status_msg)

@ask.intent("yesStatus")
def yesStatus():
global yesCall
return yesCall()

@sup.guide
def moreNetworkStatus():
moreale_status_msg = render_template('morenet_status')
return question(moreale_status_msg)

@sup.guide
def moreAlertStatus():
moreale_status_msg = render_template('moreale_status')
return question(moreale_status_msg)

@ask.intent('AMAZON.StopIntent')
def stop():
close_user_session()
return statement(render_template('no_status'))

if name == 'main':
app.run(debug=True)`

So the issue here is: if I ask for the network status, which will call 'netStatus' intent and this will store the reference for the 'yesStatus'. But when I trigger 'yesStatus' intent Alexa always responds with reprompt message. This code shows same behavior for 'aleStatus' followed by 'yesStatus' intents. It will be very helpful if you can tell me why I am facing this issue?

Installation fails due to conflicting pyyaml version

Hi, users are unable to run afg due to dependency conflict with pyyaml package. As shown in the following full dependency graph of afg, afg requires pyyaml *,while flask-ask requires pyyaml ==3.12.

According to pip’s “first found wins” installation strategy, pyyaml 5.1.2 is the actually installed version. However, pyyaml 5.1.2 does not satisfy ==3.12.

Dependency tree-----------

afg - 0.2
| +- flask-ask(install version:0.9.8 version range:*)
| | +- aniso8601(install version:1.2.0 version range:==1.2.0)
| | | +- python-dateutil(install version:2.8.1 version range:*)
| | +- flask(install version:0.12.1 version range:==0.12.1)
| | | +- click(install version:7.0 version range:>=2.0)
| | | +- itsdangerous(install version:1.1.0 version range:>=0.21)
| | | +- jinja2(install version:2.10.3 version range:>=2.4)
| | | | +- markupsafe(install version:1.1.1 version range:>=0.23)
| | | +- werkzeug(install version:0.16.0 version range:>=0.7)
| | +- pyopenssl(install version:17.0.0 version range:==17.0.0)
| | | +- cryptography(install version:2.8 version range:>=1.7)
| | | +- six(install version:1.11.0 version range:>=1.5.2)
| | +- pyyaml(install version:3.12 version range:==3.12)
| | +- six(install version:1.11.0 version range:==1.11.0)
| +- fysom(install version:2.1.5 version range:*)
| +- pyyaml(install version:5.1.2 version range:*)
| +- wrapt(install version:1.11.2 version range:*)

Thanks for your help.
Best,
Neolith

How to jump up a state to make a infinity loop

Hi,

I want to jump up the state without using a addition ask_continue_intent.
So that I can make a infinity loop to give command to Alexa continuously.

This is what I tried:

scenario.yaml

steps:
  # the first step
  init:
    events:
      launched: 
        next: center 

  center:
    reprompt:
      - "Sorry, I didn't understand"
      - "Please ask help for more information"
    help:
      - "For example, just say: who are you"
      - "For example, just say: turn on the light"
    events:
      PlayMusicIntent_trigger: 
        next: waitting 
      ControlDeviceIntent_trigger: 
        next: waitting 

  waitting:
    reprompt:
      - "Sorry, I didn't understand"
      - "Please ask help for more information"
    help:
      - "For example, just say: who are you"
      - "For example, just say: turn on the light"
    events:
      PlayMusicIntent_trigger:
        next: done 
      ControlDeviceIntent_trigger: 
        next: done 
     
  done:

server flask-ask


Sup_Current_state = "none" 

@ask.intent("PlayMusicIntent")
@sup.guide
def PlayMusicIntent_trigger(Song):

    global Sup_Current_state
    Sup_Current_state = sup.get_current_state()

    global PlayMusic_trigger,PlayMusic_song,PlayMusic_status
    PlayMusic_trigger = True
    PlayMusic_song = Song
    PlayMusic_status = "playing"

    if Sup_Current_state is "done":
        sup.move_to_step('center')
        return question(render_template('PlayMusic_done',song=PlayMusic_song))

    return question(render_template('PlayMusic_done',song=PlayMusic_song))

@ask.intent('ControlDeviceIntent')
@sup.guide
def ControlDeviceIntent_trigger(Status,Device): 

    global Sup_Current_state
    Sup_Current_state = sup.get_current_state()
 
    global ControlDevice_trigger,ControlDevice_device,ControlDevice_status

    #save the status of the device to send to gateway
    ControlDevice_trigger = True
    ControlDevice_device = Device
    ControlDevice_status = Status

    if Sup_Current_state is "done":
        sup.move_to_step('center') 
        return question(render_template('ControlDevice_done',device=Device, status=Status))   

    return question(render_template('ControlDevice_done',device=Device, status=Status))

I can send the first command in center state and second command in waitting state.
But after it finished waitting state. If I give the third command, Alexa will return an error.

I don't understand. If I create a addition state ask_keep_continue_or_not, It works perfectly but I have to say yes to keep the loop.

would you mind helping me ?

Update: I repalve Sup_Current_state with a variable to control if else then it work

@ask.on_session_started must come before @sup.start

If it is the other way around then the session id does not get generated by the time the wrapt method gets called. Might be worth documenting that the order of these decorators matters since this is not necessarily intuitive.

about sup.reprompt_error in coffee machine example

Hi,

Thank you for making afg. It's simple, easy to use.

In the coffee machine example, in @ask.intent('DrinkAmountIntent') .
The function sup.reprompt_error("I'm not sure, make it big or small?") doesn't work. I didn't hear the reprompt_error

It's because in LIST_amount there are only "small" and "big". So If you say something new, which is not in the LIST_amount, Alexa will conflict and do nothing. So that state doesn't return the reprompt_error, I can ask help then it return the helpin scenario. : "Say: make small or make big"

would you mind checking again.

Update #1: I added "on" and "off" to LIST_amount and the the reprompt_error works correctly.
Do you have any solutions for this problem ?

thank you and regards,
Khoa

KeyError: 'reprompt'

when running the example the following keyerror is thrown

File "/usr/local/lib/python2.7/dist-packages/afg/scenarios.py", line 110, in guide
return question(choice(self._scenario_steps[current_state]['reprompt']))

Common Intent called by different steps?

Hi @dgtony,

Great work on this addition to flask-ask. I'm trying to craft a conversation with various prompts, and have a question around single work utterances. Near the start of my state table I ask for a specific month, then later in the state I ask for a specific date (M/D/Y). Both requests are expecting just a single value, which I assume I would map to AMAZON.DATE. Is there a way to map a common intent and have it redirect to the next step based on the who called (previous step)?

Something like this where DateChoiceIntent is the common one:

[init] --> [date_choice] --> <choose_month> --> [foo_choice] --> ... --> [date_choice] --> <choose_full_date. --> [bar_choice]

Basically where if only a month is returned to DateChoiceIntent, date_choice() would forward to foo_choice() state. If a full date is returned, date_choice() would forward to the bar_choice() state.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.