Sb Conflicting each other
Daniyaldehleh opened this issue · 5 comments
Sb conflicting with each other.
Current Behavior
sb = StandardSkillBuilder(table_name="NewTable", auto_create_table=False)
sb = CustomSkillBuilder(api_client=DefaultApiClient())
Error:
{
"errorMessage": "__init__() got an unexpected keyword argument 'api_client'",
"errorType": "TypeError",
"stackTrace": [
" File \"/var/lang/lib/python3.8/imp.py\", line 234, in load_module\n return load_source(name, filename, file)\n",
" File \"/var/lang/lib/python3.8/imp.py\", line 171, in load_source\n module = _load(spec)\n",
" File \"<frozen importlib._bootstrap>\", line 702, in _load\n",
" File \"<frozen importlib._bootstrap>\", line 671, in _load_unlocked\n",
" File \"<frozen importlib._bootstrap_external>\", line 783, in exec_module\n",
" File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n",
" File \"/var/task/lambda_function.py\", line 238, in <module>\n sb = StandardSkillBuilder(table_name=\"NewTable\", auto_create_table=False, api_client=DefaultApiClient())\n"
]
}
Possible Solution
I tried changing sb to mb for the second one so I can have mb.add_request_handlers. However, it didn't work.
As well as, I tried writing sb = StandardSkillBuilder(table_name="NewTable", auto_create_table=False, api_client=DefaultApiClient())
which caused the above error.
Context
At the same time I need both to activate dynamo and API.
Your Environment
- ASK SDK for Python used: 3.8.3
- Operating System and version:1.14.0
Hey @danieldhz , StandardSkillBuilder
and CustomSkillBuilder
are different types of skill builder, which eventually will give you a skill for dispatching the input requests. You will need only one type of skill builder for a specific skill.
For your context, you can directly use StandardSkillBuilder
without any api client initalization. The SDK will handle that for you. Hope this helps.
Hi @nikhilym !
Thanks for your response. So I do not need sb = CustomSkillBuilder(api_client=DefaultApiClient())
to call an external api in my function?
cause without it I am now getting:
START RequestId: aec1f79f-bb1b-4883-b7c2-829016f049ba Version: $LATEST
[INFO] 2020-09-01T19:40:01.46Z aec1f79f-bb1b-4883-b7c2-829016f049ba Starting Entitled Product Check
[INFO] 2020-09-01T19:40:01.84Z aec1f79f-bb1b-4883-b7c2-829016f049ba new session, so see what is entitled
[INFO] 2020-09-01T19:40:01.311Z aec1f79f-bb1b-4883-b7c2-829016f049ba Error calling InSkillProducts API: The authentication token is invalid or doesn't have access to make this request
[ERROR] 2020-09-01T19:40:01.324Z aec1f79f-bb1b-4883-b7c2-829016f049ba The authentication token is invalid or doesn't have access to make this request
Traceback (most recent call last):
File "/opt/python/lib/python3.8/site-packages/ask_sdk_runtime/dispatch.py", line 116, in dispatch
request_interceptor.process(handler_input=handler_input)
File "/var/task/lambda_function.py", line 188, in process
result = ms.get_in_skill_products(locale)
File "/opt/python/lib/python3.8/site-packages/ask_sdk_model/services/monetization/monetization_service_client.py", line 129, in get_in_skill_products
api_response = self.invoke(
File "/opt/python/lib/python3.8/site-packages/ask_sdk_model/services/base_service_client.py", line 151, in invoke
raise ServiceException(message=exception_metadata.message,
ask_sdk_model.services.service_exception.ServiceException: The authentication token is invalid or doesn't have access to make this requestEND RequestId:
not sure if its related
For calling alexa services, you would need the api_client
to be initialized. If you are using CustomSkillBuilder
, you can initialize it manually. If you are using StandardSkillBuilder
, it is initialized by default. We currently do not support calling external APIs (other than Alexa custom skill service APIs) from the SDK.
Now, from the error message that you pasted, it looks like the service call happened but it failed at the auth level. Since the call itself happened, your api client is initialized just fine and has nothing to do with this issue.
Thank you so much for your comprehensive explanation. I fixed the error. I am just not sure what you meant on not supporting external APIs? Alexa can't call external APIs? Cause I was just able to build a func today where Alexa made POST request on user's google calender and it was successful in the development stage.
Glad to know that you got it working. What I meant by calling external APIs is, that the SDK doesn't provide any helper functions or any configurations through which skill developers can do a simple function call to external APIs.
For Alexa specific APIs, as you can check in your ISP code, you can just do a handler_input.service_client_factory.get_monetization_service().<call_some_method>
. However, you cannot use the service client factory to call any external API. Hope this helps.
Since you are able to get this working, I am going ahead and closing this issue. Please let us know if you face any other problems. Thanks.