Skip to end of metadata
Go to start of metadata

Introduction


To keep your HipChat users in the loop, you can add notifications of Salesforce activities into HipChat room. For example, this is useful to notify users on any changes to Leads or alert your Services team upon arrival of new support tickets.

This guide will help you to prepare the required Apex triggers and configure the activities you can subscribe to. If you haven't done so, configure the available objects and fields before proceeding with the following steps. The Salesforce package must have also been installed and configured.

Early beta testers, please review Notes for Beta Testers.

 

Part 1: Plan out your activity subscription


The connector provides subscription of three types of activity:

  • Object created
  • Object updated
  • Object created and updated, combined

All of these types can be applied to most standard and custom objects e.g. Lead, Contact, Case, etc.

You will need to configure the remaining parts below depending on the object type and activity type you chose here.

Part 2: Create and deploy Apex triggers


The connector relies on Apex Triggers to be informed of Salesforce activities. These triggers have to be created and deployed manually in Salesforce, but they are pretty simple triggers. For Salesforce Enterprise and Unlimited edition, the standard deployment of Apex triggers are required (see Salesforce documentation).

The following code samples show how to write notification triggers for Cases and the respective test code. To create triggers for other objects, replace the object name in the code accordingly.

Object created

trigger CaseInsertedHipChatWebhook on Case (after insert) {
	HCFS.HipChat.notify();
}

Object updated

trigger CaseUpdatedHipChatWebhook on Case (after update) {
	HCFS.HipChat.notify();
}

Object created and updated, combined

trigger CaseHipChatWebhook on Case (after insert, after update) {
	HCFS.HipChat.notify();
}

Apex test class for the triggers

Once triggers are created, they need to be tested to allow deployment to Production environment. A sample unit test for the triggers looks as follows:

@isTest
public class CaseHipChatWebhookTriggerTest {

	@isTest
	static void testTriggerAfterInsert() {
		HCFS.HipChatTriggerTestHelper.testAfterInsert('Case');
	}

	@isTest
	static void testTriggerAfterUpdate() {
		HCFS.HipChatTriggerTestHelper.testAfterUpdate('Case');
	}

}

Remember to replace the object name (API name) in the code accordingly.

If you are testing a Custom Object, provide the fully qualified name (include your namespace in the Salesforce Object Name)

  

@isTest
public class CustomObjectHipChatWebhookTriggerTest {
    
    static String sobjectName = 'yournamespace__CustomObject__c';
    
    @isTest
    static void testTriggerAfterInsert() {
        HCFS.HipChatTriggerTestHelper.testAfterInsert(sobjectName);
    }
   
    @isTest
    static void testTriggerAfterUpdate() {
        HCFS.HipChatTriggerTestHelper.testAfterUpdate(sobjectName);
    }

}


Part 3: Configure notification subscription


Once the Apex triggers are deployed, it's time to tell HipChat to subscribe to the notifications.

  1. In www.hipchat.com, visit the room's configuration page for the connector.

  2. Under the Available Salesforce Objects section, toggle the respective buttons for the object to subscribe. For example:



    Note that the notification will only be sent when it is turned on, and when the Apex trigger is installed and deployed. A successful configuration will notify the chatroom like this:



Page Contents

Due to the usage of Apex classes and Triggers, this feature is limited to Salesforce Enterprise, Unlimited and Developer editions only. See Supported Platforms.

  • No labels