[英]How to return node js output to test-bot (aws-lex) frpm aws lambda
I am new to AWS lambda, lex and node-js, so this is very basic question: 我是AWS lambda,lex和node-js的新手,所以这是一个非常基本的问题:
I am trying to write a node-js lambda function which will return simple command output to test-bot (lex), I am able to log the correct output to cloud-watch but same is not getting returned to the test-bot - I believe that I have to use something like callback (I am able to return hardcoded string to auto-bot but not able to return my command's output) but not sure how to use it, below is code snip which I am trying to run, can you pl. 我正在尝试编写一个node-js lambda函数,该函数将简单的命令输出返回到测试机器人(lex),我能够将正确的输出记录到cloud-watch,但同样没有返回到测试机器人-我相信我必须使用回调之类的东西(我能够将硬编码的字符串返回给自动机器人,但不能返回命令的输出),但不确定如何使用它,下面是我尝试运行的代码片段,可以你请 help 救命
var SSH = require('simple-ssh')
var ssh_test = new SSH({
host: 'xx.xx.xx.xx',
user: 'xyz',
pass: 'xyz'
});
exports.handler = (event, context, callback) => {
var test = event.currentIntent.slots.purchase,
ssh_test.exec('ls /tmp/', {
out: console.log.bind(console)
})
.exec('exit', {
out: console.log.bind(console)
}).start();
callback(null, {
"dialogAction": {
"type": "Close",
"fulfillmentState": "Fulfilled",
"message": {
"contentType": "PlainText",
"content": "I AM ABLE TO RETURN THIS HARDCODED STRING TO BOT" //ALONG WITH THIS I WANT TO APPEND COMMAND OUTPUT ('ls /tmp/')
}
}
});
}
Try this, 尝试这个,
var SSH = require('simple-ssh')
var ssh_test = new SSH({
host: 'xx.xx.xx.xx',
user: 'xyz',
pass: 'xyz'
});
exports.handler = (event, context, callback) => {
var test = event.currentIntent.slots.purchase,
ssh_test.exec('ls /tmp/', {
out: console.log.bind(console)
callback(null, {
"dialogAction": {
"type": "Close",
"fulfillmentState": "Fulfilled",
"message": {
"contentType": "PlainText",
"content": "I AM ABLE TO RETURN THIS HARDCODED STRING TO BOT" //ALONG WITH THIS I WANT TO APPEND COMMAND OUTPUT ('ls /tmp/')
}
}
});
})
.exec('exit', {
out: console.log.bind(console)
}).start();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.