question

Abhishek Babal avatar image
Abhishek Babal asked Phong Vu commented

show the notification in the page

i am integrating RC web widget in CRM now i want to show the notification on the CRM page whenever call is active.....so can you tell me how can i do this

ringcentral apptransferring calls
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Phong Vu avatar image
Phong Vu answered Abhishek Babal commented

Add this Javascript function to your code. Detect the event and do/show whatever you want to do with them,

window.addEventListener('message', (e) => {
  const data = e.data;
  if (data.call && data.call.direction == 'Inbound'){
    console.log(`Incoming call from: ${data.call.from.phoneNumber}. Call status: ${data.call.telephonyStatus}`)
    if (data.call.telephonyStatus == 'Ringing')
        console.log("Incoming call ringing")
  }
  if (data) {
    switch (data.type) {
      case 'rc-call-ring-notify':
        // when user gets a ringing call
        console.log("RINGING...")
        console.log(data.call);
        break;
      case 'rc-call-init-notify':
        // when user creates a call from dial
        console.log("SETUP...")
        console.log(data.call);
        break;
      case 'rc-call-start-notify':
        // when a incoming call is accepted or a outbound call is connected
        console.log("INCOMING RING...")
        console.log(data.call);
        break;
      case 'rc-call-hold-notify':
        // when user holds a call
        console.log(data.call);
        break;
      case 'rc-call-resume-notify':
        // when user unholds call
        console.log(data.call);
        break;
      case 'rc-call-end-notify':
        // when call ended
        console.log("TERMINATING...")
        console.log(data.call);
        break;
      case 'rc-call-mute-notify':
        // when muted or unmuted event
        console.log(data.call);
        break;
      case 'rc-message-updated-notify':
        console.log("VOICEMAIL?")
        console.log(data.message.type)
        console.log(data.message.uri)
        break
      default:
        console.log("OTHERS...")
        //console.log(data);
        break;
    }
  }
});
2 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

i want to show the message on website not in RC widget.........like when a call is answered on the page it shows (call active from {number} to {number}) so that other users of RC can see that on CRM can see that message

0 Likes 0 ·

This is the Javascript code on your front end. You get the notification in your code and you show whatever, wherever you want to show. Do I need to show you how to make a popup or display on a page?

1 Like 1 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys