简体   繁体   English

Google Assistant SDK [自定义类型]:通过自定义操作捕获货币值($ 10,$ 20。$ 50)

[英]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. 我想在自定义操作中使用自定义类型捕获$ 10,$ 5,$ 20等值,因为没有Schema.org定义的此类数据类型。 I add this to the json file, but it doesn't work. 我将此添加到json文件中,但是它不起作用。

This is running on raspbian. 这是在树莓派上运行。 Using google assistant SDK 1.0.1 version. 使用Google Assistant SDK 1.0.1版本。 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. 我确定json文件没有错误,因为如果忽略“ Valor”类型,将其替换为$SchemaOrg_Number并省略单词“ dolar”,则gaction效果很好。

I already tried with $SchemaOrg_priceCurrency , but it capture the type of currency like dollar, sol, yen, euro, etc... 我已经尝试过使用$SchemaOrg_priceCurrency ,但是它捕获了诸如美元,溶胶,日元,欧元等货币类型。

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. 如果查询的字符串为“ $ 10”,则需要将其作为同义词进行匹配,否则查询将根本不匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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