Creating custom tasks for Dovetail Task Manager
Out of the box, Dovetail Task Manager supports one action – Create Subcase. (See this post for a primer on Task Manager)
But because Task Manager is extensible, we can add our own custom actions that can do almost anything.
For this example, we’ll walk through how to add an action named Get Stock Quote, that will call an external web service to get a stock quote. The quote will then be logged as a note to the case.
Just for testing, we’ll use Alternate Phone Number field on the case to store the stock symbol.
Setup
Add the custom Task Action
Using Dovetail Admin, edit the Task Action user-defined list.
Add an element named Get Stock Quote
Add the custom Task Action parameters
Using Dovetail Admin, add a new user-defined list named Get Stock Quote Params
Add an element to this list named Symbol
The list name here is important. It’s conventional. The list name must be “{Task Action} Params”, where {Task Action} is the action we defined above.
You’ll notice in the next set of steps, where we set up the Task and its properties, that there’s no UI customization at all. It all just works.
Refresh Dovetail Agent’s cache
Using Dovetail Agent: Admin – cache – Refresh Cache
This allows Dovetail Agent to have access to the new user-defined lists and values that we just added.
Task Manager Setup
Task Property Template Setup
Using Dovetail Agent: Admin – Task Manager – Task Property Templates tab, click the +
in the tab header to add a new template with the following information:
Name: Stock Symbol
Action: Get Stock Quote
Data Type: String
Save To: Symbol
Click the Create
button.
The template will look like:
Task Setup
Using Dovetail Agent: Admin – Task Manager – Tasks tab, click the +
in the tab header to add a new task with the following information:
Name: Get Stock Quote
Status: Active
Action: Get Stock Quote
Workflow: None
Click the Create
button.
Task Property Setup
From the Get Stock Quote
task page, click the +
in the Properties tab header.
Select the Stock Symbol
property
Set the value to Same as case Property: alt_phone_num
Click the Create button
The task and property will look like:
Task Set Setup
Using Dovetail Agent: Admin – Task Manager – Task Sets tab, click the +
in the tab header to add a new task set with the following information:
Name: Get Stock Quote
Status: Active
Click the Create
button.
Add the Task to the Task Set
From the Get Stock Quote
task set page, click the +
in the Tasks tab header.
Select the Get Stock Quote
Task
Click the Add button
The task set will look like:
Customize Carrier
Dovetail Carrier needs to be customized so that it knows what to do when it receives a Get Stock Quote action. There’s 3 parts to this:
- Create a new class containing the information that we need to receive from Task Manager (i.e. the Symbol property)
- Create a policy so that the
Task Manager API
knows how to handle our newGetStockQuote Action
. We can do this by implementing theITaskRunnerPolicy
interface. - Register the new policy into our container.
I’m not going to go into the specific C# code details here.
But don’t worry, we’ve made all the code available freely on Github: http://dovetailsoftware.github.io/carrier-customizations/task-manager/
And it’s really not much code to make this work.
Run the Task Set
Now we can actually see it work.
From Dovetail Agent, open one of your cases, edit it, and set the Alternate Contact Phone Number to GOOG.
Remember that we’re simply using the alt phone field as a place to hold our stock symbol for testing.
Next, using the Workflow menu select: Run Task Set
Select the Get Stock Quote task set.
Click the Run Task Set button
Case History
Looking at the case history, we can see exactly what happened:
The user (Annie) ran the Get Stock Quote Task Set
Dovetail Rulemanager sent a message to Dovetail Carrier, telling it to Run a Dovetail Task Set
Dovetail Carrier received the message, made a web service call to get the stock price, and then logged the result as a note to the case.
Video
Here’s a short video that demonstrates the custom action
Summary
What we’ve done here is to extend Dovetail Task Manager with a custom action.
With custom code, actions can do whatever you want. In this example, we interfaced into another system (to get the stock quote), and then we did an operation in our Dovetail system (log a note to a case).
This means Task Manager actions are no longer limited to just creating subcases – it can now run custom code to do almost anything you want – and those things can be within Dovetail, or external.
Very cool!
All of the code for this example is available on Github: http://dovetailsoftware.github.io/carrier-customizations/
Next up – I’ll discuss how to have Carrier invoke custom code without using Task Manager – which opens up even more possibilities. I’ll have that post coming soon. Stay tuned.