How to integrate SMS with a campaign

Created by Rob Garcia, Modified on Wed, 5 Apr, 2023 at 3:35 PM by Rob Garcia

With the Dialer it is possible to integrate with the Megacall SMS platform...


Firstly we need to create the account in the SMS platform, credit is subtracted from this amount when SMS messages are sent. We need to access the platform by going to https://sms.megacall.es


Once logged in we need to go to Accounts Administration





Then click on Create





Next we need to type in the following information:-


  • Account Name - The account name of the client, normally we would put in the Tenant Name
  • Tariff - We can just select General here as there is only really one tariff at the moment
  • Balance - This amount is what Accounts would add



Once done click on Create again to create the account....


Now we need to link the User to the account we just created, so we will click on "Users Administration" on the left hand menu....





Then we need to click on the Create button on the right hand side of the screen





We now need to fill out the following information:-


  • Name - This could be the users actual name (as one account may have many users)
  • Username - The Username which this person will use. It should be with NO spaces. Underscores and dots can be used
  • Password - The password that the user would like to have 
  • Confirm Password - Here we simply confirm the above password
  • User Role - It can be Administrator or a Regular user
  • Associate with Account - Here we select the relevant account from the dropdown menu.


Now we are going to create the SMS functionality in the Dialer.


To do this we first need to open up the campaign we want to use, then we need to go to the form view and create a HTML field...





In the HTML field we need to put the following code:-



<button  href="#" class="btn btn-raised raised-check" ng-click="temp.smsclient()" ng-disabled="temp.smsbutton" >SEND SMS</button>
<br /><br />
<div class="alert alert-success" ng-show="temp.transfer_msg">
    {{temp.transfer_msg}}
</div>
<div class="alert alert-danger" ng-show="temp.cannotsms">
   {{temp.cannotsms}}
</div>



This code will create the the SMS button together with the success message and the error message....





Next we need to save the settings and then go to the Script section of the campaign....


Outside of any of the functions we need to add the following code...



// ****** START SMS Logic ****** //
temp.smsclient = function () {
    temp.smsbutton = true;
    var tmpPhone = data.$phone;  // The primary phone number field in the Dialer
    tmpPhone = tmpPhone.substring(tmpPhone.indexOf("+") === 0 ? 1 : 0);
    $http({
        url: 'https://sms.megacall.es/api/sms_integracion',
        method: 'POST',
        data:{
            username: 'USERNAME',  // Username of the Account in SMS Platform
            password: 'PASSWORD', // Password of the Account in SMS Platform
            from_id: ID, // ID of the Account in SMS Platform
            to_sms: tmpPhone,
            body_sms: 'HERE WE TYPE THE TEXT THAT WE WANT TO DISPLAY IN THE SMS'
        },
        headers: {
            'Content-Type': 'application/json'
        }
    }).then(function(response){
        if(response.status != 200) {
            temp.transfer_msg = "It seems that there was a problem sending the SMS. Try again or contact support.";
        } else {
            temp.transfer_msg = "SMS Message sent successfully!";
        }
        setTimeout(function(){ temp.smsbutton = false; temp.transfer_msg = "";}, 5000);
    },function errorCallback(response) {
        console.log('SMS error:: ',response);
        temp.transfer_msg = "It seems that there was a problem sending the SMS. Try again or contact support.";
        setTimeout(function(){ temp.smsbutton = false; temp.transfer_msg = "";}, 5000);
    });
    
};
// ****** END SMS Logic ****** //



After the POST command we will see a section for the Username, Password and from_id. The Username and Password are those that we created in the "Users Administration" area of the SMS platform...


The from_id we can obtain by going to "Accounts Administration" and then clicking on the pencil icon next to the relevant account.





This will then display the different sub-accounts associated with that main account, this is because some clients may have many different campaigns and want to display a different phone number / name for each campaign. We can also decide which Supplier we use for each. The ID can be seen on the left hand side.





Once done we then go down to the body_sms section and here we need to type the text that we want to display in the SMS. By default SMS messages normally have a character limit of 160 characters. You can use the below calculator to see the number of characters your messages will use:-


http://smscharactercount.com/#/counter



For any further assistance please contact us at support@megacall.es.



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article