> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Make a call to a web browser

> Build a browser softphone using the Telnyx WebRTC JS SDK to receive and place calls directly inside your web application with carrier-grade voice.

## How to receive calls into your web app

During this guide you will learn how to:

* Setup the <a href="https://github.com/team-telnyx/webrtc">WebRTC JS SDK</a> into your app.
* Use the necessary [SDK APIs](/docs/voice/webrtc/js-sdk/classes/telnyxrtc) to connect and receive calls into your web application.

### Requirements

* Have a <a href="https://portal.telnyx.com/">portal account</a>
* Configure your portal account for voice
* Have 2 SIP Connections: To learn how to setup a SIP connection, please visit our Quick Start Guide. We are going to use one SIP connection for the caller and another for the callee.

## Building the app

1. Add the WebRTC adapter as a script

```javascript theme={null}
   <script
     type="text/javascript"
     src="https://webrtc.github.io/adapter/adapter-latest.js">
   </script>
```

<Callout type="info">
  After pasting the above content, Kindly check and remove any new line added
</Callout>

2. Add the Telnyx RTC SDK as a script

```javascript theme={null}
   <script
     type="text/javascript"
     src="https://unpkg.com/@telnyx/webrtc@2.9.0/lib/bundle.js">
   </script>
```

<Callout type="info">
  After pasting the above content, Kindly check and remove any new line added
</Callout>

3. Initialize the client using your SIP credentials

```javascript theme={null}
  const client = new TelnyxWebRTC.TelnyxRTC({
         login: “SIP USER”,
         password: “SIP USER PASSWORD”,
  });
```

<Callout type="info">
  After pasting the above content, Kindly check and remove any new line added
</Callout>

4. Attach the event listeners to receive updates from the SDK

```javascript theme={null}
  client
       .on('telnyx.ready', () => console.log('ready to call'))
       .on('telnyx.notification', (notification) => {
         console.log('notification:', notification)
  });
```

<Callout type="info">
  After pasting the above content, Kindly check and remove any new line added
</Callout>

5. Inside the `telnyx.notification` event you can detect the incoming call and answer it. On this example we are anwering it as soon as we get the incoming call notification

```javascript theme={null}
  client.on('telnyx.notification', (notification) => {
      const call = notification.call;

      // Check the type of the notification
      if (notification.type === 'callUpdate' && call.state === 'ringing') {
          // Answer the call as soon as the notification is received.
          call.answer();
      }
  });
```

<Callout type="info">
  After pasting the above content, Kindly check and remove any new line added
</Callout>

6. Enable the microphone

```javascript theme={null}
client.enableMicrophone();
```

<Callout type="info">
  After pasting the above content, Kindly check and remove any new line added
</Callout>

7. Connect the client

```javascript theme={null}
client.connect();
```

<Callout type="info">
  After pasting the above content, Kindly check and remove any new line added
</Callout>

8. Now your application is capable of receiving voice calls.

## How to test it

1. Go to [https://webrtc.telnyx.com/](https://webrtc.telnyx.com/)
2. Login with SIP credentials (caller SIP credentials). At this point you should have created 2 SIP connections one for the caller and another for the callee.

<img src="https://mintcdn.com/telnyx/PAJh-h3FEJ6U1KdT/img/voice_voice-sdk_make-a-call-to-a-web-browser_login.png?fit=max&auto=format&n=PAJh-h3FEJ6U1KdT&q=85&s=37005dc99cc33c4a424780143c323e6d" alt="WebRTC Setting" width="1008" height="870" data-path="img/voice_voice-sdk_make-a-call-to-a-web-browser_login.png" />

3. Enter the destination `SIP username` (callee SIP connection) and press the call button.

<img src="https://mintcdn.com/telnyx/PAJh-h3FEJ6U1KdT/img/voice_voice-sdk_make-a-call-to-a-web-browser_destination-and-call.png?fit=max&auto=format&n=PAJh-h3FEJ6U1KdT&q=85&s=0696d63404ff53f464c76d6d5d2c9321" alt="WebRTC Dialer" width="1008" height="1652" data-path="img/voice_voice-sdk_make-a-call-to-a-web-browser_destination-and-call.png" />

4. The telnyx.notification listener will be fired and the call will automatically be answered.

## Test the vanilla example

* Open <a href="https://codesandbox.io/s/nostalgic-archimedes-nv3osx">CodeSandbox</a>
