{"id":634,"date":"2013-02-08T16:08:20","date_gmt":"2013-02-08T15:08:20","guid":{"rendered":"http:\/\/blog.visisoft.de\/yalst\/?p=634"},"modified":"2015-05-28T23:25:54","modified_gmt":"2015-05-28T21:25:54","slug":"new-visitor-javascript-api-for-chat-events-and-actions","status":"publish","type":"post","link":"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/","title":{"rendered":"New JavaScript Visitor Api for Chat Events and Actions"},"content":{"rendered":"<div  style='padding-bottom:10px; ' class='av-special-heading av-special-heading-h4    avia-builder-el-0  el_before_av_codeblock  avia-builder-el-first  '><h4 class='av-special-heading-tag '  itemprop=\"headline\"  >New JavaScript Visitor Api for Chat Events and Actions<\/h4><div class='special-heading-border'><div class='special-heading-inner-border' ><\/div><\/div><\/div>\n\n<section class=\"av_textblock_section \"  itemscope=\"itemscope\" itemtype=\"https:\/\/schema.org\/BlogPosting\" itemprop=\"blogPost\" ><div class='avia_textblock  '   itemprop=\"text\" ><p>Since <em>yalst<\/em> 8.0 it has been easy to drive a text chat on the visitor side using the remote-call <em>Chat API<\/em>. The <em>Chat API<\/em> has methods for sending and getting text, starting, pausing and quitting a chat, checking the availability and so forth.<\/p>\n<p>The <em>Chat API<\/em> is however defined as a pure <em>server side<\/em> API therefore it requires a comparably large effort on the client side &#8211; the visitor&#8217;s browser &#8211; to learn something trivial like if an operator is available for the chat: That is preparing the call parameters, performing a\u00a0<a title=\"Cross Origin Resource Sharing AJAX\" href=\"http:\/\/en.wikipedia.org\/wiki\/Cross-origin_resource_sharing\" target=\"_blank\" rel=\"noopener\">CORS<\/a>\u00a0capable AJAX request and parsing the JSON encoded response.<\/p>\n<p>To alleviate the pain to obtain such frequently needed information on the<em> client&#8217;s browser<\/em> we decided to wrap it together with other publicly available functionality in the JavaScript\u00a0<em>Visitor API for Chat:<\/em><\/p>\n<ul>\n<li>Availability of a support department<\/li>\n<li>Triggering a chat<\/li>\n<li>On-Demand user tracking<\/li>\n<li>Observing the progress of a running chat<\/li>\n<\/ul>\n<p>The <em>VisitorAPI<\/em> provides a greater flexibility in integrating <em>yalst<\/em> into your web pages. E.g. you<\/p>\n<ul>\n<li><span style=\"line-height: 16px;\">have full control over the chat launch buttons,<\/span><\/li>\n<li><span style=\"line-height: 16px;\">can defer the user tracking for &#8220;not important&#8221; visitors,\u00a0<\/span><\/li>\n<li>can change the layout and contents of the page dynamically depending on the state of the live support and progress of a support chat, and<\/li>\n<li>can track the progress (opened, started, joined by operator, finished) of a support chat incident.<\/li>\n<\/ul>\n<h3>Examples:<\/h3>\n<p>To find out if a chat is available<\/p>\n<pre class=\"prettyprint\"><code>\r\nLiveSupport.VisitorAPI.getOperatorAvailability(function(status){\r\n\tswitch(status){\r\n\t\tcase LiveSupport.VisitorAPI.Availability.AVAILABLE:{\r\n\t\t\t\/\/ department \"C\" has operators available for a chat\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase LiveSupport.VisitorAPI.Availability.BUSY:{\r\n\t\t\t\/\/ all operators of department \"C\" are currently busy\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}, \"C\");\r\n<\/code><\/pre>\n<p>To start a chat with the click on a button<\/p>\n<pre class=\"prettyprint\"><code>\r\n$('#chat_button').click(LiveSupport.VisitorAPI.startLiveChat());\r\n<\/code><\/pre>\n<p>To disable the chat button as soon as the chat begins<\/p>\n<pre class=\"prettyprint\"><code>\r\nLiveSupport.VisitorAPI.ChatObserver.asyncSharedChatObserver(function(observer){\r\n\tif (observer instanceof Error){\r\n\t\talert(observer.message);\r\n\t}\r\n\telse{\r\n\t\tobserver.onChatEvent = function(evtOrError){\r\n\t\t\tif (evtOrError == LiveSupport.VisitorAPI.observer.Event.join){\r\n\t\t\t\tstartButton.setAttribute(\"disabled\", \"disabled\");\r\n\t\t\t}\r\n\t\t};\r\n\t}\r\n});\r\n<\/code><\/pre>\n<p>The <em>VisitorAPI<\/em> can be used in conjunction with the regular <em>yalst<\/em> integration code or on its own.<\/p>\n<p>The <a href=\"http:\/\/docs.yalst.de\/visitor_api\/index.html\" target=\"_blank\" rel=\"noopener\">documentation of the current version<\/a> can be found <a href=\"http:\/\/docs.yalst.de\/visitor_api\/index.html\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<p>The <em>VisitorAPI<\/em>\u00a0replaces previously available but unrelated query interfaces like online.js.php and makes them accessible in the Javascript execution context of the visitor&#8217;s browser bundled under the unique namespace LiveSupport.VisitorAPI.<\/p>\n<h3>Browser Compatibility<\/h3>\n<\/div><\/section>\n<div class='avia-data-table-wrap avia_responsive_table'><table class='avia-table avia-data-table avia-table-1  avia-builder-el-3  el_after_av_textblock  avia-builder-el-last  avia_pricing_default '  itemscope=\"itemscope\" itemtype=\"https:\/\/schema.org\/Table\" ><tbody><tr class='avia-heading-row'><th class=''>Feature<\/th><th class=''>Chrome<\/th><th class=''>Firefox<\/th><th class=''>Internet Explorer<\/th><th class=''>Opera<\/th><th class=''>Safari<\/th><\/tr><tr class=''><td class=''>Basic support<\/td><td class=''>2012<\/td><td class=''>2012<\/td><td class=''>Version 8<br \/>\nVersion 7 limited<\/td><td class=''>2012<\/td><td class=''>2012<\/td><\/tr><\/tbody><\/table><\/div><style type='text\/css'>.avia-table-1 td:nth-of-type(1):before { content: 'Feature'; } .avia-table-1 td:nth-of-type(2):before { content: 'Chrome'; } .avia-table-1 td:nth-of-type(3):before { content: 'Firefox'; } .avia-table-1 td:nth-of-type(4):before { content: 'Internet Explorer'; } .avia-table-1 td:nth-of-type(5):before { content: 'Opera'; } .avia-table-1 td:nth-of-type(6):before { content: 'Safari'; } <\/style>\n","protected":false},"excerpt":{"rendered":"<p>The JavaScript Visitor Api for Chat provides a flexible way of integrating pre-chat actions and events; as well as visitor tracking on web pages. E.g. examining the support availability, tracking chat progress and painting click-to-chat buttons are highly customisable.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[46],"tags":[63,68,85],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.12 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>New JavaScript Visitor Api for Chat Events and Actions<\/title>\n<meta name=\"description\" content=\"The JavaScript Visitor Api for Chat provides flexible integration of pre-chat actions and events as well as for visitor tracking on web pages.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"New JavaScript Visitor Api for Chat Events and Actions\" \/>\n<meta property=\"og:description\" content=\"The JavaScript Visitor Api for Chat provides flexible integration of pre-chat actions and events as well as for visitor tracking on web pages.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/\" \/>\n<meta property=\"og:site_name\" content=\"yalst - Live Support | Live Chat | Live Help | Help Desk\" \/>\n<meta property=\"article:published_time\" content=\"2013-02-08T15:08:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-05-28T21:25:54+00:00\" \/>\n<meta name=\"author\" content=\"Matthias Seemann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Matthias Seemann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/\",\"url\":\"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/\",\"name\":\"New JavaScript Visitor Api for Chat Events and Actions\",\"isPartOf\":{\"@id\":\"https:\/\/www.yalst.de\/en\/#website\"},\"datePublished\":\"2013-02-08T15:08:20+00:00\",\"dateModified\":\"2015-05-28T21:25:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.yalst.de\/en\/#\/schema\/person\/32edfd67d7dc13e809181afe316fcccb\"},\"description\":\"The JavaScript Visitor Api for Chat provides flexible integration of pre-chat actions and events as well as for visitor tracking on web pages.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.yalst.de\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"New JavaScript Visitor Api for Chat Events and Actions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.yalst.de\/en\/#website\",\"url\":\"https:\/\/www.yalst.de\/en\/\",\"name\":\"yalst - Live Support | Live Chat | Live Help | Help Desk\",\"description\":\"Ihr umfassender Live Support Chat\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.yalst.de\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.yalst.de\/en\/#\/schema\/person\/32edfd67d7dc13e809181afe316fcccb\",\"name\":\"Matthias Seemann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.yalst.de\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6d883a962ac315cf385799a15783f440?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6d883a962ac315cf385799a15783f440?s=96&d=mm&r=g\",\"caption\":\"Matthias Seemann\"},\"description\":\"Entwickler und Mitglied der Gesch\u00e4ftsf\u00fchrung bei der Visisoft OHG\",\"url\":\"https:\/\/www.yalst.de\/en\/author\/seemannvisisoft-de\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"New JavaScript Visitor Api for Chat Events and Actions","description":"The JavaScript Visitor Api for Chat provides flexible integration of pre-chat actions and events as well as for visitor tracking on web pages.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/","og_locale":"en_US","og_type":"article","og_title":"New JavaScript Visitor Api for Chat Events and Actions","og_description":"The JavaScript Visitor Api for Chat provides flexible integration of pre-chat actions and events as well as for visitor tracking on web pages.","og_url":"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/","og_site_name":"yalst - Live Support | Live Chat | Live Help | Help Desk","article_published_time":"2013-02-08T15:08:20+00:00","article_modified_time":"2015-05-28T21:25:54+00:00","author":"Matthias Seemann","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Matthias Seemann","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/","url":"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/","name":"New JavaScript Visitor Api for Chat Events and Actions","isPartOf":{"@id":"https:\/\/www.yalst.de\/en\/#website"},"datePublished":"2013-02-08T15:08:20+00:00","dateModified":"2015-05-28T21:25:54+00:00","author":{"@id":"https:\/\/www.yalst.de\/en\/#\/schema\/person\/32edfd67d7dc13e809181afe316fcccb"},"description":"The JavaScript Visitor Api for Chat provides flexible integration of pre-chat actions and events as well as for visitor tracking on web pages.","breadcrumb":{"@id":"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.yalst.de\/en\/new-visitor-javascript-api-for-chat-events-and-actions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.yalst.de\/en\/"},{"@type":"ListItem","position":2,"name":"New JavaScript Visitor Api for Chat Events and Actions"}]},{"@type":"WebSite","@id":"https:\/\/www.yalst.de\/en\/#website","url":"https:\/\/www.yalst.de\/en\/","name":"yalst - Live Support | Live Chat | Live Help | Help Desk","description":"Ihr umfassender Live Support Chat","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.yalst.de\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.yalst.de\/en\/#\/schema\/person\/32edfd67d7dc13e809181afe316fcccb","name":"Matthias Seemann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.yalst.de\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6d883a962ac315cf385799a15783f440?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6d883a962ac315cf385799a15783f440?s=96&d=mm&r=g","caption":"Matthias Seemann"},"description":"Entwickler und Mitglied der Gesch\u00e4ftsf\u00fchrung bei der Visisoft OHG","url":"https:\/\/www.yalst.de\/en\/author\/seemannvisisoft-de\/"}]}},"_links":{"self":[{"href":"https:\/\/www.yalst.de\/en\/wp-json\/wp\/v2\/posts\/634"}],"collection":[{"href":"https:\/\/www.yalst.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yalst.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yalst.de\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yalst.de\/en\/wp-json\/wp\/v2\/comments?post=634"}],"version-history":[{"count":9,"href":"https:\/\/www.yalst.de\/en\/wp-json\/wp\/v2\/posts\/634\/revisions"}],"predecessor-version":[{"id":4224,"href":"https:\/\/www.yalst.de\/en\/wp-json\/wp\/v2\/posts\/634\/revisions\/4224"}],"wp:attachment":[{"href":"https:\/\/www.yalst.de\/en\/wp-json\/wp\/v2\/media?parent=634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yalst.de\/en\/wp-json\/wp\/v2\/categories?post=634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yalst.de\/en\/wp-json\/wp\/v2\/tags?post=634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}