This example creates an action link template, instantiates the action link group, and associates the action link group with a feed element and posts the feed element.
Step 1: Create the Action Link Templates
Just like radio buttons, action links must be nested in a group. Action links within a group share the properties of the group and are mutually exclusive (you can click only one action link within a group). Even if you define only one action link, it must be part of an action link group. The same is true for action link templates and action link group templates.
This example uses one action link in an action link group. When a user clicks the action link, an HTTP POST request is made to a Connect REST API resource, which posts a feed item to Chatter. The HTTP Request Body field holds the request body for the Action URL resource, including the text of the new feed item. In this example, the new feed item includes only text, but it could include other capabilities such as a file attachment, a poll, or even action links.
From Setup, enter Action Link Templates in the Quick Find box, then select Action Link Templates.
Use these values in a new Action Link Group Template:
This Action Link Group Definition Input request body includes a templateBindings property that is a collection of Action Link Template Binding Input request bodies. In this example, the Action Link Template Binding Input request body includes three template bindings.
Request body example
1POST /services/data/v67.0/connect/action-link-group-definitions2{3 "templateId":"07gD00000004CEhIAM",4 "templateBindings" : [5 {6 "key":"ApiVersion",7 "value":"v33.0"8 },9 {10 "key":"Text",11 "value":"This post was created by an API Action Link!"12 },13 {14 "key":"SubjectId",15 "value":"me"16 }17 ]18}
Request example using cURL
To use cURL to make the request, enter the following and substitute your Developer Edition instance name, and OAuth information.
1curl -H "X-PrettyPrint: 1" -H "Content-Type: application/json" -d '{ "templateId":"07gD00000004CEhIAM",2"templateBindings" : [ { "key":"ApiVersion", "value":"v67.0" },3{ "key":"Text", "value":"This post was created by an API Action Link!" }, { "key":"SubjectId", "value":"me" } ] }'4 -X POST "https://{instanceName}/services/data/v67.0/connect/action-link-group-definitions"5 -H 'Authorization: OAuth 00DRR0000000N0g!RWaPj94O6yOD.lfjB9LqMk' --insecure
Response body
Action Link Group Definition
Step 4: Post a Feed Element
Associate the action link group with a feed element and post it. You can associate up to 10 action link groups with a feed element.
This Feed Item Input request body includes a body property that is a Message Body Input request body. In this example, the Message Body Input request body includes a messageSegments property that has one Message Segment Input: Text request body.
This Feed Item Input request body also includes a capabilities property that is a Feed Element Capabilities Input request body. In this example, the Feed Element Capabilities Input includes an associatedActions property that is a Associated Actions Capability Input request body.
Request body example
Grab the action link group ID from the id property of the Action Link Group Definition response from step 3.
To use cURL to make the request, enter the following and substitute the action link group ID returned in step 2, your Developer Edition instance name, and your OAuth information.