Hello Everyone !
I am currently trying to integrate Twilio with CloudScript and have not had that much success. This question stands for Twilio but also all future services I plan on implementing.
I understood we weren't able to call libraries nor install anything so I can't install npms and use existing functions provided. I, therefore, went with the POST request side of things but faced numerous issues (I am not very used to doing it that way, more with NPMs ^^) like the request not reaching the service, returning undefined, or not returning at all.
Here is the docs in which they're telling me to do the following :
const accountSid = process.env.TWILIO_ACCOUNT_SID; const authToken = process.env.TWILIO_AUTH_TOKEN; const client = require('twilio')(accountSid, authToken); client.messages .create({ body: 'This will be the body of the new message!', from: '+15017122661', to: '+15558675310' }) .then(message => console.log(message.sid));
This isn't really possible since require() isn't usable on CloudScript. Another way they proposed was using cURL but this isn't possible as well in CloudScript :
curl -X POST https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json \ --data-urlencode "Body=This will be the body of the new message$EXCLAMATION_MARK" \ --data-urlencode "From=+15017122661" \ --data-urlencode "To=+15558675310" \ -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
So am I coming to you guys to know if anyone found or knows a way to go around all those limitations and just send a basic POST request from CloudScript to any service. If you could just provide a template, video or URL that shows what final form should my code have it would be great to help me understand the process I need to replicate to get this to work not only for Twilio but for any future service.
Deep and sincere thanks in advance !