
Twilio Conversations client library
=============
Twilio Conversations: Create meaningful connections with customers across various communication channels.
Visit our official site for more detalis: [https://www.twilio.com/conversations](https://www.twilio.com/conversations)


Instantiating and using
------------
To use the library you need [to generate a token](https://www.twilio.com/docs/conversations/create-tokens) and pass it to the conversations Client `create` factory.

### NPM
```
npm install --save @twilio/conversations
```

Using this method, you can `require` `twilio-conversations` and then use the client:
```
const Conversations = require('twilio-conversations');
Conversations.Client.create(token).then(client => {
    // Use client
});
```

Or, if you prefer `async`/`await` syntax:
```
const Conversations = require('twilio-conversations');
const client = await Conversations.Client.create(token);
// Use client
```

The SDK could also be imported using the ES module syntax:
```
import Conversations from '@twilio/conversations';
const client = await Conversations.Client.create(token);
// Use client
```

### CDN

Releases of `twilio-conversations.js` are hosted on a CDN, and you can include these
directly in your web app using a `<script>` tag.
```html
<script src="https://media.twiliocdn.com/sdk/js/conversations/v1.2/twilio-conversations.min.js"></script>
```
Using this method, `twilio-conversations.js` will set a browser global `Twilio.Conversations` through which you can use the client :
```
Twilio.Conversations.Client.create(token).then(client => {
    // Use client
});
```

or, if you prefer `async`/`await` syntax:
```
let client = await Twilio.Conversations.Client.create(token);
// Use client
```

### Security

The CDN consumption described above allows you to consume latest bug fixed versions automatically,
but does not prevent from detecting malicious modifications in the SDK code.

If you require more security you will have to consume SDK by using [SRI](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) and using an exact version
number. While less flexible it is significantly more secure, which is required by some applications.

To consume securely use the following script snippet format:

```html
<script src="https://media.twiliocdn.com/sdk/js/conversations/releases/1.2.0/twilio-conversations.min.js"
        integrity="sha256-<HASH FROM THE CHANGELOGS PAGE>"
        crossorigin="anonymous"></script>
```

Find the hash of each release published on the [Changelog](#Changelog) page.

###  Changelog

See this [link](https://www.twilio.com/docs/conversations/javascript/changelog).
