Yes, you can most definitely use a Send Phone Message Action to set the recipient phone number.
Since Hooks have been deprecated, here is the converted script in an Action:
exports.onExecuteSendPhoneMessage = async (event, api) => {
// Start formatting code
const PNF = require('google-libphonenumber').PhoneNumberFormat;
const phoneUtil = require('google-libphonenumber').PhoneNumberUtil.getInstance();
// // Load recipient into the phone number object.
let enteredNum = phoneUtil.parse(event.message_options.recipient);
// // E.164 format recipient
let e164Num = phoneUtil.format(enteredNum, PNF.E164);
// End formatting code
// Not shown: Call Phone message provider as normal using the value of e164Num instead of recipient.
// Assuming that your message sending logic is synchronous or wrapped in a Promise,
// you can just await on it here. Example:
// await sendMessage(e164Num, event.message);
// In an Action, there is no need to explicitly return a success response like in Hooks,
// unless you wish to terminate the Action execution under certain conditions.
};
Thanks Rueben. Since I’m using the Esendex plugin to send the SMS message from the marketplace, I was hoping I was able to format the recipient in the flow before Esendex kicked in, in the next stage. Maybe I need to not use the Esendex plugin, and create an action to use Esendex in the action and hence pass the E.164 number?