Newer Version Available

This content describes an older version of this product. View Latest

Define and Post Action Links

Action Links are currently available to select customers through a pilot program. To be nominated to join this pilot program, contact salesforce.com. Additional terms and conditions may apply to participate in the pilot program. Please note that pilot programs are subject to change, and as such, we cannot guarantee acceptance into this pilot program or a particular time frame in which this feature can be enabled. Any unreleased services or features referenced in this document, press releases, or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.

Note

Creating and posting action links require defining the action link, defining the action link group, and associating the action link group with a feed item. This example walks through each step.

Step 1: Define an Action Link

Think of an action link as a button on a feed item. Like a button, an action link includes a label (labelKey). An action link definition also includes other properties like a URL (actionUrl), an HTTP method (method), and an optional request body (requestBody) and HTTP headers (headers).

Action link definitions are always nested within an action link group definition. You can see the action link we define here nested in the action link group definition in step 2.

Request body
Action Link Definition Input
Request body example
1{
2   "actionType":"Api",
3   "actionUrl":"/services/data/v31.0/chatter/feed-elements",
4   "groupDefault":"true",
5   "labelKey":"Post",
6   "method":"Post",
7   "requiresConfirmation":"true",
8   "requestBody":"{\"subjectId\": \"me\",\"feedElementType\": \"FeedItem\",\"body\": {\"messageSegments\": [{\"type\": \"Text\",\"text\": \"Testing a post created via an API action link.\"}]}}",
9   "headers":[
10   {
11      "name":"Content-Type", "value":"application/json"
12   }]
13}

When a user clicks this action link, an HTTP POST request is made to a Chatter REST API resource, which posts a feed item to Chatter. The requestBody property holds the request body for the actionUrl 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.

Step 2: Define the Action Link Group

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 on only one action link within a group). Even if you defined only one action link (as we did in step 1), you must nest it in an action link group.

Resource
/connect/action-link-group-definitions
HTTP method
POST
Request body
Action Link Group Definition Input

This request body includes an actionLinks property that holds the nested Action Link Definition Input request body from step 1. If we had defined multiple action links, we would include them all in this property.

Request body example

When you joined the action links pilot, salesforce.com gave you a pilot key. In requests to action link resources, append the request with a pilotKey parameter and the value of your pilot key.

Note

1POST /services/data/v31.0/connect/action-link-group-definitions?pilotKey=R002AUMQV3GN
2
3{
4   "executionsAllowed":"OncePerUser",
5   "expirationDate":"2014-09-20T19:32:10+0000",
6   "category":"Primary",
7   "actionLinks":[
8   {
9      "actionType":"Api",
10      "actionUrl":"/services/data/v31.0/chatter/feed-elements",
11      "groupDefault":"true",
12      "labelKey":"Post",
13      "method":"Post",
14      "requiresConfirmation":"true",
15      "requestBody":"{\"subjectId\": \"me\",\"feedElementType\": \"FeedItem\",\"body\": {\"messageSegments\": [{\"type\": \"Text\",\"text\": \"This is a test post created via an API action link.\"}]}}",
16      "headers":[
17      {
18         "name":"Content-Type", "value":"application/json"
19      }]
20   }]
21}
Request example using cURL
To use cURL to make the request, enter the following and substitute your Developer Edition instance name, pilot key, and OAuth information.
1curl -H "X-PrettyPrint: 1" -H "Content-Type: application/json" -d '{ "executionsAllowed":"OncePerUser", "expirationDate":"2014-09-20T19:32:10+0000", "category":"Primary", "actionLinks":[ { "actionType":"Api", "actionUrl":"/services/data/v31.0/chatter/feed-elements", "groupDefault":"true", "labelKey":"Post", "method":"Post", "requiresConfirmation":"true", "requestBody":"{\"subjectId\": \"me\",\"feedElementType\": \"FeedItem\",\"body\": {\"messageSegments\": [{\"type\": \"Text\",\"text\": \"This is a test post created via an API action link.\"}]}}", "headers":[ { "name":"Content-Type", "value":"application/json" }] }] }' -X POST "https://instance_name/services/data/v31.0/connect/action-link-group-definitions?pilotKey=R002AUMQV3GN" -H 'Authorization: OAuth 00DRR0000000N0g!RWaPj94O6yOD.lfjB9LqMk' --insecure
Response body
Action Link Group Definition

Step 3: Associate the Action Link Group with a Feed Item and Post It

You can associate up to 10 action link groups with a feed element.
Resource
/chatter/feed-elements
HTTP method
POST
Request body
Feed Item Input
Request body example

Grab the action link group ID from the id property of the Action Link Group Definition response from step 2.

1POST /services/data/v31.0/chatter/feed-elements
2
3{
4  "body": {
5    "messageSegments": [
6      {
7        "type": "Text",
8        "text": "Click to post a feed item."
9       }
10    ]
11    },
12  "subjectId": "me",
13  "feedElementType": "feedItem",
14  "capabilities": {
15    "associatedActions": {
16      "actionLinkGroupIds": ["0AgRR0000004CTr0AM"]
17    }
18  }
19}
Request example using cURL
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.
1curl -H "X-PrettyPrint: 1" -H "Content-Type: application/json" -d '{ "body": { "messageSegments": [ { "type": "Text", "text": "Click to post a feed item." } ] }, "subjectId": "me", "feedElementType": "feedItem", "capabilities": { "associatedActions": { "actionLinkGroupIds": ["0AgRR0000004CTr0AM"] } } }' -X POST "https://instance_name/services/data/v31.0/chatter/feed-elements" -H 'Authorization: OAuth OOARoAQETAKEIddnMWXh462dprYAgRWaPj94O6yOD' --insecure
Response body
Feed Item