问题描述
我有 namecheap 共享主机,我在 cpanel 中使用了 node.js 应用程序我创建了一个在 http://roboters.live/shaheen 上运行的应用程序
现在我正在使用 dialogflow,我需要使用 price.js 文件将我的聊天机器人与 excel 文件连接起来,而无需使用内联编辑器
这是文件
const express = require("express")
const app = express();
const rp = require("request-promise-native")
const dfff = require("dialogflow-fulfillment")
app.post("/",express.json(),function(req,res){
dialogflow(req,res)
})
const dialogflow = (req,res) => {
const agent = new dfff.WebhookClient({
request: req,response : res
});
function price(agent){
var From = req.body.queryResult.parameters.From
var To = req.body.queryResult.parameters.To
var Weight = req.body.queryResult.parameters.Weight
var url = "https://sheetdb.io/api/v1/2f53mv3d1o35c/search?From="+From+"&&To="+To
console.log(From)
console.log(To)
console.log(Weight)
console.log(url)
return rp.get(url).then(message =>{
const body = JSON.parse(message)
const pricing = body[0].Price
const price = pricing * Weight
agent.add("Your Price Estimation is " + price + " Usd For Shipping " + Weight + " Kilos From " + From + " To " + To)
console.log(price)
}).catch(err =>{
agent.add("sorry")
})
}
var intentMap = new Map()
intentMap.set("pricing",price)
agent.handleRequest(intentMap)
}
app.listen(3000,function(){
console.log("We are Live");
})
这个显示 不能得到沙欣 当我去roboters.live/shaheen
然后我使用了这段代码,我猜它很糟糕
const express = require("express")
const app = express();
const rp = require("request-promise-native")
const dfff = require("dialogflow-fulfillment")
var http = require('http');
var server = http.createServer(function(req,res) {
res.writeHead(200,{'Content-Type': 'text/plain'});
var message = 'It works!\n',version = 'NodeJS ' + process.versions.node + '\n',response = [message,version].join('\n');
res.end(response);
});
const dialogflow = (req,price)
agent.handleRequest(intentMap)
}
server.listen();
现在为什么它不起作用任何想法? 当我使用 vscode node.js 和 ngrok 时,第一个代码工作正常 但第二个代码在 namecheap 中工作,显示它在 robots.live/shaheen 中工作 但它们都没有使 dialogflow 工作,因为它没有到达服务器 有什么想法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)