diff --git a/app/assets/javascripts/webchat/README.md b/app/assets/javascripts/webchat/README.md index c82f73e9b..55d5d155c 100644 --- a/app/assets/javascripts/webchat/README.md +++ b/app/assets/javascripts/webchat/README.md @@ -1,65 +1,22 @@ -### GOVUK webchat +# Webchat Component -GOV UK webchat has been made to make it easy to implement webchat across all GOV.UK pages. -Departments within government have multiple webchat integrations, and we cannot support them all. +This Webchat can represent four 'busy', 'unavailable', 'available', 'error'. -To this end, we have created a unified API for the javascript implementation, and recommend that departments implement a proxy for their own availability api. +## Supporting backend API Proxy +See the [reference implementation](https://github.com/alphagov/reference-webchat-proxy) for the backend API that is used alongside this component. -#### availability api implementation +## Usage -we have [made a reference implementation](https://github.com/alphagov/reference-webchat-proxy) of a proxy for the egain api to illustrate how you would create one. +The Webchat should be accessed through a shared [shared partial](https://github.com/alphagov/government-frontend/blob/957e3fb325eb3ff78b277ceb7054417849009756/app/views/shared/_webchat.html.erb) in which you need to pass the locals `webchat_availability_url` and `webchat_open_url`. +`webchat_availability_url` will be polled at an interval to check for the webchat instances' avaliability. -##### the api needs to respond with the following ---- -###### webchat has a technical error -any response that does not conform to an available response type will render a technical error, -as will a non 200 type response. +`webchat_open_url` is the page that will be opened when a user clicks the webchat call-to-action showm in the 'avaliable' state. -``` - { - status: "failure", - response: "A_RANDOM_FAILURE_STATE" - } - -``` -###### WebChat is available -``` - response code: 200 - { - status: "success", - response: "AVAILABLE" - } -``` -###### WebChat is unavailable -``` - response code: 200 - { - status: "success", - response: "UNAVAILABLE" - } -``` -###### WebChat is busy -``` - response code: 200 - { - status: "success", - response: "BUSY" - } -``` ---- - -#### usage - -to use the webchat implementation we have a [shared partial](https://github.com/alphagov/government-frontend/blob/957e3fb325eb3ff78b277ceb7054417849009756/app/views/shared/_webchat.html.erb) in which you need to pass the locals `webchat_availability_url` and `webchat_open_url`. -the webchat_availability_url is your proxy as documented above -the webchat_open_url is what page to actually open for webchat, we recommend you push this through the proxy as well - - -once you have your partial rendering on the page, you will need to make sure the [library](https://github.com/alphagov/government-frontend/blob/957e3fb325eb3ff78b277ceb7054417849009756/app/assets/javascripts/webchat/library.js) is included on your page and this in your initialisation code. +Finally once you have your partial rendering on the page, you will need to make sure the [library](https://github.com/alphagov/government-frontend/blob/957e3fb325eb3ff78b277ceb7054417849009756/app/assets/javascripts/webchat/library.js) is included on your page and this in your initialisation code. ``` $('.js-webchat').map(function () { @@ -71,5 +28,7 @@ once you have your partial rendering on the page, you will need to make sure the ``` a fuller example can be seen [here](https://github.com/alphagov/government-frontend/blob/957e3fb325eb3ff78b277ceb7054417849009756/app/assets/javascripts/webchat.js#L31-L41) that has an implementation of the normalisation as noted below -##### note regarding response Normalisation -as can be seen in the fuller example above, we currently have the option to do the normalisation in javascript, this is deprecated, and is shim code until all current users of webchat have there own proxies up and running +### Note regarding response Normalisation +As can be seen in the fuller example above, we currently have the option to do the normalisation in JavaScript, this is deprecated, and is shim code until all current users of Wbchat have their own proxies up and running. + +Once this shim is removed we can move this component into Static as a GOV.UK Publishing Component