# twilio-frame-chat

> Twilio Chat Frame

Latest version **0.3.1** (published 2017-10-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install twilio-frame-chat
pnpm add twilio-frame-chat
yarn add twilio-frame-chat
bun add twilio-frame-chat
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2017-10-13 |
| First published | 2017-09-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 10 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Twilio |
| Maintainers | twilio-ci |

## Links

- npm: https://www.npmjs.com/package/twilio-frame-chat
- npm.io page: https://npm.io/package/twilio-frame-chat

## Dependencies (10)

- [cuint](https://npm.io/package/cuint.md) ^0.2.2
- [react](https://npm.io/package/react.md) ^15.6.1
- [redux](https://npm.io/package/redux.md) ^3.7.1
- [react-dom](https://npm.io/package/react-dom.md) ^15.6.1
- [react-redux](https://npm.io/package/react-redux.md) ^5.0.5
- [twilio-chat](https://npm.io/package/twilio-chat.md) ^1.0.1
- [react-pacomo](https://npm.io/package/react-pacomo.md) ^0.5.3
- [redux-logger](https://npm.io/package/redux-logger.md) ^3.0.6
- [react-transition-group](https://npm.io/package/react-transition-group.md) ^1.2.0
- [redux-promise-middleware](https://npm.io/package/redux-promise-middleware.md) 4.2.1

## Recent versions

- 0.3.1 (latest) — 2017-10-13
- 0.2.0 (alpha) — 2017-09-15
- 0.3.0 — 2017-10-13

## README

# Twilio Chat Frame

Chat Frame
=============

Chat Frame is a library to help you bootstrap Twilio Chat SDK and render a Channel using only a few lines of code.

Instantiating and using Chat Frame
=============

To use the Chat Frame you need [to have a Twilio Programmable Chat Client instance](https://media.twiliocdn.com/sdk/js/chat/v1.2/docs/) and a Channel instance from it.
You can use the Twilio Programmable Chat SDK to create and join channels.

Chat Frame instantiation and loading looks as follows, just make sure you have a div with id "chatContainer" where the Chat Frame will be loaded:
```
function loadFrame(client, channel) {
    // Configuration for Chat Frame
    const frameConfiguration = {
        channel: {
            chrome: {
                closeCallback: channelSid => {
                    chatFrame.unloadChannelBySid(channelSid);
                }
            },
            visual: {
                colorTheme: 'DarkTheme'
            }
        }
    };

    // Create the Chat Frame instance
    const chatFrame = Twilio.Frame.createChat(client, frameConfiguration);
    chatFrame.loadChannel(containerSelector, channel);
}

// Create a Chat Client
Twilio.Chat.Client.create(token).then(client => {
    // Add channel joined listener
    client.on('channelJoined', channel => {
        loadFrame(client, channel);
    });

    // Create a new channel
    return client.createChannel();
})
// Join the created channel
.then(channel => {
    return channel.join();
});
```

Consuming Chat Frame
=============
You can consume the library from NPM:
```
npm install twilio-frame-chat
```

For browser you can use the version from CDN. There are two packages:
1. Frame bundle which includes the JS code and CSS style sheet.
```html
<script src="//media.twiliocdn.com/sdk/js/frame-chat/v0.3/twilio-frame-chat.bundle.min.js"></script>
```
2. Frame JS and CSS style sheet as separate files. You need to include CSS style sheet separately (or create your own).
```html
<link rel="stylesheet" href="//media.twiliocdn.com/sdk/js/frame-chat/v0.3/twilio-frame-chat.css" type="text/css"></link>
<script src="//media.twiliocdn.com/sdk/js/frame-chat/v0.3/twilio-frame-chat.min.js"></script>
```

---
_Source: https://npm.io/package/twilio-frame-chat · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
