Besides log every location changes, I would also like to log these click events as a lot of the time user would click on sth and that click would not update location hash. It would be helpful if it's possible to log these events by intercepting calls made to action helper. I've tried hacking around and no luck so far. I can still log them in the event handlers. It's just feels a little bit verbose. Does anyone have similar problem? Any ideas?
To make it clear, for example instead of in the route or controller having some code like below, the call made to google analytics could being triggered whenever action event fired.
clickMe: function(){
App.Analytics.logEvent({category: "userEvent", action: "click", label:"click me", value: 1});
},
I've tried to define a customized helper which is basically a wrapper around action helper, it makes a call to log down google analytic events using the information got from its caller and then internally call ember's action helper. I use my own helper in the template to try out, but log events only happened the first time that template rendered. If I keep click on the view no user activity gets logged.
You can use the event bubbling mechanism of javascript to do this. In any Ember view adding a handler named for an event will setup a listener for that event automatically.
By placing such a click handler on the ApplicationView you can listen in on all clicks for all it's nested views.
App.ApplicationView = Em.View.extend({
click: function(event) {
console.log('ApplicationView.click', event);
}
});
From here you can use this.get('controller').send(event) to notify the controller, route, etc to get to the function that calls the google analytics code.
Related
Dialogflow ES has an event called 'WELCOME' which makes it possible for the bot to initiate the conversation.
How can I do the same in Dialogflow CX?
There is no entry fulfillment option in the Start Page of Dialogflow CX.
Edit:
Delete the 'Default Welcome Intent' route.
I am unable to perform this. I get the following error.
In 'Default Welcome Intent' change the intent from 'WELCOME' to nothing.
I get the following error. I have set the condition to true. I have also set the page transition to 'onboarding' page.
Please let me know if more screenshots are required.
To accomplish what you're asking, the easiest way would be to:
Open the "Default Start Flow" and select its Start page.
Remove all routes and add a new one.
This new route takes a "custom condition" in the form of true (in the condition pane, click on customize expression and then just type true) and goes to a new page
called "Onboarding" (on the bottom of the route creation page, click on new page and name it Onboarding).
Go to the Onboarding page and add an entry fulfilment "Hello there, how are you doing today?"
in this way every time the default start flow is activated (window is opened) the bot will use that fulfilment.
EDIT:
ok, i tried creating a new agent and i think i solved the problem.
it seems as though we can't erase the default welcome intent, but it doesn't matter.
i created two pages: onboarding and first page. from start i added an always true route to the onboarding page, and i did the same with the onboarding and first page. As you can see from the testing console we only get the expected behaviour for the second transition, look at this:
start page:
onboarding page:
"first" page:
After looking for info on the documentation i think i understood this: from the testing console, google doesn't let you see the actual behaviour of the conversation. If you see the screenshots, when i say "hi" and go the the onboarding page, i get immediately brought to the next page by that "true" transition. Since the same exact sequence is on the start page, the same behaviour should apply there: you only can't see it in the console because "opening the window" in the console is not the same as opening the conversation "in real life".
So, what i suggest you to do is create a new integration or develop a testing environment for the bot, say a website with the messenger integration, a telephony integration or whatever else, and test this onboarding on there. Speaking from personal experience, try with the messenger one maybe: you get a link and you just embed the script in any webpage (works well and easy).
It should work, as in, as soon as you open the conversation, the bot should go the onboarding page and say "hello there!"
So, I'm not sure what your end use-case is, but DFCX (at it's core) isn't exactly designed to initiate an unsolicited message because it's really just a language model with a bunch of features built on top of it.
With that being said, if you want to create a pop-up window for your website chat-widget, you can actually configure this in the integration settings with your embed code. Here's an example:
//The DF Messenger element:
<df-messenger df-cx="true" chat-title="Agent Name" agent-id="<your agent ID>" language-code="en" expand="true"></df-messenger>
//The window load script :
<script src="https://www.gstatic.com/dialogflow-console/fast/messenger-cx/bootstrap.js?v=1"></script><script>
window.addEventListener('dfMessengerLoaded', function (event) {
const dfMessenger = document.querySelector('df-messenger');
const openText = ('<The Text You Want To Display On Page Load>');
dfMessenger.renderCustomText(openText);
});
</script>
Please note this will only work if you have the DF Messenger Integration enabled on your agent. See the docs for integrating DF Messenger here
1.Use the attribute intent inside the df-messenger tag in your UI/HTML page
2.Then create a Custom Event in Dialogflow CX (By clicking on Event handler '+' icon)
3.Check the 'use custom event' checkbox and provide event name and provide a text response in fulfillment section of this custom event.
4.Finally provide this custom event name as value to the attribute intent(mentioned in step 1)
please refer to this document for df-messenger HTML customizations https://cloud.google.com/dialogflow/cx/docs/concept/integration/dialogflow-messenger#html-customize
According to Dialogflow CX documentation, the WELCOME event (although not visible in the Start flow) is also available. As you can see in this link and the picture below.
To invoke this event, you have to use the detectIntent method of a Session client. You'll need to specify the event name in queryInput.event.event of the request used in detectIntent.
Hope this helps!
The first time i login into my application, it will transit to application index and from there I want to transit to my home route. The issue is that the application-loading and its corresponding template won't be triggered. I was wondering what i am missing here. I have noticed that if i am in my home route and i refresh the page, it will trigger application-loading substate.
return true within your index route's action.loading function so that after that loading hook fires, the event will continue to bubble up to your application route.
I'm having a weird issue in ember js with sending actions from one route/controller to another route. The action never hits the other route's action handler. I can send actions from controller to controller, from same controller to same route, but not an additional hop from one controller/route to another route handler.
Ultimately what I'm trying to achieve is sending an action from one route users.new to another route, users.login. The action isn't handled in users.login's controller so I was assuming that it would bubble to the users.login route action handler.
Any help is very much appreciated!
Actions bubble to controllers and then to its route and then the ancestors of that route. They are not used for communication across/between routes.
The question is, what do want the action to do? It sounds quite a bit like you really want to transition to a route, instead of sending an action to it or its controller. If you want to pass parameters along with the transition, you can do so using query parameters.
If you could provide more details or existing code, we might be able to give you some specific code fragments.
If for some reason you are real sure you want to communicate between routes and controllers, you can use Ember events. You send them using this.trigger('event') and listen for them using object.on('event', handler). However, I doubt if you need this for the problem you are trying to solve.
I have no idea how session services are supposed to address this problem. Normally, a session service is how you would keep track of session (user) information in a way accessible to very controller/route etc.
Sending actions from peer routes does not work. The solution is to create a session service.
Is there a way to distinguish access through external link (e.g. from history, or from other site) or access by link from other page of the same app in beforeModel handler?
Here is my case:
If user accesses my app by direct link and requests route requiring authenticated user, I make a transition to index route and show popup with an authorization form.
If user is already on my site and trying to access the requested route requiring authenticated user, I abort transition and show the popup on a previous page.
I have no separate page for authentication.
My current work around is to check some strange private property called sequence of transition object which has been passed to beforeModel handler, if transition.sequence === 0, then user came from "outside", otherwise user follow by link "inside" my app.
I think this is a bad way to achieve the goal, core developers can remove sequence property any time.
So, is there any clean way to distinguish whether current route was requested from "outside" or "inside" of my app?
I'll appreciate any help, thanks!
P.S. EmberJS v1.10.0
P.S.S. Sorry for my English
If you want to avoid using an internal call you could keep track of the history in the application route something like this Implementing a "conditional" back button in ember.js
But in your router would probably be better since controllers are going away soonish.
You could probably use http://emberjs.com/api/classes/Ember.Route.html#event_didTransition
UPDATE after chatting
Logic for counting, aborting, etc transitions can be done in the willTransition action in application route http://emberjs.com/guides/routing/preventing-and-retrying-transitions/
In ember.js I need to trigger a modal box create when I enter inside an URL, and to trigger its destruction when i leave it.
Do you know what events i can observe?
Will they be triggered in the controller or in the route?
And, finally, where can i find the documentation for this? I couldn't find any in ember.js site
I tried the enter and leave event, but they are triggered only once, and in the wrong moment
Thanks in advance
Look at activate and deactivate hooks on the Ember.Route.
http://emberjs.com/api/classes/Ember.Route.html