Skip to content

Commit

Permalink
Update docs based on updates the proxy reference
Browse files Browse the repository at this point in the history
  • Loading branch information
NickColley committed Apr 12, 2017
1 parent 2b2b664 commit 217b11e
Showing 1 changed file with 13 additions and 54 deletions.
67 changes: 13 additions & 54 deletions app/assets/javascripts/webchat/README.md
Original file line number Diff line number Diff line change
@@ -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 () {
Expand All @@ -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

0 comments on commit 217b11e

Please sign in to comment.