Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
SurveyInvitationLinkShortener Interface
Namespace
Usage
Implement an instance of the SurveyInvitationLinkShortener interface to shorten the survey invitation that can be distributed as short URLs over customer engaged channels, such as SMS, WhatsApp, or Facebook Messenger.
Special access rules
To implement this interface, you must have the Salesforce Feedback Management license enabled in your Salesforce organization.
SurveyInvitationLinkShortener Example Implementation
This is an example implementation of the sfdc_surveys.SurveyInvitationLinkShortener interface.
This sample code uses Named Credentials for authentication. For more information on Named Credentials, see Named Credentials as Callout Endpoints.
1public class SurveyInvitationLinkShortenerImpl implements sfdc_surveys.SurveyInvitationLinkShortener {
2 public String getShortenedURL(String invitationURL) {
3 return shortenUrlUsingBitlyService(invitationURL);
4 }
5 public String shortenUrlUsingBitlyService(String invitationURL) {
6 HttpRequest request = new HttpRequest();
7 request.setEndpoint('callout:bitly/v4/shorten');
8 request.setMethod('POST');
9 request.setHeader('Authorization', 'Bearer {!$Credential.Password}');
10 request.setHeader('Accept', 'application/json');
11 request.setHeader('Content-Type', 'application/json');
12 request.setBody(JSON.serialize(new Map<String, Object>{
13 'group_guid' => '{!$Credential.UserName}',
14 'long_url' => invitationURL
15 }));
16
17 Http http = new Http();
18 HttpResponse res = http.send(request);
19
20 Object result = JSON.deserializeUntyped(res.getBody());
21 if (result instanceof Map<String, Object>) {
22 Map<String, Object> resultMap = (Map<String, Object>) result;
23 Object shortenedLinkVal = resultMap.get('link');
24 if(shortenedLinkVal != null && shortenedLinkVal instanceof String) {
25 return (String) shortenedLinkVal;
26 }
27 }
28 return invitationURL;
29 }
30}