` with a class equal to `Coveo` followed by the name of your custom action.
**Example**
In the previous step, your action was called `MyCustomAction`.
Inside the `
` element, you add the following div:
```xml
```
. Repeat these steps for every result template that should have present your custom action.
. Save your modifications by clicking **Save**.
Your custom action is now ready to be used.
## Examples
Here are some specific use cases for custom actions.
Feel free to adapt and integrate them in your installations.
### Action: Send Email
This action creates a Salesforce email and attaches a link to the selected result.

> **Important**
>
> For this action to work, the Email-to-Case functionality must be enabled (see [Enable and Configure Email-to-Case](https://help.salesforce.com/articleView?id=customizesupport_enabling_email_to_case.htm&type=5)).
. When adding script to your Visualforce Page, add the following line before the `script` element.
```xml
```
. In your `script` element, add the following code:
```javascript
var MyCustomEmail = function(element, options, bindings, result) {
this.type = 'MyCustomEmail';
Coveo.Component.bindComponentToElement(element, this);
this.element = element;
this.options = options;
this.bindings = bindings;
this.result = result;
};
__extends(MyCustomEmail, Coveo.Component);
MyCustomEmail.prototype.getTitle = function () {
var menuDiv = $(''); // Change the caption to display here
var _this = this;
menuDiv.click(function() {
// Change the body of the email to display your custom message
var body = 'Hi,
'+ 'This article from our Knowledge Base might help you:
'+'
'+_this.result.title+'Regards
Ramiro Reeves, Product Specialist at BestTech';
Sfdc.canvas.publisher.publish({name: "publisher.selectAction", payload: {actionName:"Case.Email"}});
Sfdc.canvas.publisher.publish({name: "publisher.setActionInputValues", payload:{actionName:"Case.Email", emailFields: {subject: {value: 'This article might help you'}, body: {value:body}}}});
});
return menuDiv.get(0);
};
MyCustomEmail.ID = 'MyCustomEmail';
Coveo.CoveoJQuery.registerAutoCreateComponent(MyCustomEmail);
```
. When adding your `div` element in your `CoveoBoxResultAction` div of your result template, ensure that you give it the `CoveoMyCustomEmail` class, as such:
```xml
```

### Action: Insert into Case Feed
This action inserts a result link into the case feed comments.

. When adding script to your Visualforce Page, add the following line before the `script` element.
```xml
```
. In your `script` element, add the following code:
```javascript
var MyCustomInsertIntoFeed = function(element, options, bindings, result) {
this.type = 'MyCustomInsertIntoFeed';
Coveo.Component.bindComponentToElement(element, this);
this.element = element;
this.options = options;
this.bindings = bindings;
this.result = result;
};
__extends(MyCustomInsertIntoFeed, Coveo.Component);
MyCustomInsertIntoFeed.prototype.getTitle = function () {
var menuDiv = $(''); // Change the caption to display here
var _this = this;
menuDiv.click(function() {
// You can add things to display alongside the result link here
var body = _this.result.title + '\n' + _this.result.clickUri.split(' ').join('%20');
Sfdc.canvas.publisher.publish({name: "publisher.selectAction", payload: {actionName:"Case.CaseComment"}});
Sfdc.canvas.publisher.publish({name: "publisher.setActionInputValues", payload:{actionName:"Case.CaseComment", portalPostFields: {body: {value: body}, sendEmail: {value:false}}}});
Sfdc.canvas.publisher.publish({name: 'publisher.refresh', payload : {feed: {value: true}}});
});
return menuDiv.get(0);
};
MyCustomInsertIntoFeed.ID = 'MyCustomInsertIntoFeed';
Coveo.CoveoJQuery.registerAutoCreateComponent(MyCustomInsertIntoFeed);
```
. When adding your `div` element in your `CoveoBoxResultAction` div of your result template, ensure that you give it the `CoveoMyCustomInsertIntoFeed` class, as such:
```xml
```

### Action: Create a Salesforce KB article
> **Available since**
>
> This feature was introduced in the July 2016 release of Coveo for Salesforce version [2.25](https://docs.coveo.com/en/1124#july-2016-release-v225).
A new **Create Article** button is now available out of the box.
To learn how to implement it in your Salesforce integration, see [Adding a "Create Article" Button to the Coveo Insight Panel Classic Component](https://docs.coveo.com/en/1305/).
This action creates a Salesforce KB article from a result.

. When adding script to your Visualforce Page, add the following line before the `script` element.
```xml
```
. In your `script` element, add the following code:
```javascript
sforce.connection.sessionId='{!GETSESSIONID()}'; // This needs to be added to create objects since Spring '16
var MyCustomCreateKB = function(element, options, bindings, result) {
this.type = 'MyCustomCreateKB';
Coveo.Component.bindComponentToElement(element, this);
this.element = element;
this.options = options;
this.bindings = bindings;
this.result = result;
};
__extends(MyCustomCreateKB, Coveo.Component);
MyCustomCreateKB.prototype.getTitle = function () {
var menuDiv = $(''); // Change the caption to display here
var _this = this;
menuDiv.click(function() {
var kb = new sforce.SObject('Troubleshooting__kav'); // Change 'Troubleshooting' to your KB type
kb.Summary = '{!JSENCODE(case.Description)}';
kb.Title = '{!JSENCODE(case.Subject)}';
kb.URLName = '{!JSENCODE(case.Subject)}'.replace(/\s+/g, '-').replace(/[^a-zA-Z-0-9\-]/g, '') +'-'+ (Math.random() * 100000 + '').replace('.', '-');
var createResult = sforce.connection.create([kb]);
if (createResult[0].getBoolean("success")) {
openSubTab('/' + createResult[0].id, kb.Title);
menuDiv.addClass('hidden')
} else {
console.log('Failed creating custom KB',createResult);
}
});
return menuDiv.get(0);
};
MyCustomCreateKB.ID = 'MyCustomCreateKB';
Coveo.CoveoJQuery.registerAutoCreateComponent(MyCustomCreateKB);
function openSubTab(url, title) {
sforce.console.getEnclosingPrimaryTabId(function (result) {
sforce.console.openSubtab(result.id, url, true, title);
});
}
```
. When adding your `div` element in your `CoveoBoxResultAction` div of your result template, ensure that you give it the `CoveoMyCustomCreateKB` class, as such:
```xml
```
