Tuesday, September 4, 2012

Gamification and the CRM (XRM) Platform

The Gartner Group defines gamification as the concept of employing game mechanics to non-game activities such as recruitment, training and health and wellness. They also predict that by 2014, more than 70 percent of global 2,000 organizations will have at least one “gamified” application, which can range from mastering a specific skill or improving one’s health. 

Pretty impressive numbers, is it not? Reading about these emerging trends, I do wonder how our very own CRM 2011 can be applied to create business solutions that cater to those needs. The opportunities for businesses are great – from having more engaged customers, to crowdsourcing innovation or improving employee performance.

Business case:
I want to create a bare bones solution using the XRM framework in order to employ a few game mechanics to employee performance. 

The time taken to complete a call is going to be my touchpoint. Points will be allocated based on the duration of the phone call, which is then assigned to the Customer Service Representative (CSR).
Call completed in 10 min - 10 points
Call completed in 20 min - 5 points
Call completed in >20 min - 0 points

At the end of a designated time period (month, in this case) the points for the CSR are tallied up. 

Here are a few ways that top performers will be getting social recognition:
1. Badges (Platinum, Gold or Silver)
2. Automated Activity Feed posts that broadcasts the top performers name and points to the team
3. Leaderboard with the name of the top 3 performers as part of a dashboard.

Implementation Details:
1. Create 2 custom fields in User entity: One is for holding the points (integer type) and one is for the ranking (string type).

2. Create a workflow that fires on a call status of "complete". Based on the duration of the call, increment the point value in the user entity.

Note that a plugin could be a better option, but for my test case workflow should suffice.

3. Create a custom workflow activity. I have set it up to be a on demand and child process. The workflow process has a wait time of 1 month, after which it calls itself to calculate the next leader board.The custom workflow goes through the list of users, and selects the top 3 users with the highest number of points. Then the ranking for the user is set to 1, 2 or 3 depending on the points accrued. A post is also programatically created which mentions the 3 users as having achieved the top 3 rankings.

The code sample below is to get you started, with just the business logic in it:



                tracingService.Trace("getting user list");

                QueryByAttribute querybyexpression = new QueryByAttribute("systemuser");

                querybyexpression.ColumnSet = new ColumnSet("domainname", "new_points", "systemuserid", "address1_fax");

                //  Attribute to query


                //  Value of queried attribute to return


                Dictionary<string, int> numbers = new Dictionary<string, int>();

                //  Query passed to the service proxy

                EntityCollection retrieved = service.RetrieveMultiple(querybyexpression);

                //  Iterate through returned collection

                foreach (var c in retrieved.Entities)


                    string points = c.GetAttributeValue<int>("new_points").ToString();

                        if (string.IsNullOrEmpty(points) == false)


                            //add the userid and points to the dictionary

                            numbers.Add(c.GetAttributeValue<Guid>("systemuserid").ToString(), Int32.Parse(points));




                //get max value of points and associated user from the dictionary

                var maxid = string.Empty;

                var maxnum = 0;

                foreach (var kvp in numbers)


                    if (kvp.Value > maxnum)


                        maxid = kvp.Key;

                        maxnum = kvp.Value;



                //update user with highest points to #1 ranking

                if (string.IsNullOrEmpty(maxid) == false && maxnum >0)


                    Guid id = new Guid(maxid);

                    Entity user = new Entity("systemuser");

                    ColumnSet attributes = new ColumnSet(new string[] { "fullname", "domainname" });

                    user = service.Retrieve("systemuser", id, attributes);

                    if (user != null)


                        user["new_rank"] = "1";

                        user.EntityState = EntityState.Changed;


                        //create activity feed post on the wall
                        Entity post = new Entity("post");

                        post["regardingobjectid"] = user.ToEntityReference();

                        post["text"] = string.Format("@[{0},{1},\"{2}\"] user is ranked number 1!", "8",user.Id, user.GetAttributeValue<string>("fullname").ToString());






            catch (FaultException<OrganizationServiceFault> e)


                tracingService.Trace("Exception: {0}", e.ToString());

                throw new InvalidWorkflowException("new exception", e);


Let me walk through the code a bit. There is no need for any input or output parameters in this code activity. I get the list of users from the system, and add the points and userid to a dictionary. In this case, I am only looking for the highest points, and once i get that, I update the user with rank 1. I then create an activity feed  post mentioning the highest ranked user in a post. Remember to reset the user points to 0, to start a new evaluation cycle.

Note: The first run of the workflow is done manually, and ideally we would want to do it at the lat day of the month, so that the next run is the next month end. You could do it by setting up a wait condition in your workflow.

4. The activity feed post is created based on the code in step 3. I am utilizing activity feeds to make announcements about an achievement, thereby promoting social recognition.

5. Now for the badge, there are a couple of ways to go about this. One is to show a picture in the user form based on the ranking. Another is to color an iframe based on the ranking. Gonzalo Ruiz has a nice nice writeup that you can utilize for the latter. Its your choice!

6. Below is a leader board chart, which shows the top 3 performers based on points accrued. Add this chart to your service dashboard.

As you can see, we can easily leverage the xrm platform to address the new trends in our business sphere. The post is just a flavor of the possibilities, and even if it not the most polished solution, I hope it helped understand the power of the xrm framework.

Another way to approach gamification in CRM 2011 is using the goals entity, where you set the target and monitor progress towards it. Maybe an idea for a later post :)

Thanks for reading!

No comments:

Post a Comment