Setup of Twilio package tutorial
Building more complex apps without a lot of knowledge about back-ends and infrastructure sounds difficult, but we believe in Parse’s vision for letting developers create any app effortlessly. When we first launched early access for SashiDo, most of our lovely users asked for Advanced Cloud Code and we do understand why - it’s essential feature, because it’s flexible, allows you to write Express applications and use different packages such as Mashape, Mailgun etc. This means that Advanced Cloud Code gives you the opportunity to build more complex application with minimum of logic and no struggle. You only need to integrate a Cloud module into your SashiDo GitHub repo and you can easily use third-party services and libraries which will help you to create the dream product.
Those of you who haven’t used external packages will surely enjoy the power, given by them, and those of you who don’t know how to set them up with SashiDo, will see how easy and straight-forward it is.
This tutorial will show you how to setup Twilio ( an awesome API providing video and voice calls, send & receive SMS, MMS, authentication service for more secure apps ) into your Advanced Cloud Code. You can do the same with every Cloud module and the same technique will work with Android, iOS and any other platforms, supported by SashiDo. So let’s get started !
We’ll divide this tutorial into two parts: the first will show how to do the integration on the Cloud Code of SashiDo, and the second will describe how develop locally on your pc (in case you want to do some testing before deployment).
Setup of Twilio on SashiDo’s Cloud Code
You already know about your private GitHub repo, provided by SashiDo with your Cloud Code (if you’ve missed this important info, read more here.
Here is a helpful article about how to set up Git. Clone the repository, if you haven’t done it yet.
Find in the main directory file package.json. In package.json you can add all npm packages you want to use in your app. According to our tutorial this will be Twilio, but the same principle will apply for other npm packages.
P.S. Take a look at line 14.
We’ll create a new JavaScipt file named twilio.js and require it in the main.js file. Every Cloud Code file should be included there, otherwise it will not work.
Let’s write a simple function in twilio.js in the cloud directory, which will send a SMS to a number by your choice.
We’re ready with the preparations, it’s time to deploy our code.
git add . git commit -am 'Add twillio integration' git push
Keep in mind that every trigger causes a deploy in your application, so you don’t have to do anything about it.
Go to SashiDo’s Dashboard -> Core -> Cloud Code and wait until the code is finished deploying.
Now it’s time to test if our integration is successful: go to Core -> Api Console, make a POST request with function twilio.js and press Send Query.
Let’s see the result on the phone :)
If you followed the steps correctly, you should have received the SMS. In the second of the tutorial we’ll learn how to set up npm package for local development.
If you have any difficulties or need help - reach us at firstname.lastname@example.org .
Happy coding :)