Alexa - Some intents not reaching the skill - python

My Alexa skill keeps getting rejected for the reason:
'Please note "help" fails not reaching the endpoint of the skill.'
I'm using the Skill builder to build the skill, which by default implements the help intent.
My python code that I'm running on lambda has a handler for the help intent (full code can be seen at https://github.com/kkoppenhaver/last-episode/blob/master/skill.py )
## Handle the help intent
if intent_name == "AMAZON.HelpIntent" or intent_name == "TroubleshootIntent":
return build_response("Last Episode", "Welcome to Last Episode. Ask me about a T.V. series. For example, when was the last episode of How I Met Your Mother?", False)
And when I test using their testing interface, the help intent returns this string of text as intended.
Nevertheless, it continues to get rejected. Is there something simple I'm missing? I've filed a support request with Amazon as well, but would really like to get this approved as it's a relatively simple skill.
Any thoughts would be appreciated.
EDIT: Full schema
{
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "GetLastEpisodeIntent",
"samples": [
"last episode summary for {series_name}",
"what was the last episode of {series_name}",
"the last episode of {series_name}",
"about {series_name}",
"when was the last episode of {series_name}"
],
"slots": [
{
"name": "series_name",
"type": "AMAZON.TVSeries",
"samples": [
"{series_name}"
]
}
]
}
],
"prompts": [
{
"id": "Elicit.Intent-GetLastEpisodeIntent.IntentSlot-series_name",
"promptVersion": "1.0",
"definitionVersion": "1.0",
"variations": [
{
"type": "PlainText",
"value": "What series are you looking for?"
}
]
}
],
"dialog": {
"version": "1.0",
"intents": [
{
"name": "GetLastEpisodeIntent",
"confirmationRequired": false,
"prompts": {},
"slots": [
{
"name": "series_name",
"type": "AMAZON.TVSeries",
"elicitationRequired": true,
"confirmationRequired": false,
"prompts": {
"elicit": "Elicit.Intent-GetLastEpisodeIntent.IntentSlot-series_name"
}
}
]
}
]
}
}

Related

How to add reference Parameters in extend_schema decorator in drf-spectacular

I'm using drf-spectacular to generate the swagger/redoc API documentation.
I am facing issue in customising the schemas generated. I am trying to generate reference parameter using #extend_schema decorators in drf_spectacular but did'nt get the expected schema.
extend_schema -
`
from drf_spectacular.utils import extend_schema
#extend_schema(
parameters=headerParam,
responses = {200:Response1,400:errorresponse},
tags = ['User'],
)`
headerParam -
`headerParam = [
OpenApiParameter(
name='Accept-Language',
location=OpenApiParameter.HEADER,
type=OpenApiTypes.STR,
description='ISO 2 Letter Language Code',
required=True,
enum=['en', 'ar'],
# default='en',
),
OpenApiParameter(
name='Accept',
location=OpenApiParameter.HEADER,
type=OpenApiTypes.STR,
description='Type of response you are expecting from API. i.e. (application/json)',
required=True,
default='application/json',
),
]`
I am generating json schema by using "SpectacularJSONAPIView", but the problem I am facing is the schema in drf_spectacular is generating this as below -
`"parameters": [
{
"in": "header",
"name": "Accept",
"schema": {
"type": "string",
"default": "application/json"
},
"description": "Type of response you are expecting from API. i.e (application/json)",
"required": true
},
{
"in": "header",
"name": "Accept-Language",
"schema": {
"type": "string",
"enum": [
"ar",
"en"
]
},
"description": "ISO 2 Letter Language Code",
"required": true
}
],`
I want to generate like this in the headerparams -
"parameters": [
{
"$ref": "#/components/parameters/Accept"
},
{
"$ref": "#/components/parameters/Accept-Language"
}
],`
In app side swagger generator(ios), he is asking me to pass these parameters as a reference parameter(given above) so that he should not pass this parameter all the time.
Thank you and Appreciate for the help in Advance :)
I have done R&D but didn't find anything related to this.

AWS Step Functions - pass list into Glue's argument

Within my workflow I query DynamoDB for tables whose load_fail status equals 1.
If there is at least one table, Glue job needs to start with that list of tables as --source_tables argument.
Below is my entire state machine.
{
"Comment": "A description of my state machine",
"StartAt": "Query",
"States": {
"Query": {
"Type": "Task",
"Next": "Choice",
"Parameters": {
"TableName": "source_tables_load_status",
"KeyConditionExpression": "load_fail = :load_fail",
"ExpressionAttributeValues": {
":load_fail": {
"S": "1"
}
}
},
"Resource": "arn:aws:states:::aws-sdk:dynamodb:query",
"ResultSelector": {
"count.$": "$.Count",
"startTime.$": "$$.Execution.StartTime",
"items.$": "$.Items[*].table_name.S"
}
},
"Choice": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.count",
"NumericGreaterThanEquals": 1,
"Next": "start_glue"
}
],
"Default": "Success"
},
"start_glue": {
"Type": "Task",
"Resource": "arn:aws:states:::glue:startJobRun",
"Parameters": {
"JobName": "data-moving-glue",
"Arguments": {
"--dynamodb_metadata_table": "metadata_table",
"--source_tables.$": "$.items"
}
},
"End": true
},
"Success": {
"Type": "Succeed"
}
}
}
Currently I'm getting an error caused by "--source_tables.$": "$.items".
Question is how to make "--source_tables":["dbo.Table_Two", "dbo.Table_Three"] working by state machine:
An error occurred while executing the state 'start_glue' (entered at the event id #9).
The Parameters '{"JobName":"data-moving-glue","Arguments":{"--dynamodb_metadata_table":"metadata_table","--source_tables":["dbo.Table_Two", "dbo.Table_Three"]}}'
could not be used to start the Task: [The value for the field '--source_tables' must be a STRING]
I closed the result in quotes making it into a string using States.Format
https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-intrinsic-functions.html
"--source_tables.$": "States.Format('{}', $.items)"
New output is:
"--source_tables": "[\"dbo.TableOne\",\"dbo.TableTwo\"]"
This on the other hand can be handled with a function.
eval is used only as an example! Don't use it as it can compromise your code!
lst = "[\"dbo.TableOne\",\"dbo.TableTwo\"]"
for t in (eval(lst)):
print(t)

Microsoft Teams bot Adaptive Cards Action is received in on_message_activity without data

My bot returns an adaptive card in 1:1 private chat with user, the adaptive card configuration is like this,
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": f"{jiradetail.summary}",
}
]
}
],
"actions": [
{
"type": "Action.ShowCard",
"title": "Comment",
"card": {
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Input.Text",
"id": "comment",
"isMultiline": True,
"placeholder": "Enter your comment"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK",
"data": "**jiraid**"
}
]
}
}
]
}
As you could see, there is a 'comment' textbox and a 'Ok' Action (type Action.Submit, and hidden data->jiraid), the card will be as shown below,
Now on click on this Ok button, I am receiving the activity in ,
on_message_activity, with the user entered value in the commentbox in the field,
turn_context.activity.value
but i couldnt get the hidden data which i mapped to the action button, the below picture shows the inspected value of 'turn_context.activity'.
How can i get the mapped data to this action?
Note: I was also expecting the callback to be, on_teams_messaging_extension_submit_action , but this callback is never called, instead only on_message_activity is called. I assume, its because its an 1:1 conversation and its not invoked via the messageextensions. Any experts please confirm.
Regarding "on_teams_messaging_extension_submit_action" - it's not because it's a 1-1, rather it's because it is NOT a "message extension", it's just a regular Adaptive Card action.
With regards the main issue, about the data not appearing, try to avoid having a direct string value as the "data" payload, and instead try with an object, like this:
...
"data": {"value": "**jiraid**"}
...
Got the answer here,
https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-actions#
For easy reference, this what we are supposed to do,
Adaptive Cards support three action types:
Action.OpenUrl
Action.Submit
Action.ShowCard
In addition to the
actions mentioned above, you can modify the Adaptive Card
Action.Submit payload to support existing Bot Framework actions using
a msteams property in the data object of Action.Submit. The below
sections detail how to use existing Bot Framework actions with
Adaptive Cards.
So the updated payload will be, refer the payload 'msteams' under action->data,
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": f"{jiradetail.summary}",
}
]
}
],
"actions": [
{
"type": "Action.ShowCard",
"title": "Comment",
"card": {
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Input.Text",
"id": "comment",
"isMultiline": True,
"placeholder": "Enter your comment"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK",
"data": {
"msteams": {
"type": "invoke",
"value": {"jiraid":f"{jiradetail.issueid}"}
}
}
]
}
}
]
}

I need help figuring out how to turn online data into a usable list that I can print data from

In a program I am working on, I use ArcCloud's music fingerprinting service. after uploading the data I need identified, I am given back this piece of data:
re = ACRCloudRecognizer(config)
data = (re.recognize_by_file('audio_name.mp3', 0))
>>>data
'{"metadata":{"timestamp_utc":"2020-05-18 23:00:59","music":[{"label":"NoCopyrightSounds","play_offset_ms":125620,"duration_ms":326609,"external_ids":{},"artists":[{"name":"Culture Code & Regoton"}],"result_from":1,"acrid":"a53ea40c6a8b4a6795ac3d799f6a4aec","title":"Waking Up","genres":[{"name":"Electro"}],"album":{"name":"Waking Up"},"score":100,"external_metadata":{},"release_date":"2014-05-25"}]},"cost_time":5.5099999904633,"status":{"msg":"Success","version":"1.0","code":0},"result_type":0}\n'
I think it's a list, but I am unable to figure out how to navigate nor grab specific information from it. I'm unsure how they set up the information, and what patterns to look for. Ideally, I would like to create a print function that would print the title, artists, and album.
Any help is much appreciated!
Formatting the JSON makes it more legible
{
"metadata": {
"timestamp_utc": "2020-05-18 23:00:59",
"music": [
{
"label": "NoCopyrightSounds",
"play_offset_ms": 125620,
"duration_ms": 326609,
"external_ids": {},
"artists": [
{
"name": "Culture Code & Regoton"
}
],
"result_from": 1,
"acrid": "a53ea40c6a8b4a6795ac3d799f6a4aec",
"title": "Waking Up",
"genres": [
{
"name": "Electro"
}
],
"album": {
"name": "Waking Up"
},
"score": 100,
"external_metadata": {},
"release_date": "2014-05-25"
}
]
},
"cost_time": 5.5099999904633,
"status": {
"msg": "Success",
"version": "1.0",
"code": 0
},
"result_type": 0
}
Looks like you're looking for .metadata.music.title (presumably), but only if .status.code is 0

Google assistant sdk [CUSTOM TYPES ]: capture monetary values ($10, $20. $50) from a custom action

I want to use a custom type to capture $10, $5, $20, etc values in my custom action because there's no a Schema.org-defined type for this kind of data. I add this to the json file, but it doesn't work.
This is running on raspbian.
Using google assistant SDK 1.0.1 version.
The action is made for Spanish language.
{
"locale": "es",
"manifest": {
"displayName": "Imprimir",
"invocationName": "Imprimir",
"category": "PRODUCTIVITY"
},
"actions": [
{
"name": "com.example.actions.Imprimir",
"availability": {
"deviceClasses": [
{
"assistantSdkDevice": {}
}
]
},
"intent": {
"name": "com.example.intents.Imprimir",
"parameters": [
{
"name": "cantidad",
"type": "SchemaOrg_Number"
},
{
"name": "valor",
"type": "$Valor"
}
],
"trigger": {
"queryPatterns": [
"imprimir $SchemaOrg_Number:cantidad tickets de $Valor:valor"
]
}
},
"fulfillment": {
"staticFulfillment": {
"templatedResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "De acuerdo"
}
},
{
"deviceExecution": {
"command": "com.example.commands.Imprimir",
"params": {
"cantidad": "$cantidad",
"valor": "$valor"
}
}
}
]
}
}
}
}
],
"types": [
{
"name": "$Valor",
"entities": [
{
"key": "1$",
"synonyms": [
"1 dolar"
]
},
{
"key": "2$",
"synonyms": [
"2 dolares"
]
},
{
"key": "5$",
"synonyms": [
"5 dolares"
]
},
{
"key": "10$",
"synonyms": [
"10 dolares"
]
},
{
"key": "20$",
"synonyms": [
"20 dolares"
]
}
]
}
]
}
It doesn't show me any apparent error. This is what happend when I talk the order:
ON_END_OF_UTTERANCE
ON_END_OF_UTTERANCE
ON_RECOGNIZING_SPEECH_FINISHED:
{"text": "imprimir dos ticket de $10"}
ON_RESPONDING_STARTED:
{"is_error_response": false}
ON_RESPONDING_FINISHED
ON_CONVERSATION_TURN_FINISHED:
{"with_follow_on_turn": false}
The assistant tell me that she doesn't understant.
I'm working in a spanish gaction.
I know that my custom type is not working because the event is not captured. I'm sure the json file doesn't have errors because if I ignore the "Valor" type, replace it for $SchemaOrg_Number and omit word "dolar" the gaction works well.
I already tried with $SchemaOrg_priceCurrency, but it capture the type of currency like dollar, sol, yen, euro, etc...
Your synonyms list should include each possible combination. If your query has "$10" as the string, that needs to match as a synonym or the query would not match at all.

Categories