# twilio-frame

> Twilio Frame

Latest version **0.1.1** (published 2017-07-18) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2017-07-18 |
| First published | 2017-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 12 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Twilio |
| Maintainers | twilio-ci |

## Links

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

## Dependencies (12)

- [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
- [preact](https://npm.io/package/preact.md) ^8.1.0
- [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
- [preact-compat](https://npm.io/package/preact-compat.md) ^3.16.0
- [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.1.1 (latest) — 2017-07-18
- 0.1.0-rc1 (alpha) — 2017-07-17
- 0.1.0 — 2017-07-18

## README

# Twilio 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.0/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 Frame
=============
You can consume the library from NPM:
```
npm install twilio-frame
```

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/v0.1/twilio-frame.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/v0.1/twilio-frame.css" type="text/css"></link>
<script src="//media.twiliocdn.com/sdk/js/frame/v0.1/twilio-frame.min.js"></script>
```

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