jovotech / jovo-framework

🔈 The React for Voice and Chat: Build Apps for Alexa, Messenger, Instagram, the Web, and more
https://www.jovo.tech
Apache License 2.0
1.67k stars 310 forks source link

$input key and value are the same despite synonyms #903

Closed mig82 closed 2 years ago

mig82 commented 3 years ago

I'm submitting a...

Expected Behavior

When defining synonyms for an input foo, accessing $input.foo should show different values for foo's key and value. Yet, when using the debugger both key and value are the same.

Current Behavior

For example, I have this intent for the user to ask for an exchange rate. You'll see I've defined a custom type for the currency, and defined synonyms for EUR and GBP.

{
    "invocation": "exchange rates",
    "intents": [
        {
            "name": "ExchangeRates",
            "phrases": [
                "convert from {ccyFrom} to {ccyTo}",
                "convert {ccyFrom} to {ccyTo}"
            ],
            "inputs": [
                {
                    "name": "ccyFrom",
                    "type": "CurrencyType"
                },
                {
                    "name": "ccyTo",
                    "type": "CurrencyType"
                }
            ]
        }
    ],
    "inputTypes": [{
        "name": "CurrencyType",
        "values": [
            { "value": "EUR", "synonyms": [
                "Euro", "European", "Europe", "EU", "european"
            ]},
            { "value": "GBP", "synonyms": [
                    "British Pound", "British", "Pound", "Sterling",
                    "Pound Sterling", "Britain", "STG", "UK", "sterling"
            ]}
        ]
    }]
}

When in the intent handler I print this.$inputs, this is what I get.

{
  ccyFrom: {
    name: 'ccyFrom',
    alexaSkill: { name: 'ccyFrom', value: 'sterling' },
    value: 'sterling',
    key: 'sterling'
  },
  ccyTo: {
    name: 'ccyTo',
    alexaSkill: { name: 'ccyTo', value: 'euro' },
    value: 'euro',
    key: 'euro'
  }
}

Notice that for both inputs, the id, the value and the key are all the same —i.e. the synonym used by the user. None is the resolved key value. And the id, well. Not sure what that should be, but I don't think it should be the synonym either.

Error log

No error log.

Your Environment

$ node -v
v14.15.5

$ npm -v
6.14.11

$ jovo -v
Jovo CLI Version: 3.2.1

Jovo packages of current project:
  jovo-core: 3.3.1
  jovo-db-filedb: 3.3.1
  jovo-framework: 3.3.1
  jovo-platform-alexa: 3.3.1
  jovo-platform-googleassistantconv: 3.3.2
  jovo-plugin-debugger: 3.3.2
jankoenig commented 2 years ago

Thank you for this. Since then, we updated the Debugger to be able to create more flexible buttons for user input: https://www.jovo.tech/docs/debugger-config