@twilio/conversations
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.0 • Public • Published

    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

    Instantiating and using

    To use the library you need to generate a token and pass it to the Conversations Client constructor.

    NPM

    npm install --save @twilio/conversations
    

    Using this method, you can require twilio-conversations and then use the client:

    const { Client } = require('@twilio/conversations');
    const client = new Client(token);
    // Before you use the client, subscribe to the `'stateChanged'` event and wait 
    // for the `'initialized'` state to be reported.
    client.on('stateChanged', (state) => {
      if (state === 'initialized') {
        // Use the client
      }
    }
    

    The SDK could also be imported using the ES module syntax:

    import { Client } from '@twilio/conversations';
    const client = new Client(token);
    // Before you use the client, subscribe to the `'stateChanged'` event and wait 
    // for the `'initialized'` state to be reported.
    client.on('stateChanged', (state) => {
      if (state === 'initialized') {
        // Use the 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.

    <script src="https://media.twiliocdn.com/sdk/js/conversations/v2.0/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:

    const client = new Twilio.Conversations.Client(token);
    

    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 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:

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

    Find the hash of each release published on the Changelog page.

    Changelog

    See this link.

    Keywords

    none

    Install

    npm i @twilio/conversations

    DownloadsWeekly Downloads

    52,667

    Version

    2.1.0

    License

    MIT

    Unpacked Size

    12.5 MB

    Total Files

    102

    Last publish

    Collaborators

    • twilio-messaging