I wish that someone can provide the page code, SMS.jsw, js file…event handle, if possible. I have read a related post which provided SMS.jsw. But as I am new to programming, I need more suggestions. Thanks
Joe
Is it the following code? Please help.
Again, thanks for the hyperlink.
//Backend code
import {ok, badRequest, notFound, serverError} from ‘wix-http-functions’;
import wixData from ‘wix-data’;
import { fetch } from ‘wix-fetch’;
export function sendSMS(number, body){
var accountSid ='xxxxxxxx ';
var authToken = ‘xxxxxxxx’;
var twilio = import (‘twilio’);
var client = new twilio(accountSid, authToken);
return client.messages.create({
body: body,
to: number,
from : ‘+1phone number’
})
.then((message) =>console.log(message));
}
//page code
import {sendSMS} from ‘backend/sendSMS’;
$w.onReady( function () {
//TODO: write your page related code here…
});
export function submit_click(event) {
const phone = $w(“#phone”).value;
const code = $w(“code”).value;
//const verificationCode = $w(“#verificationCode”).value;
//verifyCode(phone, code, verificationCode)
sendSMS(phone, code)
.then(response => console.log(response));
}
This is code for the Twilio NPM (the packages you can install thru backend/Install Node Package from the left pane menu). But this code is not going to work, I can tell you now (like : from : ‘+1phone number’ )
If you are new to coding, might I suggest you start out small, and first try to get this working using a Zapier Zap. Involves a lot less coding. Once you got that working, try your hand at NPM´s. Honestly, we should all try to learn how to walk first before trying to run.
Thank you for message.
Yes, I am a very beginner in coding.
For the code, (like : from : ‘+1phone number’ ) , I just hide my personal phone number.
For this task, I understand it involves some programming language.
Luckily, I follow the code " email through sendGrid after submission" from the example in Wix. It works.
So, that why’s I try to SMS through Twilio.
I have installed the package before the first comment. Anyway, I will continue to try.
Of course, I would appreciate very much if the others can help.