GitHub integration of Advanced Cloud Code - part 1
Tags: tutorial, twilio, npm, parseserver
Published: 2019-10-25 11:01:14

###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 an 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 applications with a 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](https://blog.sashido.io/github-integration-of-advanced-cloud-code-part-2) will describe how to 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](https://blog.sashido.io/how-to-set-up-cloud-code-on-sashido/). 
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.**

<script src="https://gist.github.com/pkeremidchieva/510799a80e26c33cdc5cb0c3ed5124e9.js"></script>
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. 

<script src="https://gist.github.com/pkeremidchieva/5e562919c1a65dea889e96d40d907504.js"></script>

Let’s write a simple function in twilio.js in the cloud directory, which will send an SMS to a number by your choice. 

<script src="https://gist.github.com/pkeremidchieva/273a9acb043f0e28a6a95b26582313e3.js"></script>

You can find 'ACCOUNT&#95;SID' and 'AUTH&#95;TOKEN'  in [Twilio’s Dashboard](https://www.twilio.com/login), here is [Twilio’s  documentation](https://www.twilio.com/docs/) in case you need it. 

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. 

![](https://media-blog.sashido.io/content/images/2016/10/1-1.png)

<br />

Let’s see the result on the phone :) 

![](https://media-blog.sashido.io/content/images/2016/10/img2-3.png)

<br />

If you followed the steps correctly, you should have received the SMS. In the [second](https://blog.sashido.io/github-integration-of-advanced-cloud-code-part-2) of the tutorial, we’ll learn how to set up npm package for local development. 


<a href="https://blog.sashido.io/github-integration-of-advanced-cloud-code-part-2" class="btn blue">GitHub integration of Advanced Cloud Code part 2</a>

If you have any difficulties or need help - reach us at support@sashido.io.


Happy coding :)