.NET bindings for the Intercom API
We're currently building a new team to provide in-depth and dedicated SDK support.
In the meantime, we'll be operating on limited capacity, meaning all pull requests will be evaluated on a best effort basis and will be limited to critical issues.
We'll communicate all relevant updates as we build this new team and support strategy in the coming months.
Run the nuget command for installing the client as Install-Package Intercom.Dotnet.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:
UsersClientusersClient=newUsersClient(newAuthentication("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.
Authenticationauth=newAuthentication("MyPersonalAccessToken");RestClientFactoryfactory=newRestClientFactory(auth);UsersClientusersClient=newUsersClient(factory);UsersClientusersClient=newUsersClient(newAuthentication("MyPersonalAccessToken"));Useruser=usersClient.Create(newUser(){user_id="my_id",name="first last"});Useruser=usersClient.View("100300231");Useruser=usersClient.View(newUser(){email="example@example.com"});Useruser=usersClient.View(newUser(){id="100300231"});Useruser=usersClient.View(newUser(){user_id="my_id"});Useruser=usersClient.Update(newUser(){email="example@example.com",companies=newList<Company>(){newCompany(){company_id="new_company"}}});Dictionary<string,object>customAttributes=newDictionary<string,object>();customAttributes.Add("total","100.00");customAttributes.Add("account_level","1");Useruser=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
Usersusers=usersClient.List();foreach(Useruinusers.users)Console.WriteLine(u.email);Dictionary<String,String>parameters=newDictionary<string,string>();parameters.Add("segment_id","57553e93a32843ca09000277");Usersusers=usersClient.List(parameters);Usersusers=usersClient.Scroll();Stringscroll_param_value=users.scroll_param;Usersusers=usersClient.Scroll(scroll_param_value);usersClient.Archive("100300231");// with intercom generated user's idusersClient.Archive(newUser(){email="example@example.com"});usersClient.Archive(newUser(){user_id="my_id"});usersClient.PermanentlyDeleteUser("100300231");// with intercom generated user's idUseruser=usersClient.UpdateLastSeenAt("100300231");Useruser=usersClient.UpdateLastSeenAt(newUser(){id="100300231"});Useruser=usersClient.UpdateLastSeenAt("100300231",1462110718);Useruser=usersClient.UpdateLastSeenAt(newUser(){id="100300231"},1462110718);usersClient.IncrementUserSession(newUser(){id="100300231"});usersClient.IncrementUserSession("100300231",newList<String>(){"company_is_blue"}});// You can also update a User's session by updating a User record with a "new_session = true" attributeUseruser=usersClient.RemoveCompanyFromUser("100300231",newList<String>(){"true_company"});ContactsClientcontactsClient=newContactsClient(newAuthentication("MyPersonalAccessToken"));Contactcontact=contactsClient.Create(newContact(){});Contactcontact=contactsClient.Create(newContact(){name="lead_name"});Contactcontact=contactsClient.View("100300231");Contactcontact=contactsClient.View(newContact(){id="100300231"});Contactcontact=contactsClient.View(newContact(){user_id="my_lead_id"});Contactcontact=contactsClient.Update(newContact(){email="example@example",companies=newList<Company>(){newCompany(){company_id="new_company"}}});Limited to up to 10k records, if you want to list more records please use the Scroll API
Contactscontacts=contactsClient.List();foreach(Contactcincontacts.contacts)Console.WriteLine(c.email);Contactscontacts=contactsClient.List("email@example.com");Contactscontacts=contactsClient.Scroll();Stringscroll_param_value=contacts.scroll_param;Contactscontacts=contactsClient.Scroll(scroll_param_value);Note that if the user does not exist they will be created, otherwise they will be merged.
Useruser=contactsClient.Convert(contact,newUser(){user_id="120"});contactsClient.Delete("100300231");contactsClient.Delete(newContact(){id="100300231"});contactsClient.Delete(newContact(){user_id="my_id"});VisitorsClientvisitorsClient=newVisitorsClient(newAuthentication("MyPersonalAccessToken"));Visitorvisitor=VisitorsClient.View("573479f784c5acde6a000575");Dictionary<String,String>parameters=newDictionary<string,string>();parameters.Add("user_id","16e690c0-485a-4e87-ae98-a326e788a4f7");Visitorvisitor=VisitorsClient.View(parameters);Visitorvisitor=VisitorsClient.Update(visitor);Visitorvisitor=VisitorsClient.Delete(visitor);Visitorvisitor=VisitorsClient.ConvertToUser(visitor,user);Visitorvisitor=VisitorsClient.ConvertToUser(visitor,newUser(){user_id="25"});Visitorvisitor=VisitorsClient.ConvertToContact(visitor);CompanyClientcompanyClient=newCompanyClient(newAuthentication("MyPersonalAccessToken"));Companycompany=companyClient.Create(newCompany());Companycompany=companyClient.Create(newCompany(){name="company_name"});Companycompany=companyClient.View("100300231");Companycompany=companyClient.View(newCompany(){id="100300231"});Companycompany=companyClient.View(newCompany(){company_id="my_company_id"});Companycompany=companyClient.View(newCompany(){name="my_company_name"});Companycompany=companyClient.Update(newCompany(){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
Companiescompanies=companyClient.List();Companiescompanies=companyClient.Scroll();StringscrollParam=companies.scroll_param;Companiescompanies=companyClient.Scroll(scrollParam);foreach(Companycincompanies.companies)Console.WriteLine(c.name);Usersusers=companyClient.ListUsers(newCompany(){id="100300231"});Usersusers=companyClient.ListUsers(newCompany(){company_id="my_company_id"});AdminsClientadminsClient=newAdminsClient(newAuthentication("MyPersonalAccessToken"));Adminadmin=adminsClient.View("100300231");Adminadmin=adminsClient.View(newAdmin(){id="100300231"});Adminsadmins=adminsClient.List();TagsClienttagsClient=newTagsClient(newAuthentication("MyPersonalAccessToken"));Tagtag=tagsClient.Create(newTag(){name="new_tag"});Tagstags=tagsClient.List();tagsClient.Delete(newTag(){id="100300231"});tagsClient.Tag("new_tag",newList<Company>(){newCompany(){company_id="blue"}});tagsClient.Tag("new_tag",newList<Company>(){newCompany(){id="5911bd8bf0c7223d2d1d045d"}});tagsClient.Tag("new_tag",newList<Contact>(){newContact(){id="5911bd8bf0c7446d2d1d045d"}});tagsClient.Tag("new_tag",newList<User>(){newUser(){id="5911bd8bf0c7446d2d1d045d",email="example@example.com",user_id="25"}});tagsClient.Untag("new_tag",newList<Company>(){newCompany(){company_id="1000_company_id"}});tagsClient.Untag("new_tag",newList<Contact>(){newContact(){id="5911bd8bf0c7223d2d1d045d"}});tagsClient.Untag("new_tag",newList<User>(){newUser(){user_id="1000_user_id"}});SegmentsClientsegmentsClient=newSegmentsClient(newAuthentication("MyPersonalAccessToken"));Segmentsegment=segmentsClient.View("100300231");Segmentsegment=segmentsClient.View(newSegment(){id="100300231"});Segmentssegments=segmentsClient.List();NotesClientnotesClient=newNotesClient(newAuthentication("MyPersonalAccessToken"));Notenote=notesClient.Create(newNote(){author=newAuthor(){id="100300231_admin_id"},user=newUser(){email="example@example.com"},body="this is a new note"});Notenote=notesClient.Create(newUser(){email="example@example.com"},"this is a new note","100300231_admin_id");Notenote=notesClient.View("2001");Notesnotes=notesClient.List(newUser(){id="100300231"});foreach(Noteninnotes.notes)Console.WriteLine(n.user.name);EventsClienteventsClient=newEventsClient(newAuthentication("MyPersonalAccessToken"));Eventev=eventsClient.Create(newEvent(){user_id="1000_user_id",email="user_email@example.com",event_name="new_event",created_at=1462110718});Metadatametadata=newMetadata();metadata.Add("simple",100);metadata.Add("simple_1","two");metadata.Add("money",newMetadata.MonetaryAmount(100,"eur"));metadata.Add("richlink",newMetadata.RichLink("www.example.com","value1"));Eventev=eventsClient.Create(newEvent(){user_id="1000_user_id",email="user_email@example.com",event_name="new_event",created_at=1462110718,metadata=metadata});Eventsevents=eventsClient.List(newUser(){user_id="my_id"});CountsClientcountsClient=newCountsClient(newAuthentication("MyPersonalAccessToken"));AppCountappCount=countsClient.GetAppCount();ConversationAppCountconversationAppCount=countsClient.GetConversationAppCount();ConversationAdminCountconversationAdminCount=countsClient.GetConversationAdminCount();CompanySegmentCountcompanySegmentCount=countsClient.GetCompanySegmentCount();CompanyTagCountcompanyTagCount=countsClient.GetCompanyTagCount();CompanyUserCountcompanyUserCount=countsClient.GetCompanyUserCount();UserSegmentCountuserSegmentCount=countsClient.GetUserSegmentCount();UserTagCountuserTagCount=countsClient.GetUserTagCount();ConversationsClientconversationsClient=newConversationsClient(newAuthentication("MyPersonalAccessToken"));conversationsClient.View("100300231");conversationsClient.View("100300231",displayAsPlainText:true);conversationsClient.ListAll();Dictionary<String,String>parameters=newDictionary<string,string>();parameters.Add("order","asc");conversationsClient.ListAll(parameters);AdminConversationsClientadminConversationsClient=newAdminConversationsClient(newAuthentication("MyPersonalAccessToken"));AdminConversationMessageadmin_message=adminConversationsClient.Create(newAdminConversationMessage(from:newAdminConversationMessage.From("1000_admin_id"),to:newAdminConversationMessage.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"));Conversationconversation=adminConversationsClient.Reply(newAdminConversationReply(conversationId:"1000_conversation_id",adminId:"1000_admin_id",messageType:AdminConversationReply.ReplyMessageType.COMMENT,body:"this is a reply body"));Conversationreply=adminConversationsClient.ReplyLastConversation(newAdminLastConversationReply(){admin_id="12434",message_type="comment",body="replying to last conversation",intercom_user_id="5911bd8bf0c7446d2d1d045d"});UserConversationsClientuserConversationsClient=newUserConversationsClient(newAuthentication("MyPersonalAccessToken"));UserConversationMessageuser_message=userConversationsClient.Create(newUserConversationMessage(from:newUserConversationMessage.From(id:"1000_user_id"),body:"this is a user's message body"));Conversationconversation=userConversationsClient.Reply(newUserConversationReply(conversationId:"1000_conversation_id",body:"this is a user's reply body",attachementUrls:newList<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.
