Button Type

(Autogenerated transcript)

[00:00:00]
 Alright, so next we are going to see the button response type and this one is a little bit tricky that's what I would say. So to get started let's go to the agent and create an intent called show button type. Let the phrase be show me button that's sufficient and what I'm going to do is copy this, go to the intent, delete this text response, add the custom payload, paste whatever I got from there and instead of example.com I'm going to change it to google.com so that it's a real actual valid site. I also want you to notice something. Notice that it has this event field inside the rich content. So you can see that the event field has three fields, the language code, so I'm going to make it en and since we have an event called parallel I'm going to add that into this

[00:01:00]
 name over here and I'm not going to pass any parameters to that event. So let's just save that. So you can see that there is some text which is just called button text. There is an icon and there is this event and there is the type which explains what type it is to Dialogflow. In this case it's a button and then you have this finally this hyperlink. So if you go to the editor and if you ask for this type of response show me button. So it did come back with the response that's great and also notice that it's a clickable button right. Now if I click on it I want you to see what actually happens. So I'm going to click on it. Now this is good because it is opening the URL that is specified in a new tab and then

[00:02:00]
 when you go back to the page which had the chat widget you also see that it comes back with this hello from the parallel universe. Now this is coming here because we had this event called parallel. When you click on this button it opened this google.com URL and also it sent this, it sort of invoked the event called parallel in your agent and of course we know that if you do that it's going to come back with this response hello from the parallel universe. Now this is all fine and this is sort of expected but the problem with the button type is that its behavior is not changing even if I remove that link. So here is what I'm going to do. I'm going to remove this link from the button and I'm going to save it now. So let's start this fresh and go here say show me button and I want you to notice something.

[00:03:00]
 When I click on it, it actually opened a new window even though I didn't specify anything in the link. What it really did is sort of like it went back to the page where it was already there to the same URL just as if it navigated to no other, no new URL it just stayed on the same page except that of course you are in a new tab and this is where the old tab is still is which has the actual widget like with all your interactions. But it did invoke the event. So what's happened here is even after I removed the link, it went to the page which was like a blank page so it just reloaded the page, the same page where this widget resides and it also invoked the event that we have over here. So this is not good behavior. So when I have both the event and the link, first of all I don't think that's good design

[00:04:00]
 but even let's say we permit that. But if I remove the hyperlink, it should not open a new tab when I click on it. If there is no link field, it should just, if I click on this, all it should do is invoke the event and come back with a response. It's unnecessarily opening this new tab and confusing everybody. And of course you see that I clicked it one more time and it came back with the same event which was invoked again which is fine, that is expected. So that's the first part of the tricky behavior that I'm talking about. Now let's say that I removed the event. So all I'm left with is the text and the icon and the type. So let's save that. Let's go back to the WebStorm editor, open this page and ask the same question.

[00:05:00]
 Now see it still has this link, right? Now if I click on it, it goes to the new tab without opening a new page. It sort of reloads the same page and it does nothing else which is fine because it's, there is, we removed the event option from the response object. So it's not supposed to do anything else here. So what I'm trying to say is that even though there is a feature which is allowing you to click on the button and invoke an event so that it goes to a new intent in the agent, my suggestion would be to use this purely as a button which has a hyperlink which goes to a different page. In other words what I'm saying is, let's go back here and I want to see what's there. So let's take this, this guy over here and let's paste it and also make sure we change

[00:06:00]
 the URL so this is valid. So what I'm saying is just keep it like this. Just have your text and the icon and the type and the link and don't use the event because it would not work as you anticipate. It might be a bug. I hope it is and I hope that the Dialogflow team changes this very soon. But for now it's not a reliable response type and I think that the only use for it, the way it works right now is to be able to have a hyperlink with a button which is like the whole thing should be clickable if that's what you want like this. If you want, this is the behavior that you want. Yeah, that's fine. Then go ahead and use the button. But otherwise I'm going to recommend that you don't use this button type unless they fix this issue and make it either or behavior.