Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel There There Laravel Package

spatie/laravel-there-there

Expose your Laravel app data as JSON for There There. Configure a secret and endpoint, validate incoming requests, and register a sidebar callback to return relevant customer info when agents open a ticket, shown in There There’s sidebar.

View on GitHub
Deep Wiki
Context7

Expose application data as JSON for There There

Latest Version on Packagist GitHub Tests Action Status Total Downloads

This package makes it easy to expose application data to There There. When a customer opens a ticket in There There, it will call your application to fetch relevant data and display it in the sidebar.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require spatie/laravel-there-there

You can publish the config file with:

php artisan vendor:publish --tag="there-there-config"

This is the contents of the published config file:

return [
    'secret' => env('THERE_THERE_SECRET'),
    'url' => '/there-there',
    'middleware' => [
        Spatie\ThereThere\Http\Middleware\IsValidThereThereRequest::class,
        'api',
    ],
];

Add the secret to your .env file. You can find it in your There There workspace settings.

THERE_THERE_SECRET=your-secret-here

Usage

In a service provider (for example AppServiceProvider), register a sidebar callback using the ThereThere facade:

use Spatie\ThereThere\Facades\ThereThere;
use Spatie\ThereThere\SidebarItem;
use Spatie\ThereThere\Http\Requests\ThereThereRequest;

ThereThere::sidebar(function (ThereThereRequest $request) {
    $user = User::firstWhere('email', $request->email());

    if (! $user) {
        return [];
    }

    return [
        SidebarItem::markdown('Name', $user->name),
        SidebarItem::date('Registered at', $user->created_at),
        SidebarItem::numeric('Total orders', $user->orders()->count()),
        SidebarItem::boolean('Is subscribed', $user->subscribed()),
    ];
});

Each SidebarItem has a name, value, and type. The following types are available:

Type Method Value
numeric SidebarItem::numeric($name, $value) An integer or float
markdown SidebarItem::markdown($name, $value) A string (supports Markdown)
date SidebarItem::date($name, $value) A DateTimeInterface or ISO 8601 string
boolean SidebarItem::boolean($name, $value) A boolean

The package will respond with JSON in this format:

{
    "data": [
        {"name": "Name", "value": "John Doe", "type": "markdown"},
        {"name": "Registered at", "value": "2024-01-15T10:30:00+00:00", "type": "date"},
        {"name": "Total orders", "value": 42, "type": "numeric"},
        {"name": "Is subscribed", "value": true, "type": "boolean"}
    ]
}

Security

All requests are verified using HMAC-SHA256 signatures. The package will reject any request without a valid X-There-There-Signature header.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport