### Install and configure laravel-intercom Source: https://github.com/jeffersongoncalves/laravel-intercom/blob/main/README.md Install the package via Composer, publish its config file, and set the Intercom API key in the .env file. The access token is found under Settings > Developers in the Intercom workspace. ```bash composer require jeffersongoncalves/laravel-intercom ``` ```bash php artisan vendor:publish --tag=intercom-config ``` ```env INTERCOM_API_KEY=your-access-token ``` -------------------------------- ### Manage admins and events with Intercom facade Source: https://github.com/jeffersongoncalves/laravel-intercom/blob/main/README.md Lists and gets admins, and creates and lists events for a user. The events create method takes an event name, user ID, and optional metadata. ```php Intercom::admins()->list(); Intercom::admins()->get($adminId); Intercom::events()->create('invited-friend', $userId, metadata: ['invitee' => 'jane@example.com']); Intercom::events()->list($userId); ``` -------------------------------- ### Manage conversations with Intercom facade Source: https://github.com/jeffersongoncalves/laravel-intercom/blob/main/README.md Demonstrates listing, getting, searching, replying to, and closing conversations. The reply method takes the conversation ID, message body, and admin ID; close takes the conversation ID, admin ID, and a resolution note. ```php $conversations = Intercom::conversations()->list(); $conversation = Intercom::conversations()->get(1); Intercom::conversations()->search('state', 'open'); Intercom::conversations()->reply($conversation['id'], 'Thanks for reaching out!', $adminId); Intercom::conversations()->close($conversation['id'], $adminId, 'Resolved.'); ``` -------------------------------- ### Manage contacts with Intercom facade Source: https://github.com/jeffersongoncalves/laravel-intercom/blob/main/README.md Shows how to use the Intercom facade to manage contacts: list with cursor-based pagination, get by ID, create, update, search, tag/untag, and delete. The create method requires an email field. ```php use JeffersonGoncalves\Intercom\Facades\Intercom; // List (cursor-based pagination via per_page / starting_after) $contacts = Intercom::contacts()->list(['starting_after' => $cursor]); $contact = Intercom::contacts()->get('507f191e810c19729de860ea'); $contact = Intercom::contacts()->create([ 'email' => 'jane@example.com', 'name' => 'Jane Doe', ]); Intercom::contacts()->update($contact['id'], ['name' => 'Jane D.']); Intercom::contacts()->search('email', 'jane@example.com'); Intercom::contacts()->tag($contact['id'], $tagId); Intercom::contacts()->untag($contact['id'], $tagId); Intercom::contacts()->delete($contact['id']); ``` -------------------------------- ### Manage companies with Intercom facade Source: https://github.com/jeffersongoncalves/laravel-intercom/blob/main/README.md Lists companies, creates a company with an ID and attributes, and updates a company by ID. The create method takes a company ID and an array of attributes. ```php $companies = Intercom::companies()->list(); $company = Intercom::companies()->create('company-42', ['name' => 'Acme Inc']); Intercom::companies()->update($company['id'], ['name' => 'Acme Inc.']); ``` -------------------------------- ### Configure config/intercom.php Source: https://github.com/jeffersongoncalves/laravel-intercom/blob/main/README.md Configuration file for the package. The api_key is read from the INTERCOM_API_KEY environment variable, api_version defaults to '2.11', and default_per_page defaults to 15. ```php // config/intercom.php return [ 'api_key' => env('INTERCOM_API_KEY', ''), 'api_version' => env('INTERCOM_API_VERSION', '2.11'), 'default_per_page' => env('INTERCOM_DEFAULT_PER_PAGE', 15), ]; ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-intercom/blob/main/README.md Runs the test suite for the project. ```bash composer test ``` -------------------------------- ### Manage articles with Intercom facade Source: https://github.com/jeffersongoncalves/laravel-intercom/blob/main/README.md Lists articles, creates an article with title, authorId, state, and body, updates an article by ID, and deletes an article by ID. ```php $articles = Intercom::articles()->list(); $article = Intercom::articles()->create( title: 'How to reset your password', authorId: $adminId, state: 'published', body: '
Steps to reset your password...
', ); Intercom::articles()->update($article['id'], ['title' => 'How to reset your password (updated)']); Intercom::articles()->delete($article['id']); ``` -------------------------------- ### Create a message with Intercom facade Source: https://github.com/jeffersongoncalves/laravel-intercom/blob/main/README.md Creates a message from an admin to a user. The body, adminId, and to parameters are required. ```php Intercom::messages()->create( body: 'Welcome aboard!', adminId: $adminId, to: $userId, ); ``` -------------------------------- ### Manage tags with Intercom facade Source: https://github.com/jeffersongoncalves/laravel-intercom/blob/main/README.md Lists tags, creates a tag with a name, and deletes a tag by ID. ```php $tags = Intercom::tags()->list(); $tag = Intercom::tags()->create('vip'); Intercom::tags()->delete($tag['id']); ``` -------------------------------- ### Handle IntercomException errors Source: https://github.com/jeffersongoncalves/laravel-intercom/blob/main/README.md Catches IntercomException thrown on any non-2xx API response. The exception exposes the decoded error body via errorBody(). Missing required fields throw InvalidArgumentException before any HTTP call. ```php use JeffersonGoncalves\Intercom\Exceptions\IntercomException; try { Intercom::contacts()->get('unknown-id'); } catch (IntercomException $e) { logger()->error($e->getMessage(), $e->errorBody()); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.