May 2020
Intermediate to advanced
404 pages
10h 52m
English
We'll be adding the code required to call the API of our order management system. Add the following function inside the dialogflowFirebaseFulfillment object definition:
function checkOrderStatus(){ const request = require('request-promise-native'); var orderId = agent.parameters.OrderId; var url = "https://example.com/api/checkOrderStatus/"+orderId; return request.get(url) .then(jsonBody => { var body = JSON.parse(jsonBody); agent.add("Your order is: " + body.order[0].order_status); return Promise.resolve(agent); }) .catch(err => { agent.add('Unable to get result'); return Promise.resolve(agent); }); }
At the end of the file, just before ending the dialogflowFirebaseFulfillment object definition, add the ...
Read now
Unlock full access