{"id":26091666,"url":"https://github.com/intercom/intercom-dotnet","last_synced_at":"2025-04-06T14:10:25.269Z","repository":{"id":8359089,"uuid":"57774192","full_name":"intercom/intercom-dotnet","owner":"intercom","description":"Intercom API client library for .NET","archived":false,"fork":false,"pushed_at":"2023-07-07T13:29:29.000Z","size":292,"stargazers_count":63,"open_issues_count":36,"forks_count":54,"subscribers_count":119,"default_branch":"master","last_synced_at":"2024-05-28T11:52:21.832Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://developers.intercom.io/reference","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/intercom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-01T19:41:04.000Z","updated_at":"2024-06-18T18:20:52.230Z","dependencies_parsed_at":"2024-06-18T18:20:51.064Z","dependency_job_id":"d87efc89-12d7-4573-bfb2-d1301c16df36","html_url":"https://github.com/intercom/intercom-dotnet","commit_stats":{"total_commits":105,"total_committers":31,"mean_commits":"3.3870967741935485","dds":0.5428571428571429,"last_synced_commit":"67a44328eed7bb421c33d308084fd642e391836e"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intercom%2Fintercom-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intercom%2Fintercom-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intercom%2Fintercom-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intercom%2Fintercom-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/intercom","download_url":"https://codeload.github.com/intercom/intercom-dotnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247492513,"owners_count":20947544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-09T10:22:49.837Z","updated_at":"2025-04-06T14:10:25.242Z","avatar_url":"https://github.com/intercom.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# intercom-dotnet\n\n[![Circle CI](https://circleci.com/gh/intercom/intercom-dotnet.png?style=shield)](https://circleci.com/gh/intercom/intercom-dotnet)\n[![nuget](https://img.shields.io/nuget/v/Intercom.Dotnet.Client)](https://www.nuget.org/packages/Intercom.Dotnet.Client)\n![Intercom API Version](https://img.shields.io/badge/Intercom%20API%20Version-1.3-blue)\n\n\u003e .NET bindings for the [Intercom API](https://developers.intercom.io/reference)\n\n## Project Updates\n\n### Maintenance\n\nWe're currently building a new team to provide in-depth and dedicated SDK support.\n\nIn 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.\n\nWe'll communicate all relevant updates as we build this new team and support strategy in the coming months.\n\n- [Installation](#add-a-dependency)\n- [Resources](#resources)\n- [Authorization](#authorization)\n- [Usage](#usage)\n- [Todo](#todo)\n- [Pull Requests](#pull-requests)\n\n## Add a dependency\n\n### nuget\n\nRun the nuget command for installing the client as `Install-Package Intercom.Dotnet.Client`\n\n## Resources\n\nResources this API supports:\n\n- [Users](#users)\n- [Contacts](#contacts)\n- [Companies](#companies)\n- [Admins](#admins)\n- [Events](#events)\n- [Tags](#tags)\n- [Segments](#segments)\n- [Notes](#notes)\n- [Conversations](#conversations)\n- [Counts](#counts)\n\nEach of these resources is represented through the dotnet client by a Class as `ResourceClient`.\n\n**E.g.**: for **users**, you can use the `UsersClient`. For **segments**, you can use `SegmentsClient`.\n\n## Authorization\n\n\u003e If you already have an access token you can find it [here](https://app.intercom.com/developers/_). If you want to create or learn more about access tokens then you can find more info [here](https://developers.intercom.io/docs/personal-access-tokens).\n\nYou can set the `Personal Access Token` via creating an `Authentication` object by invoking the single paramter constructor:\n\n```cs\nUsersClient usersClient = new UsersClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\nIf you are building a third party application you will need to implement OAuth by following the steps for [setting-up-oauth](https://developers.intercom.io/page/setting-up-oauth) for Intercom.\n\n## Usage\n\n### For all client types\n\nIt 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.\n\n```cs\nAuthentication auth = new Authentication(\"MyPersonalAccessToken\");\nRestClientFactory factory = new RestClientFactory(auth);\nUsersClient usersClient = new UsersClient(factory);\n```\n\n### Users\n\n#### Create UsersClient instance\n\n```cs\nUsersClient usersClient = new UsersClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\n#### Create user\n\n```cs\nUser user = usersClient.Create(new User() { user_id = \"my_id\", name = \"first last\" });\n```\n\n#### View a user (by id, user_id or email)\n\n```cs\nUser user = usersClient.View(\"100300231\");\nUser user = usersClient.View(new User() { email = \"example@example.com\" });\nUser user = usersClient.View(new User() { id = \"100300231\" });\nUser user = usersClient.View(new User() { user_id = \"my_id\" });\n```\n\n#### Update a user with a company\n\n```cs\nUser user = usersClient.Update(new User() {\n                               email = \"example@example.com\",\n                               companies = new List\u003cCompany\u003e() {\n                                           new Company() { company_id = \"new_company\" } } });\n```\n\n#### Update user's custom attributes\n\n```cs\nDictionary\u003cstring, object\u003e customAttributes = new Dictionary\u003cstring, object\u003e();\ncustomAttributes.Add(\"total\", \"100.00\");\ncustomAttributes.Add(\"account_level\", \"1\");\n\nUser user = usersClient.View(\"100300231\");\nuser.custom_attributes = customAttributes;\n\nuser = usersClient.Update(user);\n```\n\n#### List users and iterating through them\n\nLimited to up to 10k records, if you want to list more records please use the Scroll API\n\n```cs\nUsers users = usersClient.List();\n\nforeach(User u in users.users)\n    Console.WriteLine(u.email);\n```\n\n#### List users by Tag, Segment, Company\n\n```cs\nDictionary\u003cString, String\u003e parameters = new Dictionary\u003cstring, string\u003e();\nparameters.Add(\"segment_id\", \"57553e93a32843ca09000277\");\nUsers users = usersClient.List(parameters);\n```\n\n#### List users via the Scroll API\n\n```cs\nUsers users = usersClient.Scroll();\nString scroll_param_value = users.scroll_param;\nUsers users = usersClient.Scroll(scroll_param_value);\n```\n\n#### Delete a user\n\n```cs\nusersClient.Archive(\"100300231\"); // with intercom generated user's id\nusersClient.Archive(new User() { email = \"example@example.com\" });\nusersClient.Archive(new User() { user_id = \"my_id\" });\n```\n\n#### Permanently delete a user\n\n```cs\nusersClient.PermanentlyDeleteUser(\"100300231\"); // with intercom generated user's id\n```\n\n#### Update User's LastSeenAt (multiple ways)\n\n```cs\nUser user = usersClient.UpdateLastSeenAt(\"100300231\");\nUser user = usersClient.UpdateLastSeenAt(new User() { id = \"100300231\" });\nUser user = usersClient.UpdateLastSeenAt(\"100300231\", 1462110718);\nUser user = usersClient.UpdateLastSeenAt(new User() { id = \"100300231\" }, 1462110718);\n```\n\n#### Increment User's Session\n\n```cs\nusersClient.IncrementUserSession(new User() { id = \"100300231\" });\nusersClient.IncrementUserSession(\"100300231\", new List\u003cString\u003e() { \"company_is_blue\" }});\n\n// You can also update a User's session by updating a User record with a \"new_session = true\" attribute\n```\n\n#### Removing User's companies\n\n```cs\nUser user = usersClient.RemoveCompanyFromUser(\"100300231\", new List\u003cString\u003e() { \"true_company\" });\n```\n\n***\n\n### Contacts\n\n#### Create ContactsClient instance\n\n```cs\nContactsClient contactsClient = new ContactsClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\n#### Create a contact\n\n```cs\nContact contact = contactsClient.Create(new Contact() { });\nContact contact = contactsClient.Create(new Contact() { name = \"lead_name\" });\n```\n\n#### View a contact (by id, or user_id)\n\n```cs\nContact contact = contactsClient.View(\"100300231\");\nContact contact = contactsClient.View(new Contact() { id = \"100300231\" });\nContact contact = contactsClient.View(new Contact() { user_id = \"my_lead_id\" });\n```\n\n#### Update a contact (by id, or user_id)\n\n```cs\nContact contact = contactsClient.Update(\n                    new Contact()\n                    {   \n                        email = \"example@example\",\n                        companies = new List\u003cCompany\u003e() { new Company() { company_id = \"new_company\" } }\n                    });\n```\n\n#### List contacts and iterate through them\n\nLimited to up to 10k records, if you want to list more records please use the Scroll API\n\n```cs\nContacts contacts = contactsClient.List();\n\nforeach (Contact c in contacts.contacts)\n    Console.WriteLine(c.email);\n```\n\n#### List contacts by email\n\n```cs\nContacts contacts = contactsClient.List(\"email@example.com\");\n```\n\n#### List contacts via Scroll API\n\n```cs\nContacts contacts = contactsClient.Scroll();\nString scroll_param_value = contacts.scroll_param;\nContacts contacts = contactsClient.Scroll(scroll_param_value);\n```\n\n#### Convert a contact to a User\n\nNote that if the user does not exist they will be created, otherwise they will be merged.\n\n```cs\nUser user = contactsClient.Convert(contact, new User() { user_id = \"120\" });\n```\n\n#### Delete a contact\n\n```cs\ncontactsClient.Delete(\"100300231\");\ncontactsClient.Delete(new Contact() { id = \"100300231\" });\ncontactsClient.Delete(new Contact() { user_id = \"my_id\" });\n```\n\n***\n\n### Visitors\n\n#### Create VisitorsClient instance\n\n```cs\nVisitorsClient visitorsClient = new VisitorsClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\n#### View a visitor\n\n```cs\nVisitor visitor = VisitorsClient.View(\"573479f784c5acde6a000575\");\n```\n\n#### View a visitor by user_id\n\n```cs\nDictionary\u003cString, String\u003e parameters = new Dictionary\u003cstring, string\u003e();\nparameters.Add(\"user_id\", \"16e690c0-485a-4e87-ae98-a326e788a4f7\");\nVisitor visitor = VisitorsClient.View(parameters);\n```\n\n#### Update a visitor\n\n```cs\nVisitor visitor = VisitorsClient.Update(visitor);\n```\n\n#### Delete a visitor\n\n```cs\nVisitor visitor = VisitorsClient.Delete(visitor);\n```\n\n#### Convert to existing user\n\n```cs\nVisitor visitor = VisitorsClient.ConvertToUser(visitor, user);\n```\n\n#### Convert to new user\n\n```cs\nVisitor visitor = VisitorsClient.ConvertToUser(visitor, new User(){ user_id = \"25\" });\n```\n\n#### Convert to contact\n\n```cs\nVisitor visitor = VisitorsClient.ConvertToContact(visitor);\n```\n\n***\n\n### Companies\n\n#### Create CompanyClient instance\n\n```cs\nCompanyClient companyClient = new CompanyClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\n#### Create a company\n\n```cs\nCompany company = companyClient.Create(new Company());\nCompany company = companyClient.Create(new Company() { name = \"company_name\" });\n```\n\n#### View a company\n\n```cs\nCompany company = companyClient.View(\"100300231\");\nCompany company = companyClient.View(new Company() { id = \"100300231\" });\nCompany company = companyClient.View(new Company() { company_id = \"my_company_id\" });\nCompany company = companyClient.View(new Company() { name = \"my_company_name\" });\n```\n\n#### Update a company\n\n```cs\nCompany company = companyClient.Update(\n                    new Company()\n                    {   \n                        company_id = \"example@example\",\n                        monthly_spend = 100\n                    });\n```\n\n#### List companies\n\nLimited to up to 10k records, if you want to list more records please use the Scroll API\n\n```cs\nCompanies companies = companyClient.List();\n```\n\n#### List companies via Scroll API\n\n```cs\nCompanies companies = companyClient.Scroll();\nString scrollParam = companies.scroll_param;\nCompanies companies = companyClient.Scroll(scrollParam);\n\nforeach (Company c in companies.companies)\n    Console.WriteLine(c.name);\n```\n\n#### List a Company's registered users\n\n```cs\nUsers users = companyClient.ListUsers(new Company() { id = \"100300231\" });\nUsers users = companyClient.ListUsers(new Company() { company_id = \"my_company_id\" });\n```\n\n***\n\n### Admins\n\n#### Create AdminsClient instance\n\n```cs\nAdminsClient adminsClient = new AdminsClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\n#### View an admin\n\n```cs\nAdmin admin = adminsClient.View(\"100300231\");\nAdmin admin = adminsClient.View(new Admin() { id = \"100300231\" });\n```\n\n#### List admins\n\n```cs\nAdmins admins = adminsClient.List();\n```\n\n***\n\n### Tags\n\n#### Create TagsClient instance\n\n```cs\nTagsClient tagsClient = new TagsClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\n#### Create a tag\n\n```cs\nTag tag = tagsClient.Create(new Tag() { name = \"new_tag\" });\n```\n\n#### List tags\n\n```cs\nTags tags = tagsClient.List();\n```\n\n#### Delete a tag\n\n```cs\ntagsClient.Delete(new Tag() { id = \"100300231\" });\n```\n\n#### Tag User, Company or Contact\n\n```cs\ntagsClient.Tag(\"new_tag\", new List\u003cCompany\u003e() { new Company(){ company_id = \"blue\" } });\ntagsClient.Tag(\"new_tag\", new List\u003cCompany\u003e() { new Company(){ id = \"5911bd8bf0c7223d2d1d045d\" } });\ntagsClient.Tag(\"new_tag\", new List\u003cContact\u003e() { new Contact(){ id = \"5911bd8bf0c7446d2d1d045d\" } });\ntagsClient.Tag(\"new_tag\", new List\u003cUser\u003e() { new User(){ id = \"5911bd8bf0c7446d2d1d045d\", email = \"example@example.com\", user_id = \"25\" } });\n```\n\n#### Untag User, Company or Contact\n\n```cs\ntagsClient.Untag(\"new_tag\", new List\u003cCompany\u003e() { new Company(){ company_id = \"1000_company_id\" } });\ntagsClient.Untag(\"new_tag\", new List\u003cContact\u003e() { new Contact(){ id = \"5911bd8bf0c7223d2d1d045d\" } });\ntagsClient.Untag(\"new_tag\", new List\u003cUser\u003e() { new User(){ user_id = \"1000_user_id\" } });\n```\n\n***\n\n### Segments\n\n#### Create SegmentsClient instance\n\n```cs\nSegmentsClient segmentsClient = new SegmentsClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\n#### View a segment (by id)\n\n```cs\nSegment segment = segmentsClient.View(\"100300231\");\nSegment segment = segmentsClient.View(new Segment() { id = \"100300231\" });\n```\n\n#### List segments\n\n```cs\nSegments segments = segmentsClient.List();\n```\n\n***\n\n### Notes\n\n#### Create NotesClient instance\n\n```cs\nNotesClient notesClient = new NotesClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\n#### Create a note (by User, body and admin_id)\n\n```cs\nNote note = notesClient.Create(\n    new Note() {\n    author = new Author() { id = \"100300231_admin_id\" },\n    user =  new User() { email = \"example@example.com\" },\n    body = \"this is a new note\"\n});\n\nNote note = notesClient.Create(new User() { email = \"example@example.com\" }, \"this is a new note\", \"100300231_admin_id\");\n```\n\n#### View a note\n\n```cs\nNote note = notesClient.View(\"2001\");\n```\n\n#### List User's notes\n\n```cs\nNotes notes = notesClient.List(new User() { id = \"100300231\"});\n\nforeach (Note n in notes.notes)\n    Console.WriteLine(n.user.name);\n```\n\n***\n\n### Events\n\n#### Create EventsClient instance\n\n```cs\nEventsClient eventsClient = new EventsClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\n#### Create an event\n\n```cs\nEvent ev = eventsClient.Create(new Event() { user_id = \"1000_user_id\", email = \"user_email@example.com\", event_name = \"new_event\", created_at = 1462110718  });\n```\n\n#### Create an event with Metadata (Simple, MonetaryAmounts and RichLinks)\n\n```cs\nMetadata metadata = new Metadata();\nmetadata.Add(\"simple\", 100);\nmetadata.Add(\"simple_1\", \"two\");\nmetadata.Add(\"money\", new Metadata.MonetaryAmount(100, \"eur\"));\nmetadata.Add(\"richlink\", new Metadata.RichLink(\"www.example.com\", \"value1\"));\n\nEvent ev = eventsClient.Create(new Event() { user_id = \"1000_user_id\", email = \"user_email@example.com\", event_name = \"new_event\", created_at = 1462110718, metadata = metadata  });\n```\n\n#### List events by user\n\n```cs\nEvents events = eventsClient.List(new User() { user_id = \"my_id\" });\n```\n\n***\n\n### Counts\n\n#### Create CountsClient instance\n\n```cs\nCountsClient countsClient = new CountsClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\n#### Get AppCount\n\n```cs\nAppCount appCount = countsClient.GetAppCount();\n```\n\n#### Get Specific Counts\n\n```cs\nConversationAppCount conversationAppCount = countsClient.GetConversationAppCount();\nConversationAdminCount conversationAdminCount = countsClient.GetConversationAdminCount();\nCompanySegmentCount companySegmentCount = countsClient.GetCompanySegmentCount();\nCompanyTagCount companyTagCount = countsClient.GetCompanyTagCount();\nCompanyUserCount companyUserCount = countsClient.GetCompanyUserCount();\nUserSegmentCount userSegmentCount = countsClient.GetUserSegmentCount();\nUserTagCount userTagCount = countsClient.GetUserTagCount();\n```\n\n***\n\n### Conversations\n\n#### Create ConversationsClient instance\n\n```cs\nConversationsClient conversationsClient = new ConversationsClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\n#### View any type of conversation\n\n```cs\nconversationsClient.View(\"100300231\");\nconversationsClient.View(\"100300231\", displayAsPlainText: true);\n```\n\n#### List all conversations\n\n```cs\nconversationsClient.ListAll();\n\nDictionary\u003cString, String\u003e parameters = new Dictionary\u003cstring, string\u003e();\nparameters.Add(\"order\", \"asc\");\nconversationsClient.ListAll(parameters);\n```\n\n#### Create AdminConversationsClient instance\n\n```cs\nAdminConversationsClient adminConversationsClient = new AdminConversationsClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\n#### Create Admin initiated Conversation\n\n```cs\nAdminConversationMessage admin_message =\n    adminConversationsClient.Create(new AdminConversationMessage(\n            from: new AdminConversationMessage.From(\"1000_admin_id\"),\n            to: new AdminConversationMessage.To(id: \"1000_user_id\"),\n            message_type: AdminConversationMessage.MessageType.EMAIL,\n            template: AdminConversationMessage.MessageTemplate.PERSONAL,\n            subject: \"this is a subject\",\n            body: \"this is an email body\"));\n```\n\n#### Create Admin initiated Conversation's reply\n\n```cs\nConversation conversation =\n    adminConversationsClient.Reply(\n        new AdminConversationReply(\n            conversationId: \"1000_conversation_id\",\n            adminId: \"1000_admin_id\",\n            messageType: AdminConversationReply.ReplyMessageType.COMMENT,\n            body: \"this is a reply body\"));\n```\n\n#### Reply to user's last conversation\n\n```cs\nConversation reply =\n    adminConversationsClient.ReplyLastConversation(\n        new AdminLastConversationReply()\n        {\n            admin_id = \"12434\",\n            message_type = \"comment\",\n            body = \"replying to last conversation\",\n            intercom_user_id = \"5911bd8bf0c7446d2d1d045d\"\n        });\n```\n\n#### Create UserConversationsClient instance\n\n```cs\nUserConversationsClient userConversationsClient = new UserConversationsClient(new Authentication(\"MyPersonalAccessToken\"));\n```\n\n#### Create User initiated Conversation\n\n```cs\nUserConversationMessage user_message =\n    userConversationsClient.Create(\n        new UserConversationMessage(\n            from: new UserConversationMessage.From(id: \"1000_user_id\"),\n            body: \"this is a user's message body\"));\n```\n\n#### Create User initiated Conversation's reply\n\n```cs\nConversation conversation =\n    userConversationsClient.Reply(\n        new UserConversationReply(\n            conversationId: \"1000_conversation_id\",\n            body: \"this is a user's reply body\",\n            attachementUrls: new List\u003cString\u003e() { \"www.example.com/example.png\", \"www.example.com/example.txt\" }));\n```\n\n***\n\n### Webhooks \u0026 Pagination\n\nNot yet supported by these bindings.\n\n## Todo\n\n- [ ] Increase test coverage\n- [ ] Support Pagination\n- [ ] Support Webhooks\n- [ ] Support Async\n- [ ] Have 100% feature parity with curl\n\n## Pull Requests\n\n- **Add tests!** Your patch won't be accepted if it doesn't have tests.\n- **Document any change in behaviour.** Make sure the README and any other relevant documentation are kept up-to-date.\n- **Create topic branches.** Don't ask us to pull from your master branch.\n- **One pull request per feature.** If you want to do more than one thing, send multiple pull requests.\n- **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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintercom%2Fintercom-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintercom%2Fintercom-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintercom%2Fintercom-dotnet/lists"}