Send SMS OTP to Mobile using API in Pega

“Security is not a product but a process”. Pega provides various options to ensure security of an end user. One of its ways of ensuring security is authentication- the process of verifying the identity of a user via mobile OTP.

This article illustrates how pega ensures authenticity of a user.by using mobile OTP.

Example Scenario :

ABC company uses the pega platform to verify the authenticity of customers by generating the one time password(OTP) and sending it to the registered mobile number of the customer. . Let’s have a look at how pega performs it .

Configuration:

Step 1 :Create fast2sms account

Register on www.fast2sms.com  for messaging service

Once successfully registered, login with your credentials. After logged-in, at the left side panel, you will get an option Dev API. Click on it.

In Dev API section, copy developer’s API authorization key & paste into notepad

C:\Users\royal\AppData\Local\Microsoft\Windows\INetCache\Content.Word\s11.jpg

Step 2: Configure Case type

Create a case type SMS

Create Mobile property in step which will configured for sending sms

C:\Users\royal\AppData\Local\Microsoft\Windows\INetCache\Content.Word\vlcsnap-2021-04-29-22h48m57s444.png

Step 3. Create Activity for Connect-Rest: 

Create an activity by following the path:

Create 🡪 Technical 🡪 Activity

Method: Connect-Rest

Method parameters:    

  • ServiceName: “Connect-Rest” service name
  • MethodName: Get
  • ExcuationMode: Run

Now click on gear icon next to service name and create Connect-Rest

C:\Users\royal\AppData\Local\Microsoft\Windows\INetCache\Content.Word\vlcsnap-2021-04-30-21h49m18s023.png

Now Create Connect-Rest:

In the Service tab provide Endpoint URL: https://www.fast2sms.com/dev/bul

Endpoint URL will be unique to the SMS API you are using. Refer to API documentation on the respective website to find the Endpoint URL

Go to Method Tab, in Get Section on Request Tab

Add Additional query string parameters

Name 
Map From 
Map From key 
authorization Constant YOUR_API_KEY
sender_id Constant FSTSMS 
message Clipboard .pyTempInteger
route Constant 
language Constant english 
numbers Clipboard .Mobile
flash Constant 0

You must replace YOUR_API_KEY with your Fast2SMS account API Authorization Key which look like this: “weBQKBrtZzLnD2ZUEnUYJIO40zZGnjgZm3BA1SAUd0qZ56gHm0k3X45DWR9c

C:\Users\royal\AppData\Local\Microsoft\Windows\INetCache\Content.Word\vlcsnap-2021-04-30-22h05m09s532.png

Save it and go to Service Tab, at the bottom of the window click on “Test Connectivity” Button.

This image shows that connection is successfully done. It is giving Neutralstatus because in messageand numbersString parameters values are not present, it is coming from clipboard.

After creating Connect-Rest , plugin this service into SendSMS activity

Step 4: Create DataTransform:

Create🡪Data Model🡪Data Transform

C:\Users\royal\AppData\Local\Microsoft\Windows\INetCache\Content.Word\vlcsnap-2021-04-30-22h24m35s014.png

Use Random function to get the random decimal number and use the round function to make it an integer. 

Example: round(random(1000,5000))

Step 5: Configure Section

Open Section: App explorer🡪Expand casetype🡪UserInterface🡪Section

Add button & configure ActionSet for it

1.Configure the Event As : Refresh this section

2.Configure the Event as :Flow in Modal dialog

C:\Users\royal\AppData\Local\Microsoft\Windows\INetCache\Content.Word\vlcsnap-2021-04-30-22h33m07s031.png

Click gear icon next to the Flow name & Create the Flow

C:\Users\royal\Pictures\vlcsnap-2021-04-30-22h35m49s398.png

After creating Flow, Open the connector & click gearicon next to the Flow Action and Create it.

C:\Users\royal\Pictures\vlcsnap-2021-04-30-22h38m00s506.png

In layout tab, in the section field enter section name 

click gear icon next to the section name & create it

      Create the following fields:

Property TypeName
LabelOTP has been sent to the Mobile Number
Text InputEnter OTP
ButtonResend OTP

Action Set for Button field:

  • Finish Assignment
  • Refresh this section (Plugin DataTransforn & Activity)
  • Flow in Modal dialog (Plugin Current Section Flow)

Save all the rules (Section, FlowAction & Flow)

Step 6: Create EditValidate rule

Create the validate rule by following the path :Create🡪Process🡪Validate

In property field, select EnterOTP property

C:\Users\royal\Pictures\vlcsnap-2021-04-30-22h50m47s897.png

In Assignment FlowAction, call this EditValidate rule 

(Casetype🡪Open Process🡪Open Assignment🡪Open FlowAction )

Save all rules and Run

Youtube Video:

Happy Learning!!!

2 Comments

Add yours →

  1. Hi ,

    I have tried with below url but sms is not generating to given mobile number
    URL :: https://www.fast2sms.com/dev/bulkV2

    Any Suggestion to overcome this issue??

    Thanks in Advance.

  2. Great!!

© 2024 Pega Tech

Theme by Anders NorénUp ↑

error: Content is protected !!