Run the nuget command for installing the client as Install-Package Intercom.Core.Client
Resources this API supports:
Each of these resources is represented through the dotnet client by a Class as ResourceClient
.
E.g.: for users, you can use the UsersClient
. For segments, you can use SegmentsClient
.
If you already have an access token you can find it here. If you want to create or learn more about access tokens then you can find more info here.
You can set the Personal Access Token
via creating an Authentication
object by invoking the single paramter constructor:
UsersClient usersClient = new UsersClient(new Authentication("MyPersonalAccessToken"));
If you are building a third party application you will need to implement OAuth by following the steps for setting-up-oauth for Intercom.
It is now possible to create all types of client by either supplying the authentication object instance or by providing an instance of the new RestClientFactory. The latter is the new preferred method to construct instances of the various clients. The older constructor methods have been marked as obsolete and will be removed in later versions.
Authentication auth = new Authentication("MyPersonalAccessToken");
RestClientFactory factory = new RestClientFactory(auth);
UsersClient usersClient = new UsersClient(factory);
UsersClient usersClient = new UsersClient(new Authentication("MyPersonalAccessToken"));
User user = usersClient.Create(new User() { user_id = "my_id", name = "first last" });
User user = usersClient.View("100300231");
User user = usersClient.View(new User() { email = "example@example.com" });
User user = usersClient.View(new User() { id = "100300231" });
User user = usersClient.View(new User() { user_id = "my_id" });
User user = usersClient.Update(new User() {
email = "example@example.com",
companies = new List<Company>() {
new Company() { company_id = "new_company" } } });
Dictionary<string, object> customAttributes = new Dictionary<string, object>();
customAttributes.Add("total", "100.00");
customAttributes.Add("account_level", "1");
User user = usersClient.View("100300231");
user.custom_attributes = customAttributes;
user = usersClient.Update(user);
Limited to up to 10k records, if you want to list more records please use the Scroll API
Users users = usersClient.List();
foreach(User u in users.users)
Console.WriteLine(u.email);
Dictionary<String, String> parameters = new Dictionary<string, string>();
parameters.Add("segment_id", "57553e93a32843ca09000277");
Users users = usersClient.List(parameters);
Users users = usersClient.Scroll();
String scroll_param_value = users.scroll_param;
Users users = usersClient.Scroll(scroll_param_value);
usersClient.Archive("100300231"); // with intercom generated user's id
usersClient.Archive(new User() { email = "example@example.com" });
usersClient.Archive(new User() { user_id = "my_id" });
usersClient.PermanentlyDeleteUser("100300231"); // with intercom generated user's id
User user = usersClient.UpdateLastSeenAt("100300231");
User user = usersClient.UpdateLastSeenAt(new User() { id = "100300231" });
User user = usersClient.UpdateLastSeenAt("100300231", 1462110718);
User user = usersClient.UpdateLastSeenAt(new User() { id = "100300231" }, 1462110718);
usersClient.IncrementUserSession(new User() { id = "100300231" });
usersClient.IncrementUserSession("100300231", new List<String>() { "company_is_blue" }});
// You can also update a User's session by updating a User record with a "new_session = true" attribute
User user = usersClient.RemoveCompanyFromUser("100300231", new List<String>() { "true_company" });
ContactsClient contactsClient = new ContactsClient(new Authentication("MyPersonalAccessToken"));
Contact contact = contactsClient.Create(new Contact() { });
Contact contact = contactsClient.Create(new Contact() { name = "lead_name" });
Contact contact = contactsClient.View("100300231");
Contact contact = contactsClient.View(new Contact() { id = "100300231" });
Contact contact = contactsClient.View(new Contact() { user_id = "my_lead_id" });
Contact contact = contactsClient.Update(
new Contact()
{
email = "example@example",
companies = new List<Company>() { new Company() { company_id = "new_company" } }
});
Limited to up to 10k records, if you want to list more records please use the Scroll API
Contacts contacts = contactsClient.List();
foreach (Contact c in contacts.contacts)
Console.WriteLine(c.email);
Contacts contacts = contactsClient.List("email@example.com");
Contacts contacts = contactsClient.Scroll();
String scroll_param_value = contacts.scroll_param;
Contacts contacts = contactsClient.Scroll(scroll_param_value);
Note that if the user does not exist they will be created, otherwise they will be merged.
User user = contactsClient.Convert(contact, new User() { user_id = "120" });
contactsClient.Delete("100300231");
contactsClient.Delete(new Contact() { id = "100300231" });
contactsClient.Delete(new Contact() { user_id = "my_id" });
VisitorsClient visitorsClient = new VisitorsClient(new Authentication("MyPersonalAccessToken"));
Visitor visitor = VisitorsClient.View("573479f784c5acde6a000575");
Dictionary<String, String> parameters = new Dictionary<string, string>();
parameters.Add("user_id", "16e690c0-485a-4e87-ae98-a326e788a4f7");
Visitor visitor = VisitorsClient.View(parameters);
Visitor visitor = VisitorsClient.Update(visitor);
Visitor visitor = VisitorsClient.Delete(visitor);
Visitor visitor = VisitorsClient.ConvertToUser(visitor, user);
Visitor visitor = VisitorsClient.ConvertToUser(visitor, new User(){ user_id = "25" });
Visitor visitor = VisitorsClient.ConvertToContact(visitor);
CompanyClient companyClient = new CompanyClient(new Authentication("MyPersonalAccessToken"));
Company company = companyClient.Create(new Company());
Company company = companyClient.Create(new Company() { name = "company_name" });
Company company = companyClient.View("100300231");
Company company = companyClient.View(new Company() { id = "100300231" });
Company company = companyClient.View(new Company() { company_id = "my_company_id" });
Company company = companyClient.View(new Company() { name = "my_company_name" });
Company company = companyClient.Update(
new Company()
{
company_id = "example@example",
monthly_spend = 100
});
Limited to up to 10k records, if you want to list more records please use the Scroll API
Companies companies = companyClient.List();
Companies companies = companyClient.Scroll();
String scrollParam = companies.scroll_param;
Companies companies = companyClient.Scroll(scrollParam);
foreach (Company c in companies.companies)
Console.WriteLine(c.name);
Users users = companyClient.ListUsers(new Company() { id = "100300231" });
Users users = companyClient.ListUsers(new Company() { company_id = "my_company_id" });
AdminsClient adminsClient = new AdminsClient(new Authentication("MyPersonalAccessToken"));
Admin admin = adminsClient.View("100300231");
Admin admin = adminsClient.View(new Admin() { id = "100300231" });
Admins admins = adminsClient.List();
TagsClient tagsClient = new TagsClient(new Authentication("MyPersonalAccessToken"));
Tag tag = tagsClient.Create(new Tag() { name = "new_tag" });
Tags tags = tagsClient.List();
tagsClient.Delete(new Tag() { id = "100300231" });
tagsClient.Tag("new_tag", new List<Company>() { new Company(){ company_id = "blue" } });
tagsClient.Tag("new_tag", new List<Company>() { new Company(){ id = "5911bd8bf0c7223d2d1d045d" } });
tagsClient.Tag("new_tag", new List<Contact>() { new Contact(){ id = "5911bd8bf0c7446d2d1d045d" } });
tagsClient.Tag("new_tag", new List<User>() { new User(){ id = "5911bd8bf0c7446d2d1d045d", email = "example@example.com", user_id = "25" } });
tagsClient.Untag("new_tag", new List<Company>() { new Company(){ company_id = "1000_company_id" } });
tagsClient.Untag("new_tag", new List<Contact>() { new Contact(){ id = "5911bd8bf0c7223d2d1d045d" } });
tagsClient.Untag("new_tag", new List<User>() { new User(){ user_id = "1000_user_id" } });
SegmentsClient segmentsClient = new SegmentsClient(new Authentication("MyPersonalAccessToken"));
Segment segment = segmentsClient.View("100300231");
Segment segment = segmentsClient.View(new Segment() { id = "100300231" });
Segments segments = segmentsClient.List();
NotesClient notesClient = new NotesClient(new Authentication("MyPersonalAccessToken"));
Note note = notesClient.Create(
new Note() {
author = new Author() { id = "100300231_admin_id" },
user = new User() { email = "example@example.com" },
body = "this is a new note"
});
Note note = notesClient.Create(new User() { email = "example@example.com" }, "this is a new note", "100300231_admin_id");
Note note = notesClient.View("2001");
Notes notes = notesClient.List(new User() { id = "100300231"});
foreach (Note n in notes.notes)
Console.WriteLine(n.user.name);
EventsClient eventsClient = new EventsClient(new Authentication("MyPersonalAccessToken"));
Event ev = eventsClient.Create(new Event() { user_id = "1000_user_id", email = "user_email@example.com", event_name = "new_event", created_at = 1462110718 });
Metadata metadata = new Metadata();
metadata.Add("simple", 100);
metadata.Add("simple_1", "two");
metadata.Add("money", new Metadata.MonetaryAmount(100, "eur"));
metadata.Add("richlink", new Metadata.RichLink("www.example.com", "value1"));
Event ev = eventsClient.Create(new Event() { user_id = "1000_user_id", email = "user_email@example.com", event_name = "new_event", created_at = 1462110718, metadata = metadata });
Events events = eventsClient.List(new User() { user_id = "my_id" });
CountsClient countsClient = new CountsClient(new Authentication("MyPersonalAccessToken"));
AppCount appCount = countsClient.GetAppCount();
ConversationAppCount conversationAppCount = countsClient.GetConversationAppCount();
ConversationAdminCount conversationAdminCount = countsClient.GetConversationAdminCount();
CompanySegmentCount companySegmentCount = countsClient.GetCompanySegmentCount();
CompanyTagCount companyTagCount = countsClient.GetCompanyTagCount();
CompanyUserCount companyUserCount = countsClient.GetCompanyUserCount();
UserSegmentCount userSegmentCount = countsClient.GetUserSegmentCount();
UserTagCount userTagCount = countsClient.GetUserTagCount();
ConversationsClient conversationsClient = new ConversationsClient(new Authentication("MyPersonalAccessToken"));
conversationsClient.View("100300231");
conversationsClient.View("100300231", displayAsPlainText: true);
conversationsClient.ListAll();
Dictionary<String, String> parameters = new Dictionary<string, string>();
parameters.Add("order", "asc");
conversationsClient.ListAll(parameters);
AdminConversationsClient adminConversationsClient = new AdminConversationsClient(new Authentication("MyPersonalAccessToken"));
AdminConversationMessage admin_message =
adminConversationsClient.Create(new AdminConversationMessage(
from: new AdminConversationMessage.From("1000_admin_id"),
to: new AdminConversationMessage.To(id: "1000_user_id"),
message_type: AdminConversationMessage.MessageType.EMAIL,
template: AdminConversationMessage.MessageTemplate.PERSONAL,
subject: "this is a subject",
body: "this is an email body"));
Conversation conversation =
adminConversationsClient.Reply(
new AdminConversationReply(
conversationId: "1000_conversation_id",
adminId: "1000_admin_id",
messageType: AdminConversationReply.ReplyMessageType.COMMENT,
body: "this is a reply body"));
Conversation reply =
adminConversationsClient.ReplyLastConversation(
new AdminLastConversationReply()
{
admin_id = "12434",
message_type = "comment",
body = "replying to last conversation",
intercom_user_id = "5911bd8bf0c7446d2d1d045d"
});
UserConversationsClient userConversationsClient = new UserConversationsClient(new Authentication("MyPersonalAccessToken"));
UserConversationMessage user_message =
userConversationsClient.Create(
new UserConversationMessage(
from: new UserConversationMessage.From(id: "1000_user_id"),
body: "this is a user's message body"));
Conversation conversation =
userConversationsClient.Reply(
new UserConversationReply(
conversationId: "1000_conversation_id",
body: "this is a user's reply body",
attachementUrls: new List<String>() { "www.example.com/example.png", "www.example.com/example.txt" }));
Not yet supported by these bindings.
- Increase test coverage
- Support Pagination
- Support Webhooks
- Support Async
- Have 100% feature parity with curl
- Add tests! Your patch won't be accepted if it doesn't have tests.
- Document any change in behaviour. Make sure the README and any other relevant documentation are kept up-to-date.
- Create topic branches. Don't ask us to pull from your master branch.
- One pull request per feature. If you want to do more than one thing, send multiple pull requests.
- Send coherent history. Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before sending them to us.