HelpScoutNet is a .NET class library that provides an easy-to-use interface for the helpscout.net v2.0 web api
- Conversation
- Customers
- Mailboxes
- Tags
- Users
- Workflows
Nothing done yet
var client=new HelpScoutApiClient("clientId","clientSecret");
//initialize token from the given credentials
await client.GetToken(true);
List Customer
//search customer by their first name, pass null to list
var searchQuery = new CustomerSearchQuery(){FirstName = "Otis" };
var pagedCustomer = await client.Customers.List(searchQuery);
foreach (var customer in pagedCustomer.Items)
{
Console.WriteLine("First Name :{0}, Last Name: {1}",customer.FirstName,customer.LastName);
}
Get Customer Detail
//search customer by their first name, pass null to list
var customerDetail= await client.Customers.Get(id);
Console.WriteLine($"First Name:{customerDetail.FirstName}");
foreach (var email in customerDetail.Embedded.Emails)
{
Console.WriteLine($"Email:{email.Value}, Type:{email.Type}");
}
var mailBoxList = await client.Mailboxes.List();
foreach (var mailBox in mailBoxList.Items)
{
Console.WriteLine($"{mailBox.Name}");
}
var req = new ConversationCreateRequest
{
MailboxId = 177024,
Type = ConversationType.Email,
Subject = "Hey there!",
Tags = new List<string> { "high-priority" },
Status = ConversationStatus.Pending,
Customer = new Customer
{
Email = "[email protected]"
},
Threads = new List<ThreadCreateRequest>
{
//add a note to this conversation
new ThreadCreateRequest
{
Type = ThreadType.Note,
Text = "Can you please resolve this issue asap.",
},
new ThreadCreateRequest
{
Type = ThreadType.Customer,
Text = "This issue keeps happening.",
Customer = new CreateConservationThreadCustomer
{
Email = "[email protected]"
}
}
}
};
var conversationId = await client.Conversations.Create(req);
Console.WriteLine($"Created Conversation Id: {conversationId}");
var conversationDetail = await client.Conversations.Get(conversationId);
Console.WriteLine($"Subject: {conversationDetail.Subject}");
await client.Conversations.Delete(conversationId);
var threadEndpoint = client.Conversations.Endpoints.Threads(conversationId);
var customerThread = new CreateThreadRequest()
{
Text = "This is a customer thread"
};
await threadEndpoint.CreateCustomerThread(customerThread,customerId);
//Similarly, Chat, Phone, Reply threads can be created
var noteThread = new CreateThreadRequest()
{
Text = "This is a note thread"
Attachments=new List<Attachment>{
new Attachment{
FileName="Some attachment name",
MimeType="image/png",
Data=Convert.ToBase64String(File.ReadAllBytes("C:\\some-attachment.png"))
}
}
};
//note thread does not require customerId
await threadEndpoint.CreateNoteThread(noteThread);