简体   繁体   English

AWS Lex 机器人在 lex 机器人的履行部分调用 lambda function,我看不到可以调用 lambda function 的地方

[英]AWS Lex bot calling a lambda function in fulfilment section of the lex bot, I don't see a place to call the lambda function

I created a lex bot to call weather API from a lambda. The lambda works fine giving the temperature of the city.我创建了一个 lex 机器人来从 lambda 调用天气 API。lambda 可以很好地给出城市的温度。

I am able to call a lambdb from lex bot thanks to for the help from "Reegz"感谢“Reegz”的帮助,我能够从 lex bot 调用 lambdb

Now I get this message "intent findingweather is fulfilled" instead of getting the weather of the city.现在我收到这条消息“intent findingweather is fulfilled”而不是获取城市的天气。 The lambda when I test, works fine, I provide the city name and lambda brings the temperature我测试时的 lambda 工作正常,我提供城市名称和 lambda 带来温度

在此处输入图像描述

  import json
  import boto3
  from pprint import pprint
  import urllib3

  def weatherfunc(city_name):

         api_key = '9100010fc2b045080a7exxf42051e547bdxx'
         base_url = 'http://api.openweathermap.org/data/2.5/weather?'
         finalurl = base_url + 'appid=' + api_key + '&q=' + city_name

         httprequest = urllib3.PoolManager()
         response = httprequest.request('GET',finalurl)
         #pprint(response.data)
         weather_status = json.loads(response.data.decode('utf-8'))
         return weather_status["main"]["temp"]



    def lambda_handler(event, context):   
        city = event['City']
        a = weatherfunc(city)
        

Yeah, Lex V2's console is a little less intuitive when it comes to adding Lambda support to your Lex bot.是的,在向 Lex 机器人添加 Lambda 支持时,Lex V2 的控制台不太直观。

Unlike with Lex V1, in V2 you can only associate one Lambda function for fulfillment to your bot.与 Lex V1 不同,在 V2 中,您只能将一个 Lambda function 关联到您的机器人。

To associate the Lambda function with your Bot, do the following:-要将 Lambda function 与您的机器人相关联,请执行以下操作:-

  • Click on "Test" from the taskbar at the bottom of the "Intents" screen单击“意图”屏幕底部任务栏中的“测试”
  • Click the settings cog in the pop-up window the opens单击弹出窗口中的设置齿轮 window 打开
  • A settings pane will open to the left of the "Test" pane设置窗格将在“测试”窗格的左侧打开
  • The first block called "Lambda function - optional" is where you can select the appropriate Lambda function第一个块称为“Lambda function - 可选”是您可以 select 适当的 Lambda ZC1C4252568E68384F1C14

Given the updated state of the question, please see below for my answers.鉴于问题的更新 state,请参阅下面的答案。

In order to make effective use of Lambda functions to power your Lex bot, you need to pay close attention to the Lex V2 Developer Guide .为了有效地使用 Lambda 功能为您的 Lex 机器人提供动力,您需要密切关注Lex V2 开发人员指南

Specifically, you need to take a close look at the input that your Lambda function receives from Lex and that your Lambda response matches the format that Lex expects.具体来说,您需要仔细查看您的 Lambda function 从 Lex 接收的输入,并且您的 Lambda 响应与 Lex 期望的格式匹配。

Have a look through this workshop and its sample code to see how to correctly work with Lex's input and output formats.查看此研讨会及其示例代码,了解如何正确使用 Lex 的输入和 output 格式。

Try to add this permission to your lambda尝试将此权限添加到您的 lambda

{
  action: "lambda:InvokeFunction",
  principal: new iam.AnyPrincipal(),
}

If it works, you can limit your principal later on如果有效,您可以稍后限制您的本金

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

相关问题 AWS LEX:插槽更新、意图更新,然后通过 Lambda function 发布新的机器人 - AWS LEX: Slot update, intent update and then new publishing bot through a Lambda function 在 AWS lex Lambda 函数中获取 Slack userId - Get Slack userId in AWS lex Lambda function Lex 无法访问 Lambda 函数 - Lex is unable to access the Lambda function Amazon lex 对 Amazon Lambda 函数的未知表述 - Amazon lex unknown utterance to the Amazon Lambda function 如何将 lamda function 关联到 amazon lex 中的机器人别名? - how to associate lamda function to bot alias in amazon lex? slack bot 使用 aws 向用户发送直接消息 lambda function - slack bot sending direct message to user using aws lambda function Amazon Lex:如何在 Lambda function (Python) 中获取插槽的 Elicitation 值? - Amazon Lex : How to get Elicitation value of a slot in Lambda function (Python)? 无法从 Lambda 访问 AWS Lex - Unable to access AWS Lex From Lambda 在 AWS 的 Lambda Function 中调用时无法访问“事件”属性 - Can't access 'event' properties when calling it in Lambda Function in AWS 为什么我在创建 AWS Lambda function 后看不到编辑内联代码和处理程序信息的选项 - why I can't see the option to edit code inline and handler Info on after creating the AWS Lambda function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM