メニュー

Expand
ページを評価:

Twilio Client JS SDK: Overview

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

概要

The code in twilio.js allows you to make voice calls to and from a web browser via a 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 straight in with our Twilio Client Quickstart.

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

When you include the twilio.js library in a web page you get access to these objects:

  • Twilio.Device This object is your main entry point for creating outbound connections, accepting incoming connections, and setting up your connection event handlers. (Docs).
  • Twilio.Connection This object 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. (Docs).

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.12/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. 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 be 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 twilio.js from the source code.

ページを評価:

ヘルプが必要ですか?

誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。

        
        
        

        フィードバックくださりありがとうございます!

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

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        ステップ1

        Get link

        Get a free personal referral link here

        ステップ2:

        Give $10

        Your user signs up and upgrade using link

        ステップ3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more