anybody please help me to send a sms when an order is placed.
You might wanna do this on the backend with Twilio or something. What happens to trigger the SMS message, someone has successfully placed an order, or they want to place an order?
twi(){
const twilio = require(‘twilio’);
const accountSid = '';
const authToken = '';
// require the Twilio module and create a REST client
const client = new twilio(accountSid, authToken);
//var client = new twilio(accountSid, authToken);
client.messages.create
({
to: ‘+9190487’,
from: ‘+1610365’,
body: ‘TEST Alert Message !’,
})
.then((message) => console.log(message.sid));
}
}
this is not working, please help.
it shows following error…
ERROR TypeError: Object expected
what line was the error on?
Sir have a look on this
import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;
import * as twilio from ‘twilio’;
declare var require: any;
@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {
constructor(public navCtrl: NavController) {
}
hi()
{
var twilio = require(‘twilio’);
const accountSid = ‘AC52c539a9’;
const authToken = ‘f47212cf04a’;
// require the Twilio module and create a REST client
var client = new twilio(accountSid, authToken);
//var client = new twilio(accountSid, authToken);
client.messages.create
({
to: ‘+91904’,
from: ‘+1610’,
body: ‘TEST Alert Message !’
})
.then((data) => console.log(‘hi’));
}
}
error :
Function code (174) (5,3)
error shows in the @component
My suggestion was to use Twilio on the backend if it was something that needed to happen when an order has been placed successfully. I don’t know what your app needs to do. But I don’t think you want to be using twilio inside of the front end ionic client.
Also FYI you probably shouldn’t post your account id and auth token to the forums.
Sir, the id & auth is not original.
Sir i only need to send a sms to the admin’s mob number stating that "a new order is recieved " when user clicks on place order,
twi(){
const twilio = require(‘twilio’);
const accountSid = ‘’;
const authToken = ‘’;
// require the Twilio module and create a REST client
const client = new twilio(accountSid, authToken);
//var client = new twilio(accountSid, authToken);
client.messages.create
({
to: ‘+9190487’,
from: ‘+1610365’,
body: ‘TEST Alert Message !’,
})
.then((message) => console.log(message.sid));
}
}
twi() will b called when user clicks on place order button
go with the native plugin then probably
but native plugin will charge for sms from network operator na?