Conversation
There was a problem hiding this comment.
Pull request overview
This pull request migrates the Intercom Go SDK from an older API version to v2.15, implementing significant architectural changes to align with Intercom's latest API structure. The migration unifies the previously separate User and Lead models into a single Contact model, adds support for Articles and Collections in the Help Center, modernizes authentication from AppID/APIKey to Access Token (Bearer), and updates all documentation and examples accordingly.
Changes:
- Unified Users and Leads into a single Contact model with a
rolefield, removing all User/Lead-specific code and updating all references throughout the codebase - Added complete support for Articles and Collections, including new service layers, repositories, API clients, tests, and example command-line tool
- Modernized authentication to use Access Token (Bearer) instead of AppID/APIKey, updated HTTP client to include Intercom-Version header, and updated all documentation
Reviewed changes
Copilot reviewed 57 out of 59 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| go.mod | Adds Go module definition with dependencies |
| go.sum | Adds dependency checksums |
| intercom.go | Updates client initialization to use AccessToken, adds Article and Collection services, removes User service |
| interfaces/http_client.go | Updates authentication to Bearer tokens, adds Intercom-Version header, removes AppID/APIKey fields |
| contact.go, contact_api.go, contact_test.go, contact_api_test.go | Updates Contact model with new API v2.15 fields, removes User-to-Contact conversion, adds merge/archive/unarchive operations |
| user.go, user_api.go, user_test.go, user_api_test.go | Deleted - User model replaced by Contact |
| article.go, article_api.go, article_test.go, article_api_test.go | New - Adds Article support with list and find operations |
| collection.go, collection_api.go, collection_test.go, collection_api_test.go | New - Adds Collection support with hierarchical structure via ParentID |
| cmd/articles/main.go | New - Example tool to export articles and collections to JSON |
| conversation.go | Updates to use Contacts instead of User, adds new fields (Title, AdminAssigneeID, etc.) |
| message.go | Updates to remove UserID from MessageAddress, renames NewUserMessage to NewContactMessage |
| notification.go | Updates to handle contact-related webhook topics instead of user topics |
| company.go, company_api.go | Updates Company model with new fields (Size, Website, Industry), renames ListUsers to ListContacts |
| request_company_mapper.go | New - Replaces requestUserMapper.go with ContactCompany type and helpers |
| requestUserMapper.go | Deleted - Replaced by request_company_mapper.go |
| page.go | Adds CursorPages and StartingAfterParam for cursor-based pagination |
| reply.go | Removes UserID field |
| admin.go, admin_test.go | Adds Avatar and TeamPriorityLevel fields, fixes test to check Email properly |
| segment_api_test.go | Updates test error handling to use t.Fatal instead of t.Fatalf(err.Error()) |
| job_api.go, job_item.go, job_test.go, job_api_test.go | Updates Job API to work with Contacts, renames NewUserJobItem to NewContactJobItem |
| tagging.go | Keeps UserID field for tagging (API still uses this for backwards compatibility) |
| event.go | Keeps UserID field (events still use user_id in API) |
| doc.go | Updates documentation to reflect Contact model and AccessToken authentication |
| README.md | Comprehensive rewrite with updated examples, API v2.15 changes, and current SDK usage patterns |
| fixtures/*.json | Updates all fixtures to match API v2.15 response format |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| parentID := strconv.FormatInt(a.ParentID, 10) | ||
| articlesByParent[parentID] = append(articlesByParent[parentID], ea) | ||
| } | ||
|
|
||
| // Build the tree | ||
| tree := make([]ExportCollection, 0, len(topLevel)) | ||
| for _, c := range topLevel { | ||
| ec := ExportCollection{ | ||
| ID: c.ID, | ||
| Name: c.Name, | ||
| Description: c.Description, | ||
| URL: c.URL, | ||
| Articles: articlesByParent[c.ID], |
There was a problem hiding this comment.
The code converts Article.ParentID (int64) to string and uses it as a key in articlesByParent (line 71), then later uses Collection.ID (string) to look up articles (line 83). However, the Article fixture shows parent_id as an integer (100) while the Collection fixture shows id as a string ("1"). This type mismatch means the lookup at line 83 articlesByParent[c.ID] may not find articles correctly unless the Collection.ID strings match the string representation of Article.ParentID integers in the actual API data.
|
|
||
| ```go | ||
| msg := intercom.NewEmailMessage(intercom.PERSONAL_TEMPLATE, intercom.Admin{ID: "1234"}, intercom.User{Email: "test@example.com"}, "subject", "body") | ||
| msg := intercom.NewEmailMessage(intercom.PERSONAL_TEMPLATE, &intercom.Admin{ID: "1234"}, &intercom.Contact{Email: "test@example.com"}, "subject", "body") |
There was a problem hiding this comment.
The Admin struct has ID field of type json.Number, but the README example shows constructing an Admin with a string literal: &intercom.Admin{ID: "1234"}. This would cause a compilation error. The example should use json.Number("1234") instead, or demonstrate using the Admin returned from the API.
|
|
||
| ```go | ||
| msg := intercom.NewInAppMessage(intercom.Admin{ID: "1234"}, intercom.Contact{Email: "test@example.com"}, "body") | ||
| msg := intercom.NewInAppMessage(&intercom.Admin{ID: "1234"}, &intercom.Contact{Email: "test@example.com"}, "body") |
There was a problem hiding this comment.
The Admin struct has ID field of type json.Number, but the README example shows constructing an Admin with a string literal: &intercom.Admin{ID: "1234"}. This would cause a compilation error. The example should use json.Number("1234") instead, or demonstrate using the Admin returned from the API.
This pull request updates the Intercom Go client to support the latest API changes, with a particular focus on unifying Users and Leads into a single Contact model, modernizing documentation, and adding support for Articles and Collections. The README has been extensively rewritten to reflect these changes, and new code has been introduced to support Articles in the SDK.
Major updates include:
Contact Model & API Alignment
Contactmodel throughout the README and usage examples, reflecting Intercom API v2.15 changes. All user-related operations are now demonstrated usingContactmethods, and references to Users/Leads have been removed or updated.Article & Collection Support
ArticleService,Article, andArticleRepositorytypes for managing Help Center articles, including list and find operations. [1] [2]Documentation Modernization
github.com/karnott/intercom-go) and removed references to deprecated Docker images and old import paths.Admin Model Improvements
AvatarandTeamPriorityLevelfields to theAdminstruct for richer admin representation.Miscellaneous Fixes
admin_test.goto properly check for email presence in admin addresses.These changes bring the SDK up to date with Intercom's latest API structure and improve both usability and maintainability for future development.