メニュー

Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Twilio Client JS SDK: Overview

Attention: Please upgrade to the latest version of twilio.js to avoid upcoming breaking changes in Google Chrome. See this advisory for details.

概要

Twilio.js allows you to make voice calls to and from a web browser and a Twilio TwiML Voice Application. This means you can open inbound and outbound audio connections to Twilio for building soft phones, walkie-talkies, conference calls, click-to-talk systems, and more, all from the browser.

Want to get started right away?

Jump right in with our Twilio Client Quickstart!

Need help troubleshooting an issue with the JavaScript SDK? See Twilio.js Troubleshooting & Common Errors

twilio.jsライブラリーをウェブページに組み込むといくつかのオブジェクトにアクセスできます。

Twilio.Device

Twilio.Device (docs) is your main entry point for creating outbound connections, accepting incoming connections, and setting up your connection event handlers.

Twilio.Connection

Twilio.Connection (docs) lets you interact with the call as it is happening. You can do things like mute/unmute, disconnect the call, or send DTMF tones using the connection.

Twilio.js ライブラリのインクルード

Using NPM (recommended)

We recommend using the twilio-client npm module to include the twilio.js SDK as a dependency into your application:

> npm install twilio-client --save

For React or other modern frameworks, twilio-client can be used directly in your application code:

> const { Device } = require('twilio-client');

For more static or traditional web applications, the SDK can be deployed alongside your app and included in your HTML. For example, in express:

app.use('/js/twilio.min.js', (req, res) => {
  res.sendFile('./node_modules/twilio-client/dist/twilio.min.js');
});

Which you might include in your HTML's <head> section:

<script type="text/javascript" src="https://media.twiliocdn.com/sdk/js/client/v1.7/twilio.min.js"></script>

Using our CDN (not recommended)

You can link directly to the twilio.js library by including it in the <head> of your HTML:

<script type="text/javascript" src="/js/twilio.min.js"></script>

This approach is provided to make getting started easier, however it is not recommended in production. By linking directly to our CDN in production, any patch-level (non-breaking) changes made to the SDK will automatically be applied and in the case of any unintentional negative side effects introduced by the update, your users may notice the issue before you do. For production, we recommend pulling twilio-client from NPM, where your application's tests can run using any new versions of the SDK before getting pushed to production.

You should use HTTPS to serve your page. In order to use this method, your page must be served over HTTPS.

Building from source

You can also build from the source.

Rate this page:

ヘルプが必要ですか?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.