I am getting the response:
response { errors: [ { code: 80, message: 'Invalid template' } ], status: 'failure' }
Template status is Active and Template I have registered with my Textlocal account:
Welcome to %%|applicationName^{"inputtype" : "text", "maxlength" : "20"}%%, Your OTP is %%|OTP^{"inputtype" : "text", "maxlength" : "6"}%%.Thanks Doosy
- How should I send a message with this template? My current code is:
import axios from 'axios'
const apiKey = "Api"
const sender = "Dooosy"
const number = "91**********"
let applicationName = "application name"
let otp = "123123"
const message = encodeURIComponent(`Welcome to ${applicationName}, Your OTP is ${otp}. Thanks Doosy`);
var url = "http://api.textlocal.in/send/?" + 'apiKey=' + apiKey + '&sender=' + sender + '&numbers=' + number + '&message=' + message
const sendSms = async (req, res) => {
axios
.post(url)
.then(function (response) {
console.log("response ", response.data);
})
.catch(function (error) {
console.log("error ", error.message);
});
}
export default sendSms
I use this sendSms file in my other file like this
import sendSms from './sendSms.js'
app.get("/demo") => {
sendSms() // called this function for send sms
res.status(200).json({
success: true,
message: "otp sent successfully"
})
}