繁体   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