Forum Home › Forums › Understanding the Software › SMS with two factor authentification
Tagged: SMS notification
- This topic has 18 replies, 2 voices, and was last updated 1 month, 1 week ago by
Mikhail.
-
AuthorPosts
-
December 3, 2025 at 9:25 am #17357
oley
ParticipantHi,
I need to send an SMS about a discreet channel change.
I have modems that can send SMS messages, but they work with double authorization: first, a request for a token with access data, and then sending an SMS with the token.
An example PS script looks like this:$ip = "172.16.1.2:81" $username = "admin" $password = "pass" $phoneNumber = "+48123456789" $messageText = "Test sms" $modemId = "2-1" try { $loginUrl = "http://$ip/api/login" $loginBody = @{ username = $username; password = $password } | ConvertTo-Json $loginResponse = Invoke-RestMethod -Uri $loginUrl -Method Post -Body $loginBody -ContentType "application/json" $token = $loginResponse.token } catch { exit 1 } try { $smsUrl = "http://$ip/api/messages/actions/send" $smsBody = @{ data = @{ number = $phoneNumber; message = $messageText; modem = $modemId } } | ConvertTo-Json -Depth 3 $smsResponse = Invoke-RestMethod -Uri $smsUrl -Method Post -Body $smsBody -ContentType "application/json" -Headers @{ Authorization = "Bearer $token" } } catch { exit 1 }I don’t really see the possibility of standard notification from Rapid SCADA.
I could write this code in C# and use it to send SMS messages.Please give me some tips on how to approach this.
Best regards
PrzemekDecember 3, 2025 at 11:40 am #17358
MikhailModeratorHi,
Check DrvHttpNotif driver. It can send HTTP requests according to commands.
To send a sequence of commands, use Auto Control Module.
Ask for additional info if needed.December 3, 2025 at 11:44 am #17359
MikhailModeratorProbably, the existing driver does not preserve a token returned by the 1st request.
December 3, 2025 at 11:45 am #17360
MikhailModeratorIs it possible for you to select an alternative service that needs only one HTTP request to send a message?
December 3, 2025 at 11:49 am #17361oley
ParticipantThank you,
yes I will provide simple proxy service which can become single request and make two-factor request.December 3, 2025 at 1:02 pm #17362oley
ParticipantIs there a possibility to simply test if this solution works?
If I had the service which works like:Invoke-RestMethod -Uri "http://localhost:5150/send-sms" -Method Post -Headers @{ "Content-Type" = "application/json" } -Body '{"phoneNumber":"+48111111111","message":"Test API"}'and put Url into DrvHttpNotif with content type json and so on. How to send a test message?
December 3, 2025 at 1:45 pm #17363oley
Participant<?xml version="1.0" encoding="utf-8"?> <NotifDeviceConfig> <Uri>http://localhost:5150/send-sms</Uri> <Method>Post</Method> <Headers> <Header name="Content-Type" value="application/json" /> </Headers> <Content>{ "phoneNumber": "+486011111", "message": "SCADA" } </Content> <ContentType>application/json</ContentType> <ContentEscaping>EncodeJson</ContentEscaping> <ParamEnabled>false</ParamEnabled> <ParamBegin>[</ParamBegin> <ParamEnd>]</ParamEnd> <AddrSep>;</AddrSep> </NotifDeviceConfig>-
This reply was modified 1 month, 1 week ago by
Mikhail.
December 3, 2025 at 3:23 pm #17364oley
ParticipantOne more request: could you remove the phone number from the configuration I sent? I can’t edit my message.
December 3, 2025 at 9:35 pm #17366oley
ParticipantI made it work.
I created a proxy service that accepts POST requests and sends SMS messages with two-factor authentication based on them.
Since the request is in JSON format, I have to use [param] instead of {param} for the parameters.
The Headers tab probably refers to the response, because when I set Content-Type there, I kept getting the error: “Error creating request: Misused header name, ‘Content-Type’. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects.”I will send something like: {CnlName} on {EvDev} at {EvObj} changed value to {CnlVal}
I suppose this should be Channel Data Change Trigger and than Command with code “Request” to my Notifier device.
Now is the question: how to send SMS to a recipient from the address book?December 4, 2025 at 9:17 am #17368
MikhailModeratorI’ve checked the source code of the driver.
Parameters (phone number and text) can be inserted in the request URL and content.
This is so weird that the service requires to insert phone number in the request header.Usually headers contain auth tokens and similar things.
P.S. Phone number in the above was changed.-
This reply was modified 1 month, 1 week ago by
Mikhail.
December 4, 2025 at 9:18 am #17369
MikhailModeratorYou wrote
-Body '{"phoneNumber":"+48111111111","message":"Test API"}'
It’s related to the request contents, not headers.December 4, 2025 at 9:19 am #17370
MikhailModeratorExample of the content:
{ "from": "SCADA", "to": [phone], "message": "[text]" }Set ParamEnabled to true.
December 4, 2025 at 9:21 am #17372
MikhailModeratorTo use a phone book, see the available commands in the driver description on the Drivers page.
December 4, 2025 at 9:23 am #17373oley
ParticipantHi Mikhail,
thank you. I can send an SMS from SCADA with simple “Request” command. It works.
Now I want to use it as notifier. So I have some contacts in the address book.
I have Channel Data Change Trigger in ACM.
How to connect this together? Command to device DrvHttpNotif? But how to access this address book?December 4, 2025 at 9:27 am #17375oley
ParticipantCan’t find any doc for this driver. Can you give me a link to this description?
-
This reply was modified 1 month, 1 week ago by
-
AuthorPosts
- You must be logged in to reply to this topic.