Posting Survey Link to Feed with Action Link Template

1 Introduction

In this blog, I am going to explain how to set up survey link to the chatter feed by using action link template.Here we are going to use Action Link Template Action type “UI”.UI Action will take the user to a Web page to the action URL. Here I am using SurveyMonkey survey link URL.

Please refer this link for more information on Action link templates Inside Action Link Templates

2 Create the Action Link Templates

Action link templates is a group of Actions that is going to be associated with the chatter feed. To create an Action link template From Setup, enter Action Link Templates in the Quick Find box, then select Action Link Templates. Click on New button then add the values in a new Action Link Group Template as shown below then save it.

Name Complete Survey
Developer Name Complete_Survey
Category Primary action
Executions Allowed Once per User

2

Now you create an Action Link Group Template . after that you can associate one or more action link templates.The action link template is automatically associated with an action link group template in a master-detail relationship. Add new action link template under the Action Link group template as shown below.

3.PNG

Action Type: UI
Action URL  https://www.surveymonkey.com/r/{!Bindings.surveylinkId}
User Visibility Everyone can see
Position 0
Label Key – none
HTTP Method GET
Label: Complete Survey

Now go to Action Link Group Template Detail Click on Edit then Check “Published” checkbox checked and save it. So that you can instantiate action line template group

3 . Get the Action Link Group Template ID

You need to get the previously defined action link template group Id. You can get in different ways like SOQL, Rest API or you can take from the URL. Action Link Template Group Object is Queriable so you can use simple SOQL as shown below

SELECT id FROM ActionLinkGroupTemplate WHERE DeveloperName=’Complete_Survey’

4.PNG

4 Instantiate the Action Link Group

You can instantiate the action link group by Using rest API or Apex Code. But in this case, I am using rest API along with workbench for rest API.

Login into workbench by using https://workbench.developerforce.com/logout.php URL. Go to Utilities -> rest explorer
End Point URL :- /services/data/v39.0/connect/action-link-group-definitions
Select operation as POST and Use the Body as shown below

 

If you can see above JSON is contacting the Action Linke Group Template Id and the array of TemplateBindings.  template bindings are contained key and values. Key should match with the action link template bindings variable reference and values is the corresponding values.{!Bindings.surveylinkId} === >  {

{!Bindings.surveylinkId} === >  {
“key”:”surveylinkId”,
“value”:”M6DQ2WD”
}

5

Click  on Execute now after that you see the JSON response as shown below which contains Action link id which you need to pass the Feed Element in next step

7.PNG

5 . Associate the Action Link Group with a Feed Element and Post It

Now in this step, you are going to create chatter feed and posting to the chatter. You can do it by using apex or rest API. here I am going to use rest API with workbench again.

Go to Utilities -> rest explorer
End Point URL :-/services/data/v39.0/chatter/feed-elements
Select operation as POST and Use the Body as shown below.

 

 

Now you can see the above request body contains action link group id instance which you got in earlier steps.

8.PNG

 

Click on Execute now. It will create a  new chatter feed post with action links as shown below.

9.PNG

On lick on of Complete Survey button, it will take you to the Survey link URL.