Comments (14)
I'm currently just using pytest against...
tests/test_file.py
from skill import handler
from tests import new_request, context
def test_intent():
request = new_request('MyIntent', {'SlotName': 'slot value'})
response = handler(request, context)
expected_response = 'Your intent was reached. My response is, "slot value".'
assert expected_response in response['response']['outputSpeech']['ssml']
assert expected_response in response['response']['reprompt']['outputSpeech']['ssml']
tests/__init__.py
import uuid
from datetime import datetime
context = {}
def new_request(name, slots={}):
req_env = {
"session": {
"sessionId": f"amzn1.echo-api.session.{uuid.uuid1()}",
"application": {
"applicationId": f"amzn1.echo-sdk-ams.app.{uuid.uuid1()}"
},
"user": {
"userId": f"amzn1.ask.account.{uuid.uuid1()}"
},
"new": False,
},
"request": {
"requestId": f"amzn1.echo-api.request.{uuid.uuid1()}",
"timestamp": f"{datetime.now().replace(second=0, microsecond=0).isoformat()}",
"locale": "en-US",
"type": "IntentRequest" if name.endswith('Intent') else name,
}
}
if name.endswith('Intent'):
req_env['request']['intent'] = {
'name': name,
'slots': {k: {'name': k, 'value': v} for k, v in slots.items()}
}
return req_env
from alexa-skills-kit-sdk-for-python.
Have you tried using ngrok? See example in https://developer.amazon.com/blogs/post/Tx14R0IYYGH3SKT/Flask-Ask-A-New-Python-Framework-for-Rapid-Alexa-Skills-Kit-Development
from alexa-skills-kit-sdk-for-python.
Hey @The-Gupta , we currently do not provide any testing framework with the SDK that helps in local testing. This falls under a feature request. We track them through the 'User Voice' portal.
Please pitch in ideas to User Voice. If it already exists, make sure to give your vote!
We think that local testing is a value-add to the skill development and will definitely look into it.
from alexa-skills-kit-sdk-for-python.
In the meantime, could anyone suggest any other possibility
- steps I could follow,
- maybe, use some other library...?
And, I repeat, I need to test an Alexa Skill locally using Python. Also, I need text I/O like Alexa Simulator on Amazon Developer Website under the Test tab, not voice using Echosim.
from alexa-skills-kit-sdk-for-python.
@nikhilym, could you suggest steps using Amazon API Gateway, preferably in Python?
from alexa-skills-kit-sdk-for-python.
@The-Gupta can you explain in brief what are you trying to achieve? Also, if this is something different from the intended question raised in this issue, please log another one.
If this issue has been addressed or a feature request has been raised on User Voice, please link the same here.
from alexa-skills-kit-sdk-for-python.
I'm trying to test an Alexa Skill locally, on my laptop, like Alexa Simulator on Amazon Developer Website under the Test tab.
from alexa-skills-kit-sdk-for-python.
Hi, I am also trying to run the code "Hello_World" and pressing the test tab. But it's not working. Some times it is timeout error and some times it is hello_world module not found.
from alexa-skills-kit-sdk-for-python.
Hey @sarang-rk. Looks like you are having a different issue than the discussion here. Please update the issue #26 with the issue template so that we can investigate the problem
from alexa-skills-kit-sdk-for-python.
Hey @The-Gupta , sorry for the late response. For lambda handler testing, pytests method as mentioned by @timothyaaron is the way. For testing the skill similar to alexa simulator, you can try the ask simulate
commands as mentioned here.
The ask cli
is currently Node specific. However, you can try these steps to get the alexa skill cloned locally for working with CLI. There is a feature request to provide a CLI similar to ask-cli for Python. Please voice your feedback if this is something you are interested in.
As for the ngrok approach mentioned by @ag1le , that is currently not supported in the SDK, since there is no web application wrapper on the lambda function. (Stay tuned for new features 😄 ) But, in case you want to follow that approach, create a wsgi app that can route the requests through the lambda handler, create a local http server using ngrok, run the webapp and tag it to the Skill endpoint for testing.
Let us know if you have questions.
from alexa-skills-kit-sdk-for-python.
Hey @The-Gupta , I checked on some of the Alexa repos that you wanted to test your skill code using API Gateway and Postman. Here is the link that explains how to do the same. I am closing this issue for now. Please reopen if you face any issues with the methods described.
As for the feature request, we suggest you to create one or upvote the requests on User Voice.
from alexa-skills-kit-sdk-for-python.
Two years later I have the same question.
Is there a way to test skills from a Python terminal without a need to go to Test Tab on the Amazon Developer website?
from alexa-skills-kit-sdk-for-python.
Hi @qo4on, we currently do not provide any testing framework with the SDK that helps in local testing.
But you can install ASK CLI and leverage its dialog command to test the skills locally.
from alexa-skills-kit-sdk-for-python.
Thanks for your answer @Shreyas-vgr.
As I know CLI shows text responses only. Is there any workaround for getting audio responses without Test Tab on Developer website?
from alexa-skills-kit-sdk-for-python.
Related Issues (20)
- ask_sdk_model.services.service_exception.ServiceException: The authentication token is invalid or doesn't have access to make this HOT 11
- Sb Conflicting each other HOT 5
- `ModuleNotFoundError:` No module named 'asn1crypto'`` when importing skill adapter from flask HOT 3
- 'NoneType' object has no attribute 'system' HOT 2
- Link how to create a new security profile should be updated HOT 1
- Golang SDK - Alexa Skills kit HOT 2
- User with almost all scopes types receives unauthorized_client error HOT 2
- UserAgentManager missing from 1.15 PyPI distro HOT 3
- Alexa HOT 1
- Fail to import local modules HOT 6
- I have a intent for the alexa skill which has two slots, one of them is fulfilled while invoking the skill. I want the second slot to store the value uttered by the user at a later point of time. Is there a way to do so using python HOT 1
- Cannot import the SpokenInfo class (ask_sdk_model.services.reminder_management) HOT 2
- Receiving unauthorized_client error trying to list all skills HOT 3
- SpeakDirective doesn't create correct audio src directive HOT 1
- Outdated version of cryptography? HOT 5
- Invalid signatures with django-ask-sdk since ask-sdk-webservice-support v1.3.3 HOT 4
- ENDPOINT_TIMEOUT is not handled properly in Incorrect handling of SessionEndedRequest.
- AskForPermissionsConsentCard not showing the option to activate requested permission HOT 2
- documentation error - local_debug.py
- Bug report : Sending a voice forward consent start connection directive returns error "ask_sdk_core/response_helper.py directive.object_type has no attribute 'object_type'"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alexa-skills-kit-sdk-for-python.