<commit_before>
Blip SDK for Web
======

SDK to easily add BLiP conversations (chatbots) in your Web page. For more information see [BLiP portal][1] and [BLiP documentation][2].

Installation
--------

Add the script element inside the **body** of your web page. Put your apikey as asked. *To get your apikey go to [BLiP portal][3]. On the left menu access Publications -> Blip Chat.* 
That's all :)

```html
<script src="https://unpkg.com/blip-sdk-web" type="text/javascript"></script>
<script>
   (function () {
      window.onload = function () {
          new BlipWebSDK.ChatBuilder()
            .withApiKey('PUT-YOUR-API-KEY-HERE')
            .build();
          }
        })();
</script>
```

Via npm
--------

If you are using ES6, simply install the `blip-sdk-web` package from the npm registry.

`npm install blip-sdk-web`

### Instantiate the BlipSdkWeb class

```javascript
import * as BlipWebSDK from 'blip-sdk-web';

new BlipWebSDK.ChatBuilder()
  .withApiKey('PUT-YOUR-API-KEY-HERE')
  .build();
```

Via bower
--------

`bower install blip-sdk-web`

```html
<script src="your-project/bower_components/blip-sdk-web/dist/blipWebSdk.js" type="text/javascript"></script>
<script>
  (function () {
    new BlipWebSDK.ChatBuilder()
      .withApiKey('PUT-YOUR-API-KEY-HERE')
      .build();
  })();
</script>
```

Via AMD
--------

This SDK use UMD to module export. If your project use same AMD, please use 'BlipWebSDK' identifier to resolve the library dependency.

### For instance:

A application that use dojo.js as your AMD

```html
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.12.1/dojo/dojo.js"></script>
<script type="text/javascript" src="https://unpkg.com/blip-sdk-web"></script>

<script>
    require(['BlipWebSDK'], function (sdk) {
        new sdk.ChatBuilder()
                  .withApiKey('PUT-YOUR-API-KEY-HERE')
                  .build();
    });
</script>
```

Optional parameters
-------

You can also define optional parameters passing an object inside *build()* method, as you can see below:

| Option | Description |
| --- | --- |
| `authType` | User authentication type (BlipWebSDK.AuthType) &#8727; |
| `title` | Title of chat window |
| `target` | Target element id for embedding sdk |
| `onEnter` | Callback action on enter chat |
| `onLeave` | Callback action on leave chat |
| `zIndex`  | Define zIndex value for chat window. (Default value: 16000001) |

&#8727; Possible values for authType are: 'Guest', 'Login' and 'Dev'. You can access them using 'BlipWebSDK.AuthType' class. 'Guest' type will be used as default If you do not define 'authType'. To see more details about authentication types [click here](https://github.com/takenet/blip-sdk-web/wiki/Authentication-Types)

### Example

## SDK as widget

```javascript
var options = {
    title: 'Send a message',
    onEnter: function() {
        console.log("I'm in the chat!");
    },
    onLeave: function() {
        console.log("I'm out the chat!");
    }
};

new BlipWebSDK.ChatBuilder()
  .withApiKey('PUT-YOUR-API-KEY-HERE')
  .build(options);
```

## SDK as embedded element using 'Login' authentication type

```javascript
var options = {
    authType: BlipWebSDK.AuthType.LOGIN_AUTH,
    title: 'Send a message',
    target: 'your-element-id',
    onEnter: function() {
        console.log("I'm in the chat!");
    },
    onLeave: function() {
        console.log("I'm out the chat!");
    }
};

new BlipWebSDK.ChatBuilder()
  .withApiKey('PUT-YOUR-API-KEY-HERE')
  .build(options);
```

## Advanced features

### Destroy chat widget

To destroy BLiP widget you must use a **destroy** method on chat builder variable.

### Example

```javascript
var options = {
    title: 'Send a message',
    onEnter: function() {
        console.log("I'm in the chat!");
    },
    onLeave: function() {
        console.log("I'm out the chat!");
    }
};

var chatBuilder = new BlipWebSDK.ChatBuilder()
  .withApiKey('PUT-YOUR-API-KEY-HERE')
  .build(options);
  
//To destroy widget use:
chatBuilder.destroy();

//To recreate widget use:
chatBuilder = new BlipWebSDK.ChatBuilder()
  .withApiKey('PUT-YOUR-API-KEY-HERE')
  .build(options);
```
<commit_msg>Update docs<commit_after>
Blip SDK for Web
======

SDK to easily add BLiP conversations (chatbots) in your Web page. For more information see [BLiP portal][1] and [BLiP documentation][2].

Installation
--------

Add the script element inside the **body** of your web page. Put your apikey as asked. *To get your apikey go to [BLiP portal][3]. On the left menu access Publications -> Blip Chat.* 
That's all :)

```html
<script src="https://unpkg.com/blip-sdk-web" type="text/javascript"></script>
<script>
   (function () {
      window.onload = function () {
          new BlipWebSDK.ChatBuilder()
            .withApiKey('PUT-YOUR-API-KEY-HERE')
            .build();
          }
        })();
</script>
```

Via npm
--------

If you are using ES6, simply install the `blip-sdk-web` package from the npm registry.

`npm install blip-sdk-web`

### Instantiate the BlipSdkWeb class

```javascript
import * as BlipWebSDK from 'blip-sdk-web';

new BlipWebSDK.ChatBuilder()
  .withApiKey('PUT-YOUR-API-KEY-HERE')
  .build();
```

Via bower
--------

`bower install blip-sdk-web`

```html
<script src="your-project/bower_components/blip-sdk-web/dist/blipWebSdk.js" type="text/javascript"></script>
<script>
  (function () {
    new BlipWebSDK.ChatBuilder()
      .withApiKey('PUT-YOUR-API-KEY-HERE')
      .build();
  })();
</script>
```

Via AMD
--------

This SDK use UMD to module export. If your project use same AMD, please use 'BlipWebSDK' identifier to resolve the library dependency.

### For instance:

A application that use dojo.js as your AMD

```html
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.12.1/dojo/dojo.js"></script>
<script type="text/javascript" src="https://unpkg.com/blip-sdk-web"></script>

<script>
    require(['BlipWebSDK'], function (sdk) {
        new sdk.ChatBuilder()
                  .withApiKey('PUT-YOUR-API-KEY-HERE')
                  .build();
    });
</script>
```

Optional parameters
-------

You can also define optional parameters passing an object inside *build()* method, as you can see below:

Options object contains three properties: 

### Config

| Propertie | Description |
| --- | --- |
| `authType` | User authentication type (BlipWebSDK.AuthType) &#8727; |
| `user` | User data with `id`, `password`, `name` and `email` properties |

&#8727; Possible values for authType are: 'Guest', 'Login' and 'Dev'. You can access them using 'BlipWebSDK.AuthType' class. 'Guest' type will be used as default If you do not define 'authType'. To see more details about authentication types [click here](https://github.com/takenet/blip-sdk-web/wiki/Authentication-Types)

### Window

| Option | Description |
| --- | --- |
| `title` | Title of chat window |
| `target` | Target element id for embedding sdk |
| `zIndex`  | Define zIndex value for chat window. (Default value: 16000001) |
| `widgetColor`  | Define color value for chat widget. (Default value: '#546E7A') |

### Events

| Option | Description |
| --- | --- |
| `onEnter` | Callback action on enter chat |
| `onLeave` | Callback action on leave chat |

Examples
---------

### SDK as widget

```javascript
var options = 
{
    window: {
        title: 'Send a message'                              
    },
    events: {
        onEnter: function() {
            console.log("I'm in the chat!");
        },
        onLeave: function() {
            console.log("I'm out the chat!");
        }
    }
};

new BlipWebSDK.ChatBuilder()
  .withApiKey('PUT-YOUR-API-KEY-HERE')
  .build(options);
```

### SDK as embedded element using 'Login' authentication type

```javascript
var options = 
{
    config: {
        authType: BlipWebSDK.AuthType.LOGIN_AUTH
    },
    window: {
        title: 'Send a message',
        target: 'your-element-id'                              
    },
    events: {
        onEnter: function() {
            console.log("I'm in the chat!");
        },
        onLeave: function() {
            console.log("I'm out the chat!");
        }
    }
};

new BlipWebSDK.ChatBuilder()
  .withApiKey('PUT-YOUR-API-KEY-HERE')
  .build(options);
```

## Advanced features

### Destroy chat widget

To destroy BLiP widget you must use a **destroy** method on chat builder variable.

### Example

```javascript
var options = 
{
    window: {
        title: 'Send a message'                              
    },
    events: {
        onEnter: function() {
            console.log("I'm in the chat!");
        },
        onLeave: function() {
            console.log("I'm out the chat!");
        }
    }
};

var chatBuilder = new BlipWebSDK.ChatBuilder()
  .withApiKey('PUT-YOUR-API-KEY-HERE')
  .build(options);
  
//To destroy widget use:
chatBuilder.destroy();

//To recreate widget use:
chatBuilder = new BlipWebSDK.ChatBuilder()
  .withApiKey('PUT-YOUR-API-KEY-HERE')
  .build(options);
```

{'fraction_non_alphanumeric': 0.15605841043361943, 'fraction_numerical': 0.005796455244677294, 'mean_word_length': 2.8689090125053904, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 33, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7071355', 'n_tokens_mistral': 2991, 'n_tokens_neox': 2853, 'n_words': 824}