'use strict';

const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const messagingServiceSid = process.env.TWILIO_MESSAGING_SERVICE_SID;

const client = require('twilio')(accountSid, authToken);

module.exports.postMessage = function (phone, messageText) {
  const payload = {
    to: phone,
    messagingServiceSid,
    body: messageText,
  };

  return client.messages.create(payload);
};

@@ -177,16 +177,67 @@
 ICE_SID;
+%0Aconst fromNumber = process.env.TWILIO_FROM_NUMBER;
 %0A%0Aconst 
@@ -388,16 +388,47 @@
 ne,%0A    
+body: messageText,%0A  %7D;%0A%0A  if (
 messagin
@@ -442,37 +442,112 @@
 eSid
-,
+) %7B
 %0A    
-body: messageText,%0A  %7D;
+payload.messagingServiceSid = messagingServiceSid;%0A  %7D else %7B%0A    payload.from = fromNumber;%0A  %7D
 %0A%0A  

Support Twilio From number