Alexa - Implementing CanFulfillIntentRequest in python

醉酒当歌 提交于 2019-12-24 01:38:18

问题


I have enabled the CanFulfillIntentRequest from the alexa skill developer console in English(U.S) of my skill. I have added a handler in my lambda for the CanFulfillIntentRequest. When I use the skill tester and type the intent utterance directly (without skill invocation name), it doesn't seem to hit my code. I can't find any related logs in the cloudwatch.

def lambda_handler(event, context):
    print("event.session.application.applicationId=" +
          event['session']['application']['applicationId'])

    if event['session']['new']:
        on_session_started({'requestId': event['request']['requestId']},
                           event['session'])

    if event['request']['type'] == "LaunchRequest":
        return on_launch(event['request'], event['session'])
    elif event['request']['type'] == "IntentRequest":
        return on_intent(event['request'], event['session'])
    elif event['request']['type'] == "SessionEndedRequest":
        return on_session_ended(event['request'], event['session'])
    elif event['request']['type'] == "CanFulfillIntentRequest":
        return on_canfullfill(event['request'], event['session'])

def on_canfullfill(request, session):
    print ("Yes, I can!")

I know this has to respond back with a JSON specifying if the skill can or cannot take up this request. But shouldn't there be a - 'Yes, I can!' entry in the cloud watch logs?

What am I missing here? Also, where can I find documentation/apis on forming and sending the reponse for this request?


回答1:


It looks like you can only test CanFulfillIntentRequest using Manual JSON tab from developer console and using ASK CLI.

From Alexa documentation

You cannot test CanFulfillIntentRequest with an Alexa-enabled device

More on testing CanFulfillIntentRequest here



来源:https://stackoverflow.com/questions/51530863/alexa-implementing-canfulfillintentrequest-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!