You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pages/integrations/salesforce/index.md
+53-22Lines changed: 53 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ description: Integrate Friendly Captcha into your Salesforce environment
7
7
8
8
# Friendly Captcha for Salesforce
9
9
10
-
To integrate Friendly Captcha into your Salesforce environment, you can use [Friendly Captcha for Salesforce][appexchange], a package available on Salesforce AppExchange.
10
+
<!--To integrate Friendly Captcha into your Salesforce environment, you can use [Friendly Captcha for Salesforce][appexchange], a package available on Salesforce AppExchange.-->
11
11
12
12
Integrating Friendly Captcha involves a front-end component and a back-end component. We recommend familiarizing yourself with the [Friendly Captcha documentation][fcdocs] to develop a baseline understanding of how an integration works.
13
13
@@ -83,7 +83,7 @@ friendlycaptcha.VerifyResult result = friendlycaptcha.Client.verifyCaptchaRespon
83
83
84
84
### Lightning Web Component
85
85
86
-
You can pass front-end configuration parameters to the `<friendlycaptcha-widget>` LWC as follows.
86
+
You can pass front-end configuration parameters to the `<friendlycaptcha-widget>` LWC like this:
87
87
88
88
```
89
89
<friendlycaptcha-widget
@@ -97,17 +97,11 @@ You can pass front-end configuration parameters to the `<friendlycaptcha-widget>
97
97
98
98
## Flow Example
99
99
100
-
This example shows how to use Friendly Captcha for Salesforce in a Flow. We'll create
101
-
a simple login screen that displays a Friendly Captcha Widget and includes server-side
102
-
captcha verification.
100
+
This example shows how to use Friendly Captcha for Salesforce in a Flow. We'll create a simple login screen that displays a Friendly Captcha Widget and includes server-side captcha verification. The pattern outlined here should be translatable anywhere you can use LWCs and Apex classes.
103
101
104
102
### Create a new Screen Flow in Setup
105
103
106
-
This will open the Flow Builder app with Start and End elements. Add a Screen Flow with
107
-
an Email component and a Password component, and then scroll down to the list of custom
108
-
components to add a Friendly Captcha Widget component. If you haven't configured your
109
-
integration by following the steps listed above, make sure to at least add a value for
110
-
the Sitekey field at this step.
104
+
This will open the Flow Builder app with Start and End elements. Add a Screen Flow with an Email component and a Password component, and then scroll down to the list of custom components to add a Friendly Captcha Widget component. If you haven't configured your integration by following [the steps listed above](#configuration), make sure to at least add a value for the Sitekey field at this step (under **Properties**).
<img src="/img/salesforce-screen-flow.png" alt="Configuring a Screen Flow" />
@@ -156,19 +150,15 @@ public class LoginAction {
156
150
}
157
151
```
158
152
159
-
This Apex Action performs a Friendly Captcha API call to verify the captcha response from the previous element in the
160
-
Flow. If Friendly Captcha is able to verify the captcha response, the `success` flag is set to true. Any errors
161
-
returned by the API are also included in the output of this Flow element.
153
+
This Apex Action calls the Friendly Captcha API to verify the captcha response generated in the previous Flow element. If Friendly Captcha is able to verify the captcha response, the `success` flag is set to true. Any errors returned by the API are also included in the output of this Flow element.
162
154
163
155
The `friendlycaptcha.Client.verifyCaptchaResponse()` method requires an API key for authentication. Make sure you've configured an API key as outlined in the documentation on [configuration](#configuration).
164
156
165
-
You could perform other kinds of validation (for example on the email and password) in this action as well.
166
-
Save the Apex class and return to your Screen Flow.
157
+
You could perform other kinds of validation (for example on the email and password) in this action as well. Save the Apex class and return to your Screen Flow.
167
158
168
159
### Add the "Verify Captcha" Apex Action to your Screen Flow
169
160
170
-
It should come after the Login Screen element. Make sure to connect the "Captcha Response" (and optionally "Sitekey")
171
-
variables from the Screen element as inputs to the Apex Action element.
161
+
It should come after the Login Screen element. Make sure to connect the "Captcha Response" (and optionally "Sitekey") variables from the Screen element as inputs to the Apex Action element.
<img src="/img/salesforce-apex-action.png" alt="Configuring an Apex Action" />
@@ -177,26 +167,67 @@ variables from the Screen element as inputs to the Apex Action element.
177
167
178
168
### Add a Decision element based on the output of the Apex Action
179
169
180
-
You can use the `success` and `error` output variables of the Apex Action to render success or failure screens.
181
-
Add a Decision element that leads to "Success" or "Failure" based on whether the `success` variable is true or
182
-
false. In this example, depending on whether the verification is successful, a different screen is presented.
170
+
You can use the `success` and `error` output variables of the Apex Action to render success or failure screens. Add a Decision element that leads to "Success" or "Failure" based on whether the `success` variable is true or false. In this example, depending on whether the verification is successful, a different screen is presented.
<img src="/img/salesforce-flow-decision.png" alt="Configuration of a Decision Flow element" />
186
174
<figcaption><i>Configuration of a Decision Flow element</i></figcaption>
187
175
</figure>
188
176
189
-
You can also conditionally render the error message if it's present:
177
+
In this implementation, we chose to render Screen elements that showed a simple confirmation text on success, and a failure message otherwise. In the failure message, you can conditionally render the error message if it's present:
[Click here for the Apex reference documentation.](reference/)
196
+
197
+
### Lightning Web Component
198
+
199
+
Using the LWC from code (e.g., from within another LWC) looks like this:
200
+
201
+
```
202
+
<friendlycaptcha-widget
203
+
sitekey={sitekey}
204
+
api-endpoint={endpoint}
205
+
theme={theme}
206
+
start-mode={startMode}
207
+
language={language}
208
+
></friendlycaptcha-widget>
209
+
```
210
+
211
+
Note that all properties (except `sitekey`) are optional and have sensible defaults. The LWC will attempt to read these properties from the "Settings" record of the `Config__mdt` CMDT; properties passed directly to the LWC take precedence.
212
+
213
+
The LWC also exposes all events exposed by [the widget itself][widget-events]:
214
+
215
+
```
216
+
<friendlycaptcha-widget
217
+
sitekey={sitekey}
218
+
oncomplete={handleComplete}
219
+
onerror={handleError}
220
+
onexpire={handleExpire}
221
+
onstatechange={handleStateChange}
222
+
></friendlycaptcha-widget>
223
+
```
224
+
225
+
Each event handler receives an `event` argument with a `detail` property matching the shapes documented on the [Widget SDK Events page][widget-events].
0 commit comments