Converting from existing Alexa "App askApiUpdateModel:Request is not valid. "

amazon-alexa

#1

Hi there,

I’m trying to build an application that works for both DialogFlow and Alexa starting from a pre-existing Alexa app.

Because I want to do this properly I’m trying also to setup a “dev” environment for both Alexa and Dialog flow.

So currently I have 2 Alexa Skills (prod and dev) and 2 Dialog Flow Actions (prod and dev)

This is what my project.js looks like:

// ------------------------------------------------------------------
// JOVO PROJECT CONFIGURATION
// ------------------------------------------------------------------

module.exports = {
    defaultStage: 'local',
    stages: {
        local:{
            languageModel: {
                'en-GB': {
                    invocation: 'ebs app local',
                },
                'en-US': {
                    invocation: 'ebs app local',
                },
              },
            endpoint: '${JOVO_WEBHOOK_URL}'
        },
        dev:{
            languageModel: {
                'en-GB': {
                    invocation: 'ebs app dev',
                },
                'en-US': {
                    invocation: 'ebs app dev',
                },
              },
            alexaSkill: {
                nlu: 'alexa',
                skillId: 'amzn1.ask.skill.XXXXXXXXXXXXXXXXXXXXXXXX',
                askProfile: 'aibuser',
                endpoint: 'arn:aws:lambda:eu-west-1:XXXXXXXXXXXXXXXXXXXXXXX',
                manifest: {
                    events: {
                        endpoint: {
                            uri: 'arn:aws:lambda:eu-west-1:XXXXXXXXXXXXXXXXXXXXXXX, // Needs to be Lambda!
                        },
                        subscriptions: [
                            {
                                eventName: 'SKILL_PERMISSION_ACCEPTED',
                            },
                            {
                                eventName: 'SKILL_PERMISSION_CHANGED',
                            }
                        ],
                    },
                },
            },
            googleAction: {
                nlu: 'dialogflow',
                dialogflow: {
                    projectId: 'XXXXXXXXX-XXXXX',
                    keyFile: './XXXXXXXXX-XXXXXX-XXXXXXXXXXXXX.json',
                    endpoint: 'https://XXXXXXXX.execute-api.eu-west-1.amazonaws.com/default/ask-custom-XXXXXXXXXXX'
                }
            },

        },
        prod:{
            alexaSkill: {
                nlu: 'alexa',
                skillId: 'amzn1.ask.skill.XXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
                askProfile: 'aibuser',
                endpoint: 'arn:aws:lambda:eu-west-1:XXXXXXXXXXXXXXXXXXXXXXXXXXXXX,
                manifest: {
                    events: {
                        endpoint: {
                            uri: 'arn:aws:lambda:eu-west-1:XXXXXXXXXXXXXXXXXXXXXXXXXXXXX', // Needs to be Lambda!
                        },
                        subscriptions: [
                            {
                                eventName: 'SKILL_PERMISSION_ACCEPTED',
                            },
                            {
                                eventName: 'SKILL_PERMISSION_CHANGED',
                            }
                        ],
                    },
                },
            },
            googleAction: {
                nlu: 'dialogflow',
                dialogflow: {
                    projectId: 'XXXXXXXXXXXX-XXXXX',
                    keyFile: './XXXXXXXX-XXXXX-XXXXXXXXXX.json',
                    endpoint: ' https://XXXXXXXX.execute-api.eu-west-1.amazonaws.com/default/ask-custom-XXXXXXXXXXXr'
                }
            }
        }
    }
};

Then I got the current model from my existing Alexa App and applied the --reverse --build

jovo get alexaSkill --skill-id amzn1.ask.skill.XXXXXXXXXXXXXXXXXXXXXXXX --reverse --build

Now, what I’m getting quite confused with is the adapting of the model to work on both Alexa and Dialogflow.

I had a few inputs using AWS SYSTEM ENTITIES, and I followed the instructions here

Add System Entities

For instance changing all the occurences of this:

{
  "name": "Income",
  "type": "AMAZON.NUMBER",
  "elicitationRequired": true,
  "confirmationRequired": false,
  "prompts": {
    "elicitation": "Elicit.Slot.1000231380677.925239295350"
  }
},

To this:

{
  "name": "Income",
  "type": {
    "alexa":"AMAZON.NUMBER",
    "dialogflow":"@sys.number
  },
  "elicitationRequired": true,
  "confirmationRequired": false,
  "prompts": {
    "elicitation": "Elicit.Slot.1000231380677.925239295350"
  }
},

Ok this is where I get stuck, I’m trying to deploy the app on my “dev” environment for Alexa

If I build the model everything works fine:

jovo build -p alexaSkill --stage dev

But when I deploy it

jovo deploy -p alexaSkill --stage dev

I get this error:

% jovo deploy -p alexaSkill --stage dev

 jovo deploy: Deploys the project to the voice platform.
   >> Learn more: https://jovo.tech/docs/cli/deploy

  ❯ Deploying Alexa Skill (stage: dev)
    ↓ Updating Alexa Skill project for ASK profile aibuser [skipped]
      → Endpoint: arn:aws:lambda:eu-west-1:279380093719:function:ask-custom-ebs_test-aibuser
    ❯ Deploying Interaction Model, waiting for build
      ✖ en-GB
        en-US
      Enabling skill for testing
 ›   Error: There was a problem:
 ›
 ›   [ERR] askApiUpdateModel:Request is not valid.
 ›
 ›   Module:   jovo-cli-platform-alexa
 ›   Hint:     Parsing error due to invalid body.
 ›
 ›

Do you have any idea of what I could possibly be doing wrong?

Thanks,
Salvo


#2

I’ve figure out the problem,

The issue was that my ask cli was outdated so I’ve updated it following this tutorial:
https://developer.amazon.com/en-US/docs/alexa/smapi/ask-cli-v1-to-v2-migration-guide.html

I had to delete the models I had initially pulled from the existing skill and repeat this command:

jovo get alexaSkill --skill-id amzn1.ask.skill.XXXXXXXXXXXXXXXXXXXXXXXX --reverse --build

I’ve modified the inputs adding dialogflow attributes again and rebuilt the project.

So I think I’m one step closer, the error that I’m getting now is the following:

jovo deploy -p alexaSkill --stage dev

 jovo deploy: Deploys the project to the voice platform.
   >> Learn more: https://jovo.tech/docs/cli/deploy

  ❯ Deploying Alexa Skill (stage: dev)
    ✖ Updating Alexa Skill project for ASK profile aibuser
      Deploying Interaction Model, waiting for build
      Enabling skill for testing
 ›   Error: There was a problem:
 ›
 ›   [ERR] smapiUpdateAccountLinkingInformation:Account linking information is not valid.
 ›
 ›   Module:   jovo-cli-platform-alexa
 ›   Hint:     Object instance at property path "$.accountLinkingRequest" has missing required property: "clientSecret".

I think I’d need to modify project.js to add in the clientSecret somehow, but there is no documentation regardin that.

Could anyone point me in the right direction?

Thanks,
Salvo


#3

I’ve found the error.

Well, I had a few problems:

  1. I misunderstood something in the documentation:
    https://www.jovo.tech/tutorials/alexa-model-to-dialogflow#add-system-entities

Where is says “You can add it by adding a dialogflow element to the input” I was doing a search and replace in my model file for all occurrences of:

"type": "AMAZON.NUMBER",

and replacing it with

"type": {
    "alexa": "AMAZON.NUMBER",
    "dialogflow": "@sys.number"
  }

This is wrong, the change has to be done only within the “intents” subsection (1st level from root) not on the whole file
21

  1. the generated accountLinking.json (/platforms/alexaSkill/skill-package/accountLinking.json) file was missing the clientSecret field ( this is because I hadn’t set it in the Alexa Console), so I added it manually.

I tried the deployment again and everything worked.

Thanks,
Salvo


#4

Great, thanks for the update! Closing this.


closed #5