简体   繁体   English

Alexa 的 Google 助理技能

[英]Google Assistant Skill for Alexa

I found a guide on how to create a skill for Alexa that made me use Google as a search engine (thus integrating Google Assistant into Alexa).我找到了关于如何为 Alexa 创建一项技能的指南,该指南让我使用 Google 作为搜索引擎(从而将 Google Assistant 集成到 Alexa 中)。 The problem is that Amazon has upgraded to nodejs 16.x, while the guides are stuck on previous versions.问题是亚马逊已经升级到 nodejs 16.x,而指南停留在以前的版本上。 How can I solve the problem?我该如何解决这个问题?

Running a test using Lambda on Amazon AWS, the error it gives me is the following:在 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.

I think I need to modify the Lambda function code by uploading an updated zip file, but I don't know how or where to get it.我想我需要通过上传更新的 zip 文件来修改 Lambda 函数代码,但我不知道如何或从何处获取它。

For example, I uploaded this zip file (github: https://github.com/rokmohar/alexa-assistant/releases ) to update Node to version 12.x and update Node packages.例如,我上传了这个 zip 文件(github: https ://github.com/rokmohar/alexa-assistant/releases)以将 Node 更新到版本 12.x 并更新 Node 包。 Is it possible to do a similar thing with nodejs 16.x?是否可以用 nodejs 16.x 做类似的事情?

I believe the problem is in this code:我相信问题出在这段代码中:

{
"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"
    }
}

} }

Thanks for the help.谢谢您的帮助。

I am the autor of the package above.我是上面包的作者。 It was just updated to use NodeJs 18.x and latest ASK SKD v2.它刚刚更新为使用 NodeJs 18.x 和最新的 ASK SKD v2。 Can you try to setup with the latest version (currently 1.5.0) and let me know if it works for you.您能否尝试使用最新版本(当前为 1.5.0)进行设置,并告诉我它是否适合您。

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

相关问题 如何在浏览器上打开alexa skill? - How to open alexa skill on browser? alexa 在调用技能时发送 SessionEndedRequest - alexa sending SessionEndedRequest on skill invocation 将数据上传到 Firesbase 后 Alexa 技能没有响应 - Alexa skill not responding after uploading data to firesbase 获得技能并没有在 alexa 开发中提供有效的回应 - Getting skill did not provide a valid response in alexa development 如何为 Alexa 技能意图响应获取和使用确认“是”或“否” - How to get and use confirmation 'yes' or 'no' for Alexa skill intent response Alexa Skill 请求反序列化失败 - json 到 SkillRequest object C# - Alexa Skill request deserialization fails - json to SkillRequest object C# 亚马逊 Alexa 阅读谷歌电子表格 - Amazon Alexa reading Google Spreadsheets 是否可以在没有任何用户操作的情况下动态更改 Alexa 技能显示的内容? - Is it possible to change contents dynamically which Alexa skill shows without any user actions? 使用 google assistant/google home 自动打开 URL - automatically opening URL with google assistant/google home 如何为 Alexa 技能调用配置 MQTT (AWS IoT) 测试控制台? - How do configure the MQTT (AWS IoT) test console for an Alexa skill invocation?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM