Reputation: 10378
My Nodejs app uses nexmo 2.8.0
to send message to cell phones and it works fine with US phone number. My question is how to send the message to phone# of other countries such as China and Hong Kong? According to the nexmo
doc, it shall work with international phone#. But I tried and the other party didn't receive it. Here is the code:
const Nexmo = require("nexmo");
const nexmo = new Nexmo({
apiKey: process.env.nexmoApiKey,
apiSecret: process.env.nexmoApiSecret
}, { debug: true });
function sendNexmoSms(nexmo, vcode, cell, cell_country_code){ //vcode is the message
return new Promise(resolve => {
nexmo.message.sendSms(process.env.nexmo_sender_number, cell_country_code + cell, vcode, {type: 'unicode'}, async (err, result) => {
if(err){
resolve('failed to send');
}else{
if (result.messages[0]['status'] === "0") {
resolve('success');
} else {
resolve('failed to send');
}
}
});
});
};
Upvotes: 0
Views: 151
Reputation: 750
According to Vonage document, you should set the receiver number in E.164 format Here is how to build E.164 format phone number: https://www.twilio.com/docs/glossary/what-e164
Upvotes: 2
Reputation: 49
Can you share more details about the question? It is not clear about the error code that you receive.
One of the issue can be routing issue as well.
Upvotes: 0