The "last chance" component is a modal window that returns search results when a user wants to initiate a contact. As the name indicates, it is the last try to get a match before a ticket is created.
This component does not track the contact_ticket event, however you should log when a ticket is created. See the Tracking section below to see how you can log contact_ticket.
How to create this component.
sdk.component('lastChance', '#target', options);
By default, this component looks like this:
This is the HTML component. For example, the "#inbenta" target is:
<div id="inbenta"></div>
Available options to set in this component
Name | Type | Default | Description |
---|---|---|---|
categoryId | integer | 0 | Knowledge instance category Id |
maxResults | integer | 3 | Maximum number of shown results. Minimum: 1. Max: 100. |
Methods can be used in this component.
Method | Description |
---|---|
show(query:string) |
Show the last chance modal. If the query is defined will do the search with that query, if not, will do the search with the linked inputs |
hide() |
Hide the last chance modal |
setQuery(query: String) |
Set the current query |
setContentsDataInterceptor(interceptor:function) |
Set a contents interceptor. |
setRelatedDataInterceptor(interceptor:function) |
Set a related interceptor. |
This component has some components inside which can be configured. This components are:
Name | Description |
---|---|
contents | Component to render each content |
Events to listen on this component:
Name | Params | Description |
---|---|---|
click | content : Content object |
Sent whether a content is clicked |
expand | content : Content object |
Sent whether a content is expanded |
relatedClick | integer : Related content id |
Sent whether a related content is clicked |
decisionTreeClick | decisionTree : Decision tree object |
Sent whether a decision tree content is clicked |
rateContent | rating : Rating object |
Sent whether a content rating is clicked |
submit | null |
Sent whether the user clicks the submit button |
cancel | null |
Sent whether the user clicks the cancel button |
This component calls the API to do the following:
/search request
with the type
parameter set to contact to get the result of the question and track the search as contact./tracking/events
endpoint.Labels of this component. The default labels of each component can be rewritten in the SDK creation configuration.
Name | Default | Description |
---|---|---|
LAST_CHANCE_TITLE | Last Chance |
The text for the title of the component |
LAST_CHANCE_CANCEL | Cancel |
The text for the cancel button |
LAST_CHANCE_SUBMIT | Submit |
The text for the submit button |
The example below shows a Last Chance component that is linked to a textarea, which is placed within a generic form. When the user submits the form, it shows the Last Chance component. Clicking the submit
button on the component creates the ticket and logs the contact_ticket event.
var lastChance = sdk.component('lastChance', '#last-chance', {});
lastChance.linkToInput(document.getElementById('textarea'));
// Submit form
document.getElementById('form').addEventListener('submit', function(event) {
lastChance.show();
});
lastChance.$on('submit', function() {
// Send ticket
<code to send the ticket>
// Track the contact_ticket event
sdk.client.track(
'contact_ticket',
{
'value': lastChance.getQuery()
}
);
});