# To integrate free sms api in ionic 3

**URL:** <https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962>\
**Category:** ionic-v3\
**Created:** [March 9, 2018, 4:27am UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962 "2018-03-09T04:27:38Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![remilkr](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@remilkr](https://forum.ionicframework.com/u/remilkr)\
**Post date:** [March 9, 2018, 4:27am UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962/1 "2018-03-09T04:27:38Z")

</div>

anybody please help me to send a sms when an order is placed.

---

<div class="post-metadata">

**Author:** ![addwebsolution](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/addwebsolution/32/120392_2.png) [@addwebsolution](https://forum.ionicframework.com/u/addwebsolution)\
**Post date:** [March 9, 2018, 6:08am UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962/2 "2018-03-09T06:08:29Z")

</div>

Hi, @remilkr

try to integrate below native plugin

> **[Ionic Framework](https://ionicframework.com/docs/native/sms/)**
>
> Ionic is the app platform for web developers. Build amazing mobile, web, and desktop apps all with one shared code base and open web standards

thanks

---

<div class="post-metadata">

**Author:** ![bwhiting](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bwhiting/32/117866_2.png) [@bwhiting](https://forum.ionicframework.com/u/bwhiting)\
**Post date:** [March 9, 2018, 8:22am UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962/3 "2018-03-09T08:22:04Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![remilkr](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@remilkr](https://forum.ionicframework.com/u/remilkr)\
**Post date:** [March 10, 2018, 11:45am UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962/4 "2018-03-10T11:45:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bwhiting](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bwhiting/32/117866_2.png) [@bwhiting](https://forum.ionicframework.com/u/bwhiting)\
**Post date:** [March 11, 2018, 7:03pm UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962/5 "2018-03-11T19:03:04Z")

</div>

what line was the error on?

---

<div class="post-metadata">

**Author:** ![remilkr](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@remilkr](https://forum.ionicframework.com/u/remilkr)\
**Post date:** [March 12, 2018, 6:35am UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962/6 "2018-03-12T06:35:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bwhiting](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bwhiting/32/117866_2.png) [@bwhiting](https://forum.ionicframework.com/u/bwhiting)\
**Post date:** [March 12, 2018, 6:49am UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962/7 "2018-03-12T06:49:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![remilkr](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@remilkr](https://forum.ionicframework.com/u/remilkr)\
**Post date:** [March 12, 2018, 6:56am UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962/8 "2018-03-12T06:56:23Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![remilkr](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@remilkr](https://forum.ionicframework.com/u/remilkr)\
**Post date:** [March 12, 2018, 6:58am UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962/9 "2018-03-12T06:58:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![remilkr](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@remilkr](https://forum.ionicframework.com/u/remilkr)\
**Post date:** [March 12, 2018, 7:01am UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962/10 "2018-03-12T07:01:59Z")

</div>

![vvvvvvvvvv](https://global.discourse-cdn.com/ionicframework/original/3X/f/7/f7f08e4be5d46c38555cd7e16a5be8fcba95755e.PNG)

---

<div class="post-metadata">

**Author:** ![bwhiting](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bwhiting/32/117866_2.png) [@bwhiting](https://forum.ionicframework.com/u/bwhiting)\
**Post date:** [March 12, 2018, 7:08am UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962/11 "2018-03-12T07:08:06Z")

</div>

go with the native plugin then probably

---

<div class="post-metadata">

**Author:** ![remilkr](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@remilkr](https://forum.ionicframework.com/u/remilkr)\
**Post date:** [March 12, 2018, 7:28am UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962/12 "2018-03-12T07:28:00Z")

</div>

but native plugin will charge for sms from network operator na?

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:46pm UTC](https://forum.ionicframework.com/t/to-integrate-free-sms-api-in-ionic-3/123962/13 "2021-07-19T21:46:11Z")

</div>


