// We make use of the following public API
// https://documenter.getpostman.com/view/8854915/Szf26WHn
const url = "https://www.dataaccess.com/webservicesserver/NumberConversion.wso";
const body = `<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<NumberToWords xmlns="http://www.dataaccess.com/webservicesserver/">
<ubiNum>${input}</ubiNum>
// Additional headers may be required
// dpending on your server implementation
"Content-Type": "text/xml; charset=utf-8",
const options = { method: "POST", headers, body };
const chatlayer = ChatlayerResponseBuilder();
// Perform the request to the SOAP api
const response = await fetch(url, options);
// Extract the text value from the response
const xmlResponse = await response.text();
// Build and match the RegExp to extract data from the response
const regExp = new RegExp(
"<m:NumberToWordsResult>(.*?)</m:NumberToWordsResult>"
const match = xmlResponse.match(regExp);
throw new Error("Could not find the given number");
chatlayer.addMessage(result);
chatlayer.addMessage(ex.toString());