簡體   English   中英

Alexa 的 Google 助理技能

[英]Google Assistant Skill for Alexa

我找到了關於如何為 Alexa 創建一項技能的指南,該指南讓我使用 Google 作為搜索引擎(從而將 Google Assistant 集成到 Alexa 中)。 問題是亞馬遜已經升級到 nodejs 16.x,而指南停留在以前的版本上。 我該如何解決這個問題?

在 Amazon AWS 上使用 Lambda 運行測試,它給我的錯誤如下:

{
  "errorMessage": "RequestId: ab04002d-67e6-4144-9c1f-94987a0b8e5e Error: Runtime exited with error: exit status 7",
  "errorType": "Runtime.ExitError"
}

nNODE_MODULE_VERSION 72. This version of Node.js requires\nNODE_MODULE_VERSION 93. Please try re-compiling or re-installing\nthe module (for instance, using `npm rebuild` or `npm install`).","code":"ERR_DLOPEN_FAILED","stack":["Error: The module '/var/task/node_modules/@suldashi/lame/build/Release/bindings.node'","was compiled against a different Node.js version using","NODE_MODULE_VERSION 72. This version of Node.js requires","NODE_MODULE_VERSION 93.

我想我需要通過上傳更新的 zip 文件來修改 Lambda 函數代碼,但我不知道如何或從何處獲取它。

例如,我上傳了這個 zip 文件(github: https ://github.com/rokmohar/alexa-assistant/releases)以將 Node 更新到版本 12.x 並更新 Node 包。 是否可以用 nodejs 16.x 做類似的事情?

我相信問題出在這段代碼中:

{
"AWSTemplateFormatVersion": "2010-09-09",
"Metadata":{
    "License": "Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License"
},
Description: "This AWS CloudFormation Template is provided for users to install the Alexa Google Assistant skill. It is provided under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. This means that you may use this template provided that it is not for commercial use. You may not host instructions that use this CloudFormation template if you receive monetisation from that page, for example embedded adverts",
"Mappings": {
    "RegionMap": {
        "us-east-1": {
            "BUCKET": "alexagoogleassistantskilluseast1"
        },
        "eu-west-1": {
            "BUCKET": "alexagoogleassistantskilleuwest1"
        }
    }
},
"Conditions": {
    "CorrectAWSRegion": {
        "Fn::Or": [
            {
                "Fn::Equals": [
                    {
                        "Ref": "AWS::Region"
                    },
                    "eu-west-1"
                ]
            },
            {
                "Fn::Equals": [
                    {
                        "Ref": "AWS::Region"
                    },
                    "us-east-1"
                ]
            }
        ]
    },
    "IncorrectAWSRegion": {
        "Fn::Not": [
            {
                "Condition": "CorrectAWSRegion"
            }
        ]
    }
},
"Resources": {
    "S3Bucket": {
        "Type": "AWS::S3::Bucket",
        "Condition": "CorrectAWSRegion",
        "Properties": {
            
        }
    },
    "DynamoDBtable": {
            "Type" : "AWS::DynamoDB::Table",
        "Condition": "CorrectAWSRegion",
            "Properties" : {
                "AttributeDefinitions" : [
                  {
                    "AttributeName" : "userId",
                    "AttributeType" : "S"   
                  }
                ],
              "KeySchema" : 
                  [
                      {
                        "AttributeName" : "userId",
                        "KeyType" : "HASH"
                      }
                  ]
                
                ,
              "ProvisionedThroughput" : {
                "ReadCapacityUnits" : 5,
                "WriteCapacityUnits" : 5
              },
              "TableName": "AlexaAssistantSkillSettings"                       
            }
        
    },
    "LambdaFunctionRole": {
        "Type": "AWS::IAM::Role",
        "Condition": "CorrectAWSRegion",
        "Properties": {
            "AssumeRolePolicyDocument": {
                "Version": "2012-10-17",
                "Statement": [
                    {
                        "Effect": "Allow",
                        "Principal": {
                            "Service": [
                                "lambda.amazonaws.com"
                            ]
                        },
                        "Action": [
                            "sts:AssumeRole"
                        ]
                    }
                ]
            },
            "Path": "/",
            "Policies": [
                {
                    "PolicyName": "GoogleAssistantPolicy",
                    "PolicyDocument": {
                        "Version": "2012-10-17",
                        "Statement": [
                            {
                                "Sid": "AllowLogging",
                                "Effect": "Allow",
                                "Action": [
                                    "logs:CreateLogGroup",
                                    "logs:CreateLogStream",
                                    "logs:PutLogEvents"
                                ],
                                "Resource": [
                                    "*"
                                ]
                            },
                            {
                                "Effect": "Allow",
                                "Action": "s3:*",
                                "Resource": [
                                    {
                                        "Fn::Join": [
                                            "",
                                            [
                                                {
                                                    "Fn::GetAtt": [
                                                        "S3Bucket",
                                                        "Arn"
                                                    ]
                                                },
                                                "*"
                                            ]
                                        ]
                                    }
                                ]
                            },
                            {
                                "Effect": "Allow",
                                "Action": "dynamodb:*",
                                "Resource": [
                                    {
                                        "Fn::Join": [
                                            "",
                                            [
                                                {
                                                    "Fn::GetAtt": [
                                                        "DynamoDBtable",
                                                        "Arn"
                                                    ]
                                                },
                                                "*"
                                            ]
                                        ]
                                    }
                                ]
                            }
                            
                        ]
                    }
                }
            ]
        }
    },
    "AlexaSkillFunction": {
        "Type": "AWS::Lambda::Function",
        "Condition": "CorrectAWSRegion",
        "Properties": {
            "FunctionName": "alexa-assistant-skill-function",
            "Handler": "index.handler",
            "Role": {
                "Fn::GetAtt": [
                    "LambdaFunctionRole",
                    "Arn"
                ]
            },
            "Description": "Alexa Skill code for the Google Assistant Skill",
            "Code": {
                "S3Bucket": {
                    "Fn::FindInMap": [
                        "RegionMap",
                        {
                            "Ref": "AWS::Region"
                        },
                        "BUCKET"
                    ]
                },
                "S3Key": "index_1.2.zip"
            },
            "Runtime": "nodejs16.x",
            "Timeout": "10",
            "MemorySize": "1344",
            "Environment": {
                "Variables": {
                    "S3_BUCKET": {
                        "Ref": "S3Bucket"
                    },
                    "API_ENDPOINT": "embeddedassistant.googleapis.com"
                }
            }
        }
    },
    "AlexaSkillFunctionPermissions": {
        "Type": "AWS::Lambda::Permission",
        "Condition": "CorrectAWSRegion",
        "Properties": {
            "FunctionName": {
                "Ref": "AlexaSkillFunction"
            },
            "Action": "lambda:InvokeFunction",
            "Principal": "alexa-appkit.amazon.com"
        }
    }
},
"Outputs": {
    "FunctionARN": {
        "Condition": "CorrectAWSRegion",
        "Value": {
            "Fn::GetAtt": [
                "AlexaSkillFunction",
                "Arn"
            ]
        },
        "Description": "Lambda function ARN to be placed in the Amazon Developer Portal"
    },
    "FunctionError": {
        "Condition": "IncorrectAWSRegion",
        "Value": "Incorrect AWS Region!!! Must be US-East(N. VIRGINIA) or EU(Ireland)",
        "Description": "You must Select US-EAST (North Virgina) if you are located in North America or EU (Ireland) if you are located elsewhere"
    }
}

}

謝謝您的幫助。

我是上面包的作者。 它剛剛更新為使用 NodeJs 18.x 和最新的 ASK SKD v2。 您能否嘗試使用最新版本(當前為 1.5.0)進行設置,並告訴我它是否適合您。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM