I am using msg91 Node.js API to send SMS. It is working fine if the message's text is in English.
Now I want to send SMS in Hindi.
Problem is, if I don't encode the message, it returns Authentication error. Post encoding it says the message is sent, but I don't receive any message on the test target.
Error Message:
{ success: 'false',
token: 'Authentication failure' }
Sample message is:
मोजो में आपका स्वागत है
npm module used: msg91
npm install --save msg91
Sending SMS via msg91 is just a simple get call. You don't need to rely on a language specific API.
As long as you send unicode=1 in the get call you can insert hindi text in you messages.
For more information about the same read here - https://control.msg91.com/apidoc/textsms/send-sms.php
You can refer NodeJS package https://www.npmjs.com/package/springedge to send sms. You can install as
npm install springedge
Code example of sending sms:
// send sms
var springedge = require('springedge');
var params = {
'apikey': '', // API Key
'sender': 'SEDEMO', // Sender Name
'to': [
'919019xxxxxxxx' //Moblie Number
],
'message': 'test+message'
};
springedge.messages.send(params, 5000, function (err, response) {
if (err) {
return console.log(err);
}
console.log(response);
});
You will just need api key and trail account to use it. or you can customize it as per your requirement.
Related
Twilio Stuido does not provide a native way to email a recording therefore this needs to be coded. In this example, a voicemail has been taken of a users call. Now that we have the recording a Twilio Function is created (NodeJS) to send this recording to email.
In the sample code below the function is failing however there is no available debug tool inside the Twilio Console for dealing with functions. NodeJS is fairly new to us so this maybe easy for someone to spot.
Possible other errors may be however:
Incorrect gmail authentication (although the details are correct in terms of username and password, perhaps this is not how you configure google apps to send the email)
Inability to import or incorrectly importation of the nodemailer dependency into Twilio
Bad NodeJS skills
The input variables are:
attachment
{{widgets.Voicemail_Recording.RecordingUrl}}
- which contains the URL to the voicemail recording.
lang
- the language of the caller (based on IVR choices earlier).
phone_number
{{trigger.call.From}}
NodeJS Twilio Function
var mailer = require('nodemailer');
mailer.SMTP = {
host: 'smtp.gmail.com',
port:587,
use_authentication: true,
user: 'info#example.com',
pass: '*********'
};
exports.handler = function(context, event, callback) {
mailer.send_mail({
sender: event.phone_number + '<info#example.com>',
to: 'info#example.com',
subject: 'Voicemail (' + event.lang + ')',
body: 'mail content...',
attachments: [{'filename': event.attachment, 'content': data}]
}), function(err, success) {
if (err) {
}
}
};
Sam here from Twilio's support team - I just released a blog post that should help with this. It shows how to forward voicemails with Studio, Functions, and SendGrid. Check it out here: https://www.twilio.com/blog/forward-voicemail-recordings-to-email
I have a webhook setup, and I am able to receive messages and reply to them. I would like to have the responses sent by my webhook to have messagingServiceSid attached to them.
I didn't find on documentation a way to configure that for responses from my webhook, only for new SMS using
client.sendMessage({
messagingServiceSid: 'MG9752274e9e519418a7406176694466fa',
to: '+16518675309',
body: 'Phantom Menace was clearly the best of the prequel trilogy.'
}, function(err, message) {
console.log(message);
});
Is there something similar for this code? Is it doable through the UI?
app.post('/foo/bar/sms', twilio.webhook({
host:'gassy-ocelot-129.herokuapp.com',
protocol:'https'
}), function(request, response) {
var twiml = new twilio.TwimlResponse();
twiml.message('This HTTP request came from Twilio!');
response.send(twiml);
});
Images:
No messagingService on reply messages sent using twiml response
Message Detail view from logs
Twilio developer evangelist here.
As far as I'm aware, there's no way to reply to message from a message service with TwiML.
However, rather than using TwiML, you could just send the SMS back to your user from the REST API and return an empty <Response> to the incoming webhook. Something a bit like this:
app.post('/foo/bar/sms', twilio.webhook({
host:'gassy-ocelot-129.herokuapp.com',
protocol:'https'
}), function(request, response) {
// send the message from the message service
client.sendMessage({
messagingServiceSid: 'MG9752274e9e519418a7406176694466fa',
to: request.body.From,
body: 'Your message'
}, function(err, message) {
console.log(message);
});
// send empty TwiML response
var twiml = new twilio.TwimlResponse();
response.send(twiml);
})
Let me know if that helps at all.
If you receive an incoming SMS on a phone number currently set up to that Messaging Service (via the web ui or phone number REST), then the incoming requests will have MessagingServiceSid in the query string.
I am using nodemailer module with my nodejs/express.js app.
I am using gmail as the transporter.
It seems like every 20 successful emails sent, I will get this error:
454 4.7.0 Cannot authenticate due to temporary system problem
I'm testing out an invoice system so I'm regularly sending an email to the same email address for testing.
I am not using Google apps and I have set Gmail security to work with low security apps.
Invoices are important and if I cant guarantee all invoices will get sent to my customers, its going to be bad.
Is this normal?
app.get('/thankyou', function(req,res) {
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'somethinggggg#gmail.com',
pass: 'password here'
}
});
res.render('thankyou_email', function(err,html) {
var mailOptions = {
from: 'John Doe <somethinggggg#gmail.com>',
to: 'someoneee#icloud.com',
subject: 'Your order was received',
html: html
};
transporter.sendMail(mailOptions, function(error, info) {
if(error) {
console.log('error1: ' + error);
transporter.sendMail(mailOptions, function(error, info) {
if(error) {
console.log('error2: ' + error);
} else {
console.log('cool bro everything works2');
console.log(info);
}
});
} else {
console.log('cool bro everything works');
console.log(info);
}
});
res.render('thankyou_page');
});
As you can see, if I have an error I try to resend the email again, but still I receive the same error.
Also notice that I am using res.render() twice. I thought this was weird but it still works. The first res.render() I am using to generate the html for the email, and the last res.render() is to render the html in the response back to the client. I used to get an error about sending headers twice, but I don't see that error no more. Nevertheless ,it still worked.
Whose fault is this? Me? Nodemailer? Gmail?
If I were to sign up for Google apps will I still have this problem?
I have come across Nodemailer documentation and it was stated in Using OAuth2 that if a XOAuth2 token generator is used as the value for auth.xoauth2 when setting up transporter object then you do not need to set the value for user or pass as OAuth2 is used for authenticated.
XOAuth2 generator generates required accessToken itself if it is missing or expired. If authentication fails, a new token is requested and the authentication is retried once. If it still fails, an error is returned.
Sample code is given in the documentation. Though, I haven't personally tried using it, I hope it works with you. :)
I'm trying to send a message to GCM server to forward to another phone. The request keeps saying 400. I've checked the code close to a hundred times, but I'll put it up just in case. I also have changed the registration token parameter to registration_id and various others, along with changing the data to arrays etc. Just to be clear that the API key and Registration ID work, I can get a push notification from this Web site:
http://demo.androidhive.info/gcm_chat/push_test.php
Here's the code:
var gcm = require('node-gcm');
var gcmSender = new gcm.Sender('A......1234568AAA'); //my api key
var GCMmessage = new gcm.Message();
GCMmessage.addData("message", message);
GCMmessage.addData("from", from);
GCMmessage.addNotification('title', 'Alert!!!');
GCMmessage.addNotification('body', 'Abnormal data access');
GCMmessage.addNotification('icon', 'ic_launcher');
var regtoken = response.GCM.RegID; //data returned from another function
//Gives the RegID for a specific user
gcmSender.send(GCMmessage, {"to" : regtoken}, function(err, gcmResponse) {
if(err){
console.log(err);
} else {
console.log(gcmResponse);
console.log("message sent");
}
});
Ok it seems that it is best to send your gcm message directly using an npm module like 'request' or something similar. When I sent a message using that I received a very detailed error message telling me that 'from' is a reserved word. I'm not sure if that was the whole issue, but having a detailed error message made the code modification pretty easy.
I am using Node SMPP,i am able to send SMS to my number but i can't get delivery receipt it is delivered or not . Please refer my below code
can you please guide if anything went wrong
var smpp = require('smpp');
var session = smpp.connect('103.250.30.x', 51612);
session.bind_transceiver({
system_id: 'makesms1',
password: 'Prasad#1'
}, function(pdu) {
if (pdu.command_status == 0) {
// Successfully bound
console.log('bound bind_transceiver')
session.submit_sm({
destination_addr: '90000541x0',
short_message: new Buffer("Hi, Froxtel interview SMS/email has been sent by company only. Its not any related to freshersworld. U can contact directly company or call 08688805062/3.Please ignore the word freshersworld in sms/mail.regards Froxtel team.","utf8"),
source_addr:'FROXTL',
registered_delivery:1,
data_coding:0,
}, function(pdu) {
if (pdu.command_status == 0) {
// Message successfully sent
console.log(JSON.stringify(pdu));
}
});
}
});
When i use nodejs shorty module it working fine and i am able to get delivery receipt . but i am unable to send long message.
should i use data_sm for long messages or other ?
Your code looks fine for sending and processing the responses to your outgoing requests.
The delivery receipts are sent from the smpp server to your client using deliver_sm pakets and therefore you need to register an event handler:
session.on('deliver_sm', function(pdu) {
console.log(pdu.short_message);
session.send(pdu.response());
});