1

I am working twilio client JavaScript. I successfully placed a voice call to specific number but i want to know whether or not call is cancelled, unanswered and other status

if(Twilio) {
            Twilio.Device.setup(token);
            Twilio.Device.ready((device:any) => {
                console.log('Twilio.Device Ready!');
            });
        
            Twilio.Device.error((error:any) => {
                console.log('Twilio.Device Error: ' + error.message);
              // setShowInCallMenu(!showInCallMenu);
                setIsCallConnected(false);
            });
        
            Twilio.Device.connect((conn:any) => {
                console.log('Successfully established call!');
                setIsCallConnected(true);
                setStartTimestamp(moment());
                handleRecording(true);
               
            });
            Twilio.Device.disconnect((conn:any) => {
                console.log('Call ended.');
                setIsCallConnected(false);
                handleRecording(false);
               //toggleCaller()
                onNativeCallback(
                    {
                        'code':4001,
                        'message':'Call Ended'
                    } 
                );
            });
        }

webhook doesn't solve this problem all. I need the status of the call. another way would be make a separate call to callSid endpoint and get information about call but in that case it wont gave details like whether call is not answered or cancelled

James Z
  • 12,209
  • 10
  • 24
  • 44
Ali
  • 557
  • 1
  • 9
  • 30

0 Answers0