Optionally provide private feedback to help us improve this article...

Thank you for your feedback!

Adding ticket replies using the InstantKB .NET API

In this article we show how to add replies to existing support tickets within InstantKB using the InstantKB .NET API. As with other examples before you can use the InstantKB .NET API you'll first need to reference the InstantKB assemblies from your Visual Studio project.

Getting Started

Add the necessary using statement to your C# class...

using InstantASP.InstantKB;

Our Example

In this example we'll add 10 replies to an existing ticket. We'll first query to ensure the ticket exists and then iterate 10 times adding a new reply to the ticket each time. We then display the new replies to ensure they were added correctly.

// ----------------
// add replies
// ----------------

// get InstantKB context
var context = HttpContext.KnowledgeBaseContext.Current;

// we'll add a reply to ticket ID 5
var t = new Business.TicketRepository(context.CurrentUser);
var ticket = t.SelectTicket(5);

if (ticket != null)
// let's add 10 replies to ticket 5
var tr = new Business.TicketReplyRepository(context.CurrentUser);
for (var i = 1; i <= 10; i++)
var reply = tr.InsertUpdateTicketReply(new Components.TicketReply()
TicketID = ticket.TicketID,
TicketReplyUserID = context.CurrentUser.UserID,
TicketText = "Reply Text " + i.ToString(),


// ----------------
// show new replies
// ----------------

// let's display our new replies
// the second boolean parameter 
// ensures we invalidate the cache
// ensuring the latest replies are returned
var updatedTicket = t.SelectTicket(5, true);
if (updatedTicket != null)
foreach (var reply in updatedTicket.TicketReplyCollection)
Response.Write(reply.TicketText + "<br/>");

That's It!

We hope this simple example helps you integrate InstantKB into your applications. Of course if we can provide any further examples or assist please never hesitate to submit a support request.