我有一个正在组装的Google Dialogflow应用程序,它有许多需要使用外部REST处理的实现。我已经设置好了客户端并使用了firebase serve
,使我能够在本地进行测试。我的index.js函数具有以下符号:
exports.clientEmployeeServiceCodes = functions.https.onRequest(async (req, res)=>{...});
但是当我在本地运行时,我通过url传递的任何请求参数都是未定义的。下面是一个例子。
http://localhost:5000/arc-caregiver-f8ec9/us-central1/clientEmployeeServiceCodes?phone=%22%%2b12123003939%22
但是当我通过Dialogflow调用时,我会得到参数。所以我的问题是,我是否做错了什么,或者是否有一种方法可以在我的url调用中模拟这些参数,以便该方法的行为就像我在Dialogflow中调用它一样。
下面是我通过req对象获取Dialogflow参数的示例。注意我是从哪里得到引脚的值的。
exports.userHours = functions.https.onRequest(async (req, res)=>{
const start = MyUtils.getDatePlus(-14);
const end = MyUtils.getDatePlus(14);
var view = 'API_Pay_Periods';
var form = 'Pay_Periods';
var criteria = 'Pay_Period_Date >= "'+start+'" %26%26 Pay_Period_Date <=
"'+end+'"'
const ret = await callRestAPI(Config,view,form,criteria);
const pp = getPayPeriod(ret);
const pin = req.query.pin
console.log('pin',pin)
const data = await RESTAPI(Config, view,form,criteria);
res.status(200).send(response);
....
res.end();
});
发布于 2019-05-22 10:27:13
Dialogflow通过POST将其履行信息通过JSON object in the body of the request发送到您的webhook。您不能通过在URL本身中发送查询参数来重复此操作。
一种典型的处理方法是设置一个到本地环境的ngrok tunnel,并使用它来记录发送的JSON体。然后,您可以使用相同的主体进行稍后的测试。
https://stackoverflow.com/questions/56244731
复制相似问题