Calls with Twilio

Hi there,
I have a form on my site that asks for a persons phone number. They can click button A and get a message sent to them by text. Or they can click button B and get a call with the message. I am using Twilio as my text/call provider.

Button A, get the message by text works…see code below

import {ok, badRequest, notFound, serverError} from ‘wix-http-functions’;
import wixData from ‘wix-data’;
import { fetch } from ‘wix-fetch’;
import {getSecret} from ‘wix-secrets-backend’;
export async function sendSms(number, body) {
const accountSid = await getSecret(“mysid”);
const authToken = await getSecret(“mytoken”);
var twilio = require (‘twilio’);
var client = new twilio(accountSid, authToken);
return client.messages.create({
body: body,
to: number,
from : ‘+15555555555’
})
.then((message) => console.log(message.sid));
}

So for button B I assumed I could change some things around so that it would work for a call. I assumed that if i changed client. messages .create to client. calls .create it would send out the call. But it does not work.

any insights would be really appreciated?

1 Like