Exception handling in webhook response - DialogFlow - actions-on-google

I have started using dialog flow couple of days back. I have used Java API to act as a webhook where every intent invoke the API and it produces response that can be understandable by dialog flow.
There are some occasions where my dialog flow agent request failed with the input from the intents. In this case I couldn't catch the exception in API and it produces 400 Bad request and dialog flow doesn't repsond anything to the user.
Let me know how to do this. There is an inline editor with js and it was handled with exception like this
res.on('error', (error) => {
console.log(Error calling the weather API: ${error})
reject();
});

There is no specific way to handle exceptions in the webhook dictated by Dialogflow, which is why inline editor produced that generic snippet.
If you send a 400 Bad Request from your webhook to Dialogflow, Dialogflow will respond to the user with whatever default response you provided in Dialogflow console for the failed intent. If you didn't provide a default intent response in Dialoflow console and the webhook failed, then your app will not respond anything to user, which is what seems to be happening.
I suggest providing default responses for all intents in the Dialogflow console.

Related

How do i handle url callbacks on my serverless flutter app?

I am testing a crypto payment system on my flutter app, and after generating a random address for payment, the api is supposed to notify me when the transaction has been confirmed using a callback url. I use firestore for my backend, how do i handle this callback url. I will post a copy of the documentation below.
"Insert your URL address where you want to get callbacks in create_payment request. The parameter name is ipn_callback_url. You will receive payment updates (statuses) to this URL address."
for anyone having a similar challenge, i actually solved this problem by writing a http cloud function to help me handle this, then supplied the url to the function as the callback url to the api. SO yes.... http cloud functions was a solution to this problem
Here's a very simple function that can be used:
exports.paymentConfirmation = functions.https.onRequest(async(req, res)=>{
const requestBody = req.body;
const paymentStatus = requestBody.payment_status;
console.log('this is the payment status: ' + paymentStatus);
Promise.resolve();
}
res.send(null);
})
basically you can do anything you want with the request body you get back. In this case i just logged one of the parameters. After deploying this function to firebase, you have access to its url. Problem solved. So when there's an update from the api u subscribed to, it can send a POST request to that url and that triggers whatever code you've written in the function.

how to make a get request to data from response_url of slack api

I am using the slack api in a typescript application, where when I initially send a payload through a slack / command, this payload has a response_url. I am able to post data to this response_url with axios, but I have trouble making a get request to this url to access the data I have previously posted. I have tried axios.get(response_url) and await axios.get(response_url) but I have gotten invoke error with status code 500 and a result of Promise {<pending>} - would anyone know the correct way to use the get call?

How can I integrate the Google Actions responses in a webhook response in Dialogflow?

I am trying to figure out how I can embed Google Actions responses, such as the cards carousel, in a webhook response for DialogFlow.
On https://developers.google.com/actions/dialogflow/webhook, I found the following information:
The response format of the Dialogflow webhook contains the standard Dialogflow webhook response contents and a data.google object that closely resembles a standard conversation webhook response with the following general differences.
So I tried extending the webhook response with a data.google structure as following:
{
"fulfillmentText":"Please select any card you like.",
"data":{
"google":{
...
}
}
}
When testing in the console, I get the following error:
Webhook call failed. Error: Failed to parse webhook JSON response: Cannot find field: data in message google.cloud.dialogflow.v2beta1.WebhookResponse.
Looking to the definition of WebhookResponse, it looks like there is indeed no data field.
I am going around in circles. My question is basically: how can I enrich Dialogflow webhook responses with Google Actions responses?
The documentation for Actions on Google still refers to the Dialogflow V1 protocol documentation and the node.js library from Google only supports the V1 protocol. Since it sounds like you're trying to use Dialogflow V2 Beta, you need to change how you've formatted the JSON.
Instead of using the data.google data structure, as in V1, V2Beta uses the payload.google field (that is, a payload object that has a google object in it). (See https://dialogflow.com/docs/fulfillment#requirements under the "Response" section and click on the V2 tab.)
The payload.google field would be set to the same thing the contents of the data.google field was set to.

Ajax call to Zomato API is not working

I am trying to access zomato api.
URL: https://developers.zomato.com/api/v2.1/categories
Headers: 'X-Zomato-API-Key':'myapikeyhere-763demoapi434'
If I use chrome's postman extension or curl then I can access the url & getting 200 status code.
But if I run it through my angular2 app or simple ajax, it is giving error at preflight OPTIONS request, error code is 501. I have tried otherways too, error is same. Need help
Zomato API's can only be accessed from server to server calls, the error message you have reported is a security policy implemented by Chrome to prevent cross site request forgery on the client side.
A way you can get around this is to write a handler on your server end to make handler which the ajax call will use, this handler in-turn makes a request to the Zomato's server to retrieve the data required.

Why am I getting request method GET not supported?

I am using PostMan as a REST client to test this API method Cisco ACL Analysis API. specifically POST /acl/trace or getAClTracksStd (first go to Policy Analysis)
Here is my PostMan HTTP test call
Does anyone who is familiar with PostMan understand why I am getting this "Request method 'GET' is not supported" error from the server? I am making a POST HTTP request, not GET.(Selected from Drop down menu) It make more sense for me to get a input invalid parameter error or something.
Just to show that the endpoint url works, heres a HTTP test request that works
(same link, host->host API -> GET /host/{startIndex}/{recordsToReturn}
There's two issues that I'm seeing with your REST call. First, the error you're seeing is because the call needs to be preceded by "https://". Second, remove the interface IDs parameter and values. You should get a response with data after making these changes.
Your json looks erronuous (comma after the destIp) - and the server probably always responds with a default confusing error message in this case. (Postman is very well tested and it sends POST).