这是密码。为测试添加了硬编码值。
Axios添加到package.json中,启用了意图的实现。
function workerHandler(agent) {
const {
name, phone, date
} = agent.parameters;
const data = [{
name: "Akash",
phone: "1234567891",
date: "5 July"
}];
axios.post = ('https://sheet.best/api/sheets/------', data);
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
intentMap.set('saveData', workerHandler);
// intentMap.set('your intent name here', yourFunctionHandler);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
});
请帮帮忙。
发布于 2020-07-05 16:07:50
您的代码有许多问题。
首先,您似乎是在为axios.post分配任务,而不是试图调用它,尽管语法看起来也不太正确。应该有点像
axios.post( url, data );您还需要返回它(以及它的随后/捕获)链返回的承诺,这样Dialogflow的处理程序dispatcher知道等待承诺完成。所以这看起来更像是
return axios.post( url, data );但是,由于您需要错误处理,并且应该向用户发送响应,所以这看起来可能更像
return axios.post( url, data )
.then( () => {
agent.add( "Saved" );
})
.catch( err => {
console.error( err );
agent.add( "Something went wrong" );
});https://stackoverflow.com/questions/62742331
复制相似问题