Help

Custom app, sending SMS

579 0
cancel
Showing results for 
Search instead for 
Did you mean: 
maxim_kulikov
4 - Data Explorer
4 - Data Explorer

Hello. I’m trying to create a custom application for sending SMS from Airtable. Actually there already exist an app like that

but for some reasons I can’t use Twilio service. So I’ve got a code from telecom provider which I’m working with, and this code is working when I run it on my own computer, it sends SMS.
So I wrote the function in my Airtable custom app with this code, but it’s doesn’t work when I trying to call this function

function sendSMS(){
    const https = require('https');

    const data = JSON.stringify({
        auth: {apikey: 'API key'},
        data: {
            message: 'TEST.',
            sender: {text:'TEST'},
            recipients: [{phonenr:'+421XXXXXXXXX'}]
        }
    });

    const options = {
        hostname: 'api-tls12.smstools.sk',
        port: 443,
        path: '/3/send_batch',
        method: 'POST',
        headers: {
            'Content-Type': 'application/json;charset=UTF-8',
            'Content-Length': data.length
        }
    };

    const req = https.request(options, res => {
        console.log(`statusCode: ${res.statusCode}`)
        res.on('data', d => {
            process.stdout.write(d)
            console.error(data)
        })
    });

    req.on('error', error => {console.error(error)});
    req.write(data);
    req.end()
}

What’s wrong with it?

0 Replies 0