Forum Discussion
Send text message using external gateway
You have to replace the content of the default index.js file. This video was a good starting point for me te learn more about iRuleLX:
- kevinmcJan 20, 2022Altocumulus
Thanks Niels, that was a good series of videos so I understand a lot more now. I did run into this issue iRulesLX error: error: 01070711:3: boost::filesystem::status: Permission denied: (f5.com) when I installed the module so had to follow that workaround but I think everything is in place now and I just need to get the code right. I'll post the correct code here if it works or (more likely) I may need to ask another question.
- kevinmcFeb 04, 2022Altocumulus
Hi Niels
I have followed your instructions and we have tried to adapt your code using the guidance on gov.uk. I am getting this error:
Rule /Common/ilxplugin_gov_uk/irule_gov_uk <ACCESS_POLICY_AGENT_EVENT>: sendOTP failed for telephoneNumber: +447767826522, ILX failure: ILX timeout. invoked from within "ILX::call $rpc_handle sendOTP $generatedOTP $telephoneNumber "
Can you see what the error could be? I can give you the apiKey and templateId if needed
This is my iRule
when ACCESS_POLICY_AGENT_EVENT {
if { [ACCESS::policy agent_id ] eq "gov_uk" } {set generatedOTP "[ACCESS::session data get session.otp.assigned.val]"
set telephoneNumber "[ACCESS::session data get session.ad.last.attr.extensionAttribute1]"if {[info exists generatedOTP] && ($generatedOTP eq "")} {
log local0. "Error: generatedOTP variable is empty; no OTP sent for $telephoneNumber."
return
}if {([info exists telephoneNumber] && $telephoneNumber eq "")} {
log local0. "Error: telephoneNumber variable is empty; no OTP sent for $telephoneNumber."
return
}set rpc_handle [ILX::init ilxplugin_gov_uk extension_gov_uk]
log local0.info "RPC Handle: $rpc_handle"
if {[ catch { ILX::call $rpc_handle sendOTP $generatedOTP $telephoneNumber } result ] } {
log local0. "sendOTP failed for telephoneNumber: $telephoneNumber, ILX failure: $result"
return
}log local0. "gov.uk status for user $username ($telephoneNumber): $result"
ACCESS::session data set session.custom.govuk.status $result
}
}index.js
// Import the f5-nodejs module.
var f5 = require('f5-nodejs');// Create a new rpc server for listening to TCL iRule calls.
var ilx = new f5.ILXServer();var apiKey = 'x'; // Your API Key
var templateId = 'x'; // Your Template IDvar NotifyClient = require('notifications-node-client').NotifyClient;
var notifyClient = new NotifyClient(apiKey);ilx.addMethod('sendOTP', function(req, res) {
var generatedOTP = req.params()[0];
var phoneNumber = req.params()[1];
var personalisation = { 'passcode': generatedOTP };
var reference = null;notifyClient.sendSms(templateId, phoneNumber, {personalisation: personalisation,reference: reference})
.then(response => console.log(response))
.catch(err => console.error(err));
//.then((response) => {return res.reply(response);});
//.catch((response) => {return res.reply(response);});
});// Start listening for ILX::call and ILX::notify events.
ilx.listen();
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com