Sending custom messages inside Actions for failed API's

I’m hoping someone can help me with this issue. I call an API as soon as a user types ‘hello’ or triggers an intent that also calls the API, but when the API fails the bot responds with the default error message. The code below skips the API call (since the API doesn’t work) and just continues onto the next node (which I don’t want unless the API works).

How can I respond to the user with a specific message that tells them the API isn’t working or is down?

this is my action ‘getUrlApi.js’ that calls the API:

async function action(bp: typeof sdk, event: sdk.IO.IncomingEvent, args: any, { user, temp, session } = event.state) {
  /** Your code starts below */

  const axios = require('axios')

  /**
  * @title getURL Api
  * @category 
  * @author 
  */

  const getUrlAPI = async () => {
    try {
      const { data } = await axios.get('http://10.123.456.789:3001/get_url')
      session.response = data
    } catch (e) {
      console.log('!! Error while trying to fetch getURL API', e);
      const payload = await bp.cms.renderElement('builtin_text', {text: 'If you are seeing this message, the API is down. Please contact a technician to resolve this issue before proceeding.'},event);
      await bp.events.replyToEvent(event, payload);
    }
    return getUrlAPI()
  }
  /** Your code ends here */
}

Error fixed. I moved the return getURLAPI() down one line after the second to last curly bracket.

async function action(bp: typeof sdk, event: sdk.IO.IncomingEvent, args: any, { user, temp, session } = event.state) {
  /** Your code starts below */

  const axios = require('axios')

  /**
  * @title getURL Api
  * @category 
  * @author 
  */

  const getUrlAPI = async () => {
    try {
      const { data } = await axios.get('http://10.123.456.789:3001/get_url')
      session.response = data
    } catch (e) {
      console.log('!! Error while trying to fetch getURL API', e);
      const payload = await bp.cms.renderElement('builtin_text', {text: 'If you are seeing this message, the API is down. Please contact a technician to resolve this issue before proceeding.'},event);
      await bp.events.replyToEvent(event, payload);
    }
  }
    return getUrlAPI()
  /** Your code ends here */
}