ziming/laravel-crisp 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ziming/laravel-crisp

Composer 安装命令:

composer require ziming/laravel-crisp

包简介

Wrapper Library for Crisp Chat Rest Api

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A laravel Crisp library for Crisp Chat API.

Some example of things you can more easily do with this library:

  • Showing your customer last Crisp chat message in your own admin, which you can then click on to go straight to their profile or chat in Crisp
  • A cron job to delete very old messages from your Crisp workspace
  • A free/paid plugin in the Crisp Marketplace
  • Schedule reminders to your customers via Crisp Chat
  • Build your own chat bot to reply to your customers on Crisp Chat
  • and much more!

Support Me

You can use my referral link to sign up for a Crisp Chat free account. I get a small reward if you upgrade to the Essentials or Plus Plan in the future.

I highly recommend Crisp Chat if you are looking for a chat support SaaS for your website. As it charges a flat monthly fee per workspace instead of charging by per seat.

At the Essentials Plan & above, you also get features like: Sites Monitoring, Status Pages, AI Bot Builder, Knowledge Base, WhatsApp Integration & more!

Side Note: Looking to send WhatsApp messages with Crisp Chat? Check out my Laravel Crisp WhatsApp package too!

Installation

You can install the package via composer:

composer require ziming/laravel-crisp

You can publish the config file with:

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

This is the contents of the published config file:

return [
    'website_id' => env('CRISP_WEBSITE_ID'),
    'tier' => env('CRISP_TIER', 'plugin'),
    'access_key_id' => env('CRISP_ACCESS_KEY_ID'),
    'secret_access_key' => env('CRISP_SECRET_ACCESS_KEY'),
];

Usage

So what are the differences between the Crisp's official PHP SDK and this package?

The 1st main difference is that you don't have to set the tier & api credentials every time after instantiating

You also do not have to pass in the website_id every time.

I hope through the examples below, you can see how much more convenient this brings for those of us who only have a single Crisp workspace.

But 1st you need to create your plugin at the Crisp Marketplace 1st.

With that done, you may continue with the examples below or check out the source code in the src/Resources folder.

// Official PHP Crisp SDK
use Crisp\CrispClient;
$officialCrisp = new CrispClient();
$officialCrisp->setTier('plugin');
$officialCrisp->authenticate(
    config('crisp.access_key_id'), 
    config('crisp.secret_access_key')
);

$officialCrisp->websitePeople->findByEmail(config('crisp.website_id'), 'abc@example.com');

// This Package
$laravelCrisp = new Ziming\LaravelCrisp();
$laravelCrisp->websitePeople->findByEmail('abc@example.com');

// If you prefer the laravel facade approach you can just do this
\Ziming\LaravelCrisp\Facades\LaravelCrisp::websitePeople()
    ->findByEmail('abc@example.com');

// If for some reason you want to use a different website_id,
// the official Crisp client is always available too
$laravelCrisp->officialClient->websitePeople->findByEmail(
    config('crisp.website_id'), 
    'abc@example.com'
);

The 2nd main difference are extra methods that I think are useful but are not in Crisp official SDK when I 1st added them.

// Gives you the Crisp Profile Link in Crisp. You can put it in your laravel admin to easier go to the customer profile in Crisp for example.
\Ziming\LaravelCrisp\Resources\WebsitePeople::getProfileLink('people-id');

// Gives you the conversation link in Crisp. You can put it in your laravel admin to easier go to the customer chat in Crisp for example.
\Ziming\LaravelCrisp\Resources\WebsiteConversations::getConversationLink('session-id');

// Get the first people id that matches the search text if 1 or more results are returned
$laravelCrisp = new Ziming\LaravelCrisp();
$laravelCrisp->websitePeople->getFirstPeopleIdBySearchText('Some Phone Number as Crisp does not have an exact filter by phone feature yet (but coming soon)');

// Get you the last message of a conversation to show in admin for example
$laravelCrisp->websiteConversations->getOneLastMessage('session-id');

// Gives you a nice DTO object for a crisp conversation. Which give really nice hints to your IDEs
$crispConversation = $laravelCrisp->websiteConversations->getOneCrispConversation('session-id');

// Because it is a DTO object, you can access all the various properties
// of the object with IDE hints!
$crispConversation->is_verified;

The 3rd main difference is a few methods' signatures are changed to be more user-friendly compared to

// The official Crisp PHP sdk takes in a params array, mine takes in the 2 required arguments directly
$laravelCrisp->websiteConversations->create('website name', 'website.domain');

// The official Crisp PHP sdk takes in a params array, where the date key need to be in ISO 8601 string format,
// Mine takes in a Carbon instance directly and do the conversion for you. You can also pass in a ISO 8601 string for the $date
// argument if you prefer. You can use this to send a reminder to your customer via Crisp Chat for example
$laravelCrisp->websiteConversations->scheduleReminder($sessionId, now()->addDay(), 'Note');

Testing

composer test

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

ziming/laravel-crisp 适用场景与选型建议

ziming/laravel-crisp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.61k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2025 年 06 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「laravel-crisp」 「ziming」 「laravel-crisp-chat」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ziming/laravel-crisp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ziming/laravel-crisp 我们能提供哪些服务?
定制开发 / 二次开发

基于 ziming/laravel-crisp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 13.61k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-22