Sending OTP via sms in a pre user registration action

I have an action in my Pre User Registration that sends an sms via an sms provider.
Now I want to send an TOTP via the script. Since I can’t get the custom sms gateway to work.

It it even possible and the right way of doing it (I know it is a inferior option then custom sms gateway)?

Hi @pbr,

Welcome to the Auth0 Community!

Have you considered using Passwordless Authentication with SMS?

If so, please give us some additional details on your flow and expected outcome.

{
    strategy: 'sms',
    provider: 'sms_gateway',
    gateway_url: 'https://gatewayapi.com/rest/mtsms',
    from: 'My_project',
    template: 'Your verification code is: @@password@@', 
    brute_force_protection: true,
    forward_req_info: 'true',
    disable_signup: false,
    name: 'sms',
    syntax: 'md_with_macros',
    totp: {
      time_step: 180,
      length: 4
    },
    gateway_authentication: {
      method: 'bearer',
      subject: 'urn:Auth0',
      audience: 'urn:MySmsGateway',
      secret: 'my_token',
      secret_base64_encoded: true
    }
  }

on the sms gateway I have a token, a secret and a key
The secret and key is for 0auth.

const fetch = require("node-fetch"); // npm install node-fetch
const util = require("util");

exports.onExecutePreUserRegistration = async (event, api) => {
console.log("local flow")
async function sendSMS() {  
  const phone_numb = event.user.phone_number


    const payload = {
    sender: "ExampleSMS",
    message: event.message_options.code,
    recipients: [
      { msisdn: phone_numb },
    ],
  };

  const apiToken = event.secrets.api_token;
  const encodedAuth = Buffer.from(`${apiToken}:`).toString("base64");

  const resp = await fetch("https://gatewayapi.com/rest/mtsms", {
    method: "post",
    body: JSON.stringify(payload),
    headers: {
      Authorization: `Basic ${encodedAuth}`,
      "Content-Type": "application/json",
    },
  });
  const json = await resp.json()
  console.log(util.inspect(json, {showHidden: false, depth: null}));
  if (resp.ok) {
    console.log("congrats! messages are on their way!");
  } else {
    console.log("oh-no! something went wrong...");
  }
}

  sendSMS();
};

is my action and it can send if I set the message to a string
But I can’t seem to send the OTP with it.