Technical Forum
Ask questions. Discover Answers.
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner

Send text message using external gateway


I have been asked to send a text message by integrating F5 APM with the Notify service using their API


REST API documentation - GOV.UK Notify (


Does anyone know the best way to do this from within an access policy after the "OTP generate" action?


Hi ,


there is a Codeshare from  that you might want to read in order to get some idea how to solve your issue:


He uses Twillio, but I think it can be adapted to work with the notify service.

The seems to provide a nodejs client/library too:




Yes,   is right. You should be able to adapt the code I've been using for the Twilio gateway to get this working via GOV.UK Notify. If needed, you can send me an temporary API key and templateid and I'll try to get it working.

Thanks for the replies, I will try to adapt your code. I'll need to provision iRulesLX on this Big-IP. I'll come back if I have any problems.


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:


F5 iRules LX - 1. Setting Up /TUTORIAL - YouTube

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: ( 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.

Hi Niels

I have followed your instructions and we have tried to adapt your code using the guidance on 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

if { [ACCESS::policy agent_id ] eq "gov_uk" } {

set generatedOTP "[ACCESS::session data get session.otp.assigned.val]"
set telephoneNumber "[ACCESS::session data get]"

if {[info exists generatedOTP] && ($generatedOTP eq "")} {
log local0. "Error: generatedOTP variable is empty; no OTP sent for $telephoneNumber."

if {([info exists telephoneNumber] && $telephoneNumber eq "")} {
log local0. "Error: telephoneNumber variable is empty; no OTP sent for $telephoneNumber."

set rpc_handle [ILX::init ilxplugin_gov_uk extension_gov_uk]
log "RPC Handle: $rpc_handle"
if {[ catch { ILX::call $rpc_handle sendOTP $generatedOTP $telephoneNumber } result ] } {
log local0. "sendOTP failed for telephoneNumber: $telephoneNumber, ILX failure: $result"

log local0. " status for user $username ($telephoneNumber): $result"
ACCESS::session data set session.custom.govuk.status $result



// 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 ID

var 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.