Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

164 Commits

Repository files navigation

intercom-dotnet

Circle CInugetIntercom API Version

.NET bindings for the Intercom API

Project Updates

Maintenance

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.

Add a dependency

nuget

Run the nuget command for installing the client as Install-Package Intercom.Dotnet.Client

Resources

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.

Authorization

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.

Usage

For all client types

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);

Users

Create UsersClient instance

UsersClientusersClient=newUsersClient(newAuthentication("MyPersonalAccessToken"));

Create user

Useruser=usersClient.Create(newUser(){user_id="my_id",name="first last"});

View a user (by id, user_id or email)

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"});

Update a user with a company

Useruser=usersClient.Update(newUser(){email="example@example.com",companies=newList<Company>(){newCompany(){company_id="new_company"}}});

Update user's custom attributes

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);

List users and iterating through them

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);

List users by Tag, Segment, Company

Dictionary<String,String>parameters=newDictionary<string,string>();parameters.Add("segment_id","57553e93a32843ca09000277");Usersusers=usersClient.List(parameters);

List users via the Scroll API

Usersusers=usersClient.Scroll();Stringscroll_param_value=users.scroll_param;Usersusers=usersClient.Scroll(scroll_param_value);

Delete a user

usersClient.Archive("100300231");// with intercom generated user's idusersClient.Archive(newUser(){email="example@example.com"});usersClient.Archive(newUser(){user_id="my_id"});

Permanently delete a user

usersClient.PermanentlyDeleteUser("100300231");// with intercom generated user's id

Update User's LastSeenAt (multiple ways)

Useruser=usersClient.UpdateLastSeenAt("100300231");Useruser=usersClient.UpdateLastSeenAt(newUser(){id="100300231"});Useruser=usersClient.UpdateLastSeenAt("100300231",1462110718);Useruser=usersClient.UpdateLastSeenAt(newUser(){id="100300231"},1462110718);

Increment User's Session

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" attribute

Removing User's companies

Useruser=usersClient.RemoveCompanyFromUser("100300231",newList<String>(){"true_company"});

Contacts

Create ContactsClient instance

ContactsClientcontactsClient=newContactsClient(newAuthentication("MyPersonalAccessToken"));

Create a contact

Contactcontact=contactsClient.Create(newContact(){});Contactcontact=contactsClient.Create(newContact(){name="lead_name"});

View a contact (by id, or user_id)

Contactcontact=contactsClient.View("100300231");Contactcontact=contactsClient.View(newContact(){id="100300231"});Contactcontact=contactsClient.View(newContact(){user_id="my_lead_id"});

Update a contact (by id, or user_id)

Contactcontact=contactsClient.Update(newContact(){email="example@example",companies=newList<Company>(){newCompany(){company_id="new_company"}}});

List contacts and iterate through them

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);

List contacts by email

Contactscontacts=contactsClient.List("email@example.com");

List contacts via Scroll API

Contactscontacts=contactsClient.Scroll();Stringscroll_param_value=contacts.scroll_param;Contactscontacts=contactsClient.Scroll(scroll_param_value);

Convert a contact to a User

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"});

Delete a contact

contactsClient.Delete("100300231");contactsClient.Delete(newContact(){id="100300231"});contactsClient.Delete(newContact(){user_id="my_id"});

Visitors

Create VisitorsClient instance

VisitorsClientvisitorsClient=newVisitorsClient(newAuthentication("MyPersonalAccessToken"));

View a visitor

Visitorvisitor=VisitorsClient.View("573479f784c5acde6a000575");

View a visitor by user_id

Dictionary<String,String>parameters=newDictionary<string,string>();parameters.Add("user_id","16e690c0-485a-4e87-ae98-a326e788a4f7");Visitorvisitor=VisitorsClient.View(parameters);

Update a visitor

Visitorvisitor=VisitorsClient.Update(visitor);

Delete a visitor

Visitorvisitor=VisitorsClient.Delete(visitor);

Convert to existing user

Visitorvisitor=VisitorsClient.ConvertToUser(visitor,user);

Convert to new user

Visitorvisitor=VisitorsClient.ConvertToUser(visitor,newUser(){user_id="25"});

Convert to contact

Visitorvisitor=VisitorsClient.ConvertToContact(visitor);

Companies

Create CompanyClient instance

CompanyClientcompanyClient=newCompanyClient(newAuthentication("MyPersonalAccessToken"));

Create a company

Companycompany=companyClient.Create(newCompany());Companycompany=companyClient.Create(newCompany(){name="company_name"});

View a company

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"});

Update a company

Companycompany=companyClient.Update(newCompany(){company_id="example@example",monthly_spend=100});

List companies

Limited to up to 10k records, if you want to list more records please use the Scroll API

Companiescompanies=companyClient.List();

List companies via Scroll API

Companiescompanies=companyClient.Scroll();StringscrollParam=companies.scroll_param;Companiescompanies=companyClient.Scroll(scrollParam);foreach(Companycincompanies.companies)Console.WriteLine(c.name);

List a Company's registered users

Usersusers=companyClient.ListUsers(newCompany(){id="100300231"});Usersusers=companyClient.ListUsers(newCompany(){company_id="my_company_id"});

Admins

Create AdminsClient instance

AdminsClientadminsClient=newAdminsClient(newAuthentication("MyPersonalAccessToken"));

View an admin

Adminadmin=adminsClient.View("100300231");Adminadmin=adminsClient.View(newAdmin(){id="100300231"});

List admins

Adminsadmins=adminsClient.List();

Tags

Create TagsClient instance

TagsClienttagsClient=newTagsClient(newAuthentication("MyPersonalAccessToken"));

Create a tag

Tagtag=tagsClient.Create(newTag(){name="new_tag"});

List tags

Tagstags=tagsClient.List();

Delete a tag

tagsClient.Delete(newTag(){id="100300231"});

Tag User, Company or Contact

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"}});

Untag User, Company or Contact

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"}});

Segments

Create SegmentsClient instance

SegmentsClientsegmentsClient=newSegmentsClient(newAuthentication("MyPersonalAccessToken"));

View a segment (by id)

Segmentsegment=segmentsClient.View("100300231");Segmentsegment=segmentsClient.View(newSegment(){id="100300231"});

List segments

Segmentssegments=segmentsClient.List();

Notes

Create NotesClient instance

NotesClientnotesClient=newNotesClient(newAuthentication("MyPersonalAccessToken"));

Create a note (by User, body and admin_id)

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");

View a note

Notenote=notesClient.View("2001");

List User's notes

Notesnotes=notesClient.List(newUser(){id="100300231"});foreach(Noteninnotes.notes)Console.WriteLine(n.user.name);

Events

Create EventsClient instance

EventsClienteventsClient=newEventsClient(newAuthentication("MyPersonalAccessToken"));

Create an event

Eventev=eventsClient.Create(newEvent(){user_id="1000_user_id",email="user_email@example.com",event_name="new_event",created_at=1462110718});

Create an event with Metadata (Simple, MonetaryAmounts and RichLinks)

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});

List events by user

Eventsevents=eventsClient.List(newUser(){user_id="my_id"});

Counts

Create CountsClient instance

CountsClientcountsClient=newCountsClient(newAuthentication("MyPersonalAccessToken"));

Get AppCount

AppCountappCount=countsClient.GetAppCount();

Get Specific Counts

ConversationAppCountconversationAppCount=countsClient.GetConversationAppCount();ConversationAdminCountconversationAdminCount=countsClient.GetConversationAdminCount();CompanySegmentCountcompanySegmentCount=countsClient.GetCompanySegmentCount();CompanyTagCountcompanyTagCount=countsClient.GetCompanyTagCount();CompanyUserCountcompanyUserCount=countsClient.GetCompanyUserCount();UserSegmentCountuserSegmentCount=countsClient.GetUserSegmentCount();UserTagCountuserTagCount=countsClient.GetUserTagCount();

Conversations

Create ConversationsClient instance

ConversationsClientconversationsClient=newConversationsClient(newAuthentication("MyPersonalAccessToken"));

View any type of conversation

conversationsClient.View("100300231");conversationsClient.View("100300231",displayAsPlainText:true);

List all conversations

conversationsClient.ListAll();Dictionary<String,String>parameters=newDictionary<string,string>();parameters.Add("order","asc");conversationsClient.ListAll(parameters);

Create AdminConversationsClient instance

AdminConversationsClientadminConversationsClient=newAdminConversationsClient(newAuthentication("MyPersonalAccessToken"));

Create Admin initiated Conversation

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"));

Create Admin initiated Conversation's reply

Conversationconversation=adminConversationsClient.Reply(newAdminConversationReply(conversationId:"1000_conversation_id",adminId:"1000_admin_id",messageType:AdminConversationReply.ReplyMessageType.COMMENT,body:"this is a reply body"));

Reply to user's last conversation

Conversationreply=adminConversationsClient.ReplyLastConversation(newAdminLastConversationReply(){admin_id="12434",message_type="comment",body="replying to last conversation",intercom_user_id="5911bd8bf0c7446d2d1d045d"});

Create UserConversationsClient instance

UserConversationsClientuserConversationsClient=newUserConversationsClient(newAuthentication("MyPersonalAccessToken"));

Create User initiated Conversation

UserConversationMessageuser_message=userConversationsClient.Create(newUserConversationMessage(from:newUserConversationMessage.From(id:"1000_user_id"),body:"this is a user's message body"));

Create User initiated Conversation's reply

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"}));

Webhooks & Pagination

Not yet supported by these bindings.

Todo

  • Increase test coverage
  • Support Pagination
  • Support Webhooks
  • Support Async
  • Have 100% feature parity with curl

Pull Requests

  • 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.

About

Intercom API client library for .NET

Resources

Stars

63 stars

Watchers

125 watching

Forks

Releases

Packages

Used by

Contributors

Languages