Businesses need verified customers/users so that they can share important information about business/ regulatory updates. Businesses will need a verified phone number in every stage of the customer lifecycle including account creation, transaction authentication, and ongoing customer engagement activities to decrease the potential for compromised security. Phone/Mobile verification can be done using many ways. This post will verify phone using Flow Http Callout (Beta) with VeriPhone API.
We have already published a post to Verify Phone in Salesforce using VeriPhone API using a low code approach. This post is using the same API to verify phones using no-code approach.
HTTP Callout (Beta) is a new feature in the Salesforce Flow to call external API without code. This way we can easily maintain external API interaction. Right now it is supporting only GET operation of API.
Steps for implementing and integrating VeriPhone API
- Setup User in VeriPhone API
- Create a Permission Set for Callout
- Create an External Credential and a Named Credential
- Create Salesforce Flow to Verify Phone/Mobile
- Test Flow
Let us implement all these steps one by one
1. Setup User in VeriPhone API
Create a free user in VeriPhone system. You can use your Gmail or GitHub user also for creating a free user account.
Once registration is done, verify the account using the confirmation link. A confirmation email will be sent to the email which is used for registration. After confirmation, you can see your API key detail in the setting section.
2. Create a Permission Set for Callout
Create a permission set Callout User PS and assign this permission set to yourself. This permission set will be assigned to all users who need to call external API using flow. You can create a permission set from Setup -> Permission Sets
Assign object permission (CRUD) “User External Credentials” to store encrypted tokens used by named credentials.
3. Create an External Credential and a Named Credential
We will create a named credential to call external API. We have a lot of benefits using named credentials, you can check our video for more information. We will create external credentials first before creating named credentials.
An external credential represents the details of how Salesforce authenticates to an external system via an authentication protocol. In our case, we have an API key that is passed in the URL to authenticate callout so we will use a custom authentication protocol.
Once we set the authentication protocol, set permission set mapping which will indicate who all users can call named credentials.
We are done with the external credential setup. Let us set up the named credential using the above external credential.
Put base API URL in Url property for named credential. If we have an API Url
https://api.veriphone.io/v2/verify?phone=49-15123577723&key=266B0091BC9547A2A40DD088795FA4C6
then only put https://api.veriphone.io and the rest of the URL will be appended using the Http Callput action. Add the above-created external credential to the External Credential property.
4. Create Salesforce Flow to Verify Phone/Mobile
Now let us create a screen flow Verify Phone that will validate the customer’s phone number and update the verification status in the account record.
a. Get Current Record
Create a recordId property of the account record type. We will get the current sObject record in this property. recordid is a dynamic variable that can hold record id as well as sObject.
b. Create a dynamic Action
Now drag an Action element on the screen element. You will get + Create HTTP Callout (Beta) in the action selection dialog. We will get New HTTP Callout (Beta) screen to create a callout in flow.
Put the required information in the HTTP Callout screen.
(1) – API URL path. This will be appended to the base named credential Url that is set in the named credential.
(2) – Required Url parameters. Values for these parameters are replaced using Flow variables.
(3) – Provide Sample response JSON to create respionse Apex Class automatically.
Provide sample response JSON by clicking on Add/Edit in Provide Sample Response section. This will create a response apex wrapper class.
This process will create an external service VeriPhoneES that can be checked using Setup->External Services. It will also create a dynamic apex response class.
c. Create a Response Object
Let us create an element that will store the response after the HTTP callout action is performed. That response object will be used to get the status of phone verification.
d. Call API using Dynamic External Service
Call dynamic external service in flow that was created after HTTP Callout (Beta) action was created. As per API, we have to pass the API key and Phone number that need to verify. The response is saved in the above-created response object.
The API key can be saved in custom settings/custom metadata and can be populated from there. I have hardcoded it for demo purposes.
e. Update Phone Verification using Update Element
Based on the response object update status of the current account record phone verification.
e. Complete Flow
5. Test Flow
Now everything is set up. Let us
- Create an action button “Verify Phone using HTTP Method” in the account object and open the above flow Verify Phone on that button call.
- Add created button in the respective page layout or the app builder page
Test any account record where a phone number is entered. Click on the button “Verify Phone using HTTP Method” and check the verification status.
References for Flow Http Callout
Related Posts
Verify Phone in Salesforce using VeriPhone API
Dynamic Code Execution using Callable Interface
Salesforce DropBox Integration to upload files
Need Help?
Need some kind of help in implementing this feature, connect on linked-in profile.
1 Comment
Pingback: Current Record in Salesforce Flow - SalesforceCodex