简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM