REQUEST A DEMO

Migrating a case from Clarify into a Zendesk ticket

I recently received a request asking how to migrate some data (specifically, cases) from Clarify into Zendesk. Seems the company is in the process of turning off Clarify and rolling out Zendesk.

 

clarrify to zendesk

It’s all about the APIs

 

We provide a full set of APIs for Clarify within our Dovetail SDK, and Zendesk also provides a set of APIs. So we just need to put them together.

PowerShell

 

I’ve been using PowerShell more and more lately, so I decided to use that as my environment. And because Powershell gives me full access to the .NET framework, I can use classes such as System.Net.WebClient, which makes it easy for me to call the Zendesk REST APIs.

Login to Clarify

 

In a previous post, I showed how to use some common functions in PowerShell for logging into a Clarify database.

 

. .\DovetailCommonFunctions.ps1
$ClarifyApplication = create-clarify-application;
$ClarifySession = create-clarify-session $ClarifyApplication;

Get the case data from Clarify

 

Now, we need to get the details of a case.

 

A quick little function to get a case given its ID number:

 

function get-case-by-id([string] $id)
{
$dataSet = new-object FChoice.Foundation.Clarify.ClarifyDataSet($ClarifySession)
$caseGeneric = $dataSet.CreateGeneric(“case”)
$caseGeneric.AppendFilter(“id_number”, “Equals”, $id)
$caseGeneric.Query();
$caseGeneric.Rows[0];
}

 

Then we can call this function that we just created:

 

$case = get-case-by-id “10”;

 

and get some case data:

 

$subject=$case[“title”];
$description = $case[“case_history”];

 

That’s all the Clarify stuff. Now onto the Zendesk side of things.

It’s a ticket in Zendesk

 

In Clarify, they’re called tickets. In Zendesk, they’re called tickets.

 

First, we’ll create the XML needed by the create ticket API:

 

$createTicketXML = “<ticket>”;
$createTicketXML+= “<subject><![CDATA[” + $subject + “]]></subject>”;
$createTicketXML+= “<description><![CDATA[” + $description + “]]></description>”;
$createTicketXML+= “</ticket>”;

Zendesk authentication and URL

 

$zendeskLoginName = “myLoginName”;
$zendeskPassword = “myPassword”;
$zendeskURL = “http://myZendeskAccount.zendesk.com/”
$ticketsURL = $zendeskURL + “tickets.xml”

A simple web request

 

As I mentioned earlier, since I’m in Powershell, I can easily use the System.Net.WebClient object. Setup the login credentials, set the content type to be application/xml, and then we can post the XML to create a ticket.

 

$webClient = new-object “System.Net.WebClient”
$webClient.Credentials = new-object System.Net.NetworkCredential($zendeskLoginName,$zendeskPassword )
$webClient.Headers.Add(“Content-Type”, “application/xml”);
$webClient.UploadString($ticketsURL,$createTicketXML);

Status Check and output

 

if ($webClient.ResponseHeaders[“Status”] -eq 201)
{
write-host “Successfully created a new ticket in Zendesk at:” $webClient.ResponseHeaders[“Location”]
}

 

This will output something like:

 

powershell

 

Successfully created a new ticket in Zendesk at: http://myZendeskAccount.zendesk.com/tickets/34.xml

Next steps

 

Next would be to probably get a list of cases from Clarify, loop through them, and for each one, create it in Zendesk.  I’ll leave that as an exercise for the reader.

Did I mention it’s all about the APIs?

 

Rock on.