question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A voice call recive everytime 'answered' status

See original GitHub issue

I’m trying to build an alert machine. I need that when no one answer, a new call start to another number. I can do the first call but listening the event i recive everytime the ‘answered’ status even if the called reject or he doesn’t answer.

Here the code:


API = {
  auth : {
    apiKey: 'xxxxxxx',
    apiSecret: 'xxxxxxxxxxxxxx',
    applicationId: 'xxxxxxxxxxxxx',
    privateKey: 'config/xxxx/nexmo-private.key',
  },
  ncco : [{
    action: "talk",
    voiceName: "Giorgio",
    text: "Alert"
  }],
  from: '39xxxxxx'
};

app.post('/:project/:token/', (req, res) => {
	console.log("+++ " + moment().toISOString() + " | New " + req.params.project + " POST +++");
	console.log(req.body);




	console.log(req.body);
    config = {...config, body: req.body};

	if(!voice[req.params.project]) {
		console.log("Creating new VoiceProxy");
		voice[req.params.project] = new VoiceProxy(config);
	}

	let instance = voice[req.params.project];
    instance.createCalls(instance.config.body.tos[0]).then((res) => {
        conversation.push(res);
        console.log(res);
    }).catch((err) => {
        console.log(err);
    })

    res.json({success:true});
});

const VoiceProxy = function(config) {
	this.config = config;
	this.nexmo = new Nexmo(this.config.auth, {});
	
	this.createCalls = (to) => {
		let def = $q.defer();

		let ncco = this.config.ncco;
		this.nexmo.calls.create({
				to: [	getPhoneConf(to)	],
				from: getPhoneConf(this.config.from),
				ncco,
		},
		(err, result) => {
			if(err) {
					def.reject(err);
			} else {
					def.resolve(result);
			}
		});
	
		return def.promise;
	};
};

Here Logs:

Creating new VoiceProxy
{ uuid: '39a6e0a6-4ec6-4a8c-b118-947a6fe0e3a4',
  status: 'started',
  direction: 'outbound',
  conversation_uuid: 'CON-f358e844-512c-4a37-91d1-4af0bf32709e' }
+++ 2020-06-09T11:48:57.207Z | New dipe POST +++
{ headers: {},
  from: '39xxx',
  to: '39xxx',
  uuid: '39a6e0a6-4ec6-4a8c-b118-947a6fe0e3a4',
  conversation_uuid: 'CON-f358e844-512c-4a37-91d1-4af0bf32709e',
  status: 'started',
  direction: 'outbound',
  timestamp: '2020-06-09T11:48:56.586Z' }
+++ 2020-06-09T11:48:57.209Z | New dipe POST +++
{ headers: {},
  from: '39xxx',
  to: '39xxx',
  uuid: '39a6e0a6-4ec6-4a8c-b118-947a6fe0e3a4',
  conversation_uuid: 'CON-f358e844-512c-4a37-91d1-4af0bf32709e',
  status: 'ringing',
  direction: 'outbound',
  timestamp: '2020-06-09T11:48:56.586Z' }
+++ 2020-06-09T11:49:18.370Z | New dipe POST +++
{ start_time: null,
  headers: {},
  rate: null,
  from: '39xxx',
  to: '39xxx',
  uuid: '39a6e0a6-4ec6-4a8c-b118-947a6fe0e3a4',
  conversation_uuid: 'CON-f358e844-512c-4a37-91d1-4af0bf32709e',
  status: 'answered',
  direction: 'outbound',
  network: null,
  timestamp: '2020-06-09T11:49:18.148Z' }
+++ 2020-06-09T11:49:21.043Z | New dipe POST +++
{ headers: {},
  end_time: '2020-06-09T11:49:21.000Z',
  uuid: '39a6e0a6-4ec6-4a8c-b118-947a6fe0e3a4',
  network: '22288',
  duration: '3',
  start_time: '2020-06-09T11:49:18.000Z',
  rate: '0.23500000',
  price: '0.01175000',
  from: 'Unknown',
  to: '39xxxxxxxxx',
  conversation_uuid: 'CON-f358e844-512c-4a37-91d1-4af0bf32709e',
  status: 'completed',
  direction: 'outbound',
  timestamp: '2020-06-09T11:49:20.992Z' }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
bencgreenbergcommented, Jun 10, 2020

Are you receiving answered statuses back on your webhook payload for both when the caller does not answer and when the caller presses the reject button on their phone?

0reactions
bencgreenbergcommented, Jun 11, 2020

@gine - Would you be able to join us on our community Slack? I believe we can address this better in real-time there. The link to join is at https://developer.nexmo.com/community/slack. When you join, we can continue this conversation in the #voice-api channel.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are the Possible Call Statuses, and What do They Mean?
Notice: A completed call indicates that a connection was established, and audio data was transferred. This could be seen when a phone is...
Read more >
Manage call settings - Android - Google Support
Open the Google Voice app "" . · At the top left, tap Menu Menu and then Settings. · Under Messages, Calls, or...
Read more >
Answer or decline incoming calls on iPhone - Apple Support
On iPhone, you can answer, silence, or decline an incoming call; send a call to voicemail, respond with a text, and reminder yourself...
Read more >
How to Answer an Incoming Call While Already on the Phone
Test it before taking any calls so you know how it will work. Note: in the United States, most mobile phones can handle...
Read more >
Can't call, dropped calls, & other calling issues - T-Mobile
Read these troubleshooting tips if you're unable to make or receive calls, or your calls drop unexpectedly on ... Remove any cases or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found