PHPackages                             jolti/freshchat\_sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. jolti/freshchat\_sdk

ActiveLibrary[API Development](/categories/api)

jolti/freshchat\_sdk
====================

A PHP SDK to use Freschat Chatbot API Service

20PHP

Since Jan 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/mohamedjolti/Freshchat_php_sdk)[ Packagist](https://packagist.org/packages/jolti/freshchat_sdk)[ RSS](/packages/jolti-freshchat-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Project Features
================

[](#project-features)

Create a PHP SDK to interact with Freshchat API

Documentation
-------------

[](#documentation)

The project is based on the documentation described in

Installation
------------

[](#installation)

first install composer dependencies

```
composer install

```

secondly copy .env.example file to .env and change the property API\_TOKEN with you Freshchat api token

Example usage
-------------

[](#example-usage)

let assume you want to send a message when a user send a message to your Bot, the WebhookController is an example of a controller to handle freshchat message notification (webhooks) 1.First we have to get the message from the incoming request sent by freshchat server , the class MessageResponseFactory can be used to build a message instance from a request

```
$messageResponseFactory = new MessageResponseFactory($request->getContent());
/**
* message webhook sent by Freshchat server
* @var Message
*/
$messageResponse = $messageResponseFactory->getMessage();

```

the variable messageResponse contains all the message properties.

2.Create new Conversation and set the id to the id of the messageResponse Conversation so our message will be send just to the user that contact us.

```
$conversation = new Conversation();
$conversation->setId($messageResponse->getConversationId());

```

3. Create a new Message , each message has an actor (agent) Id described in Freshchat documentation , in this example we will get our agents and set the first agent as the agent of our message
    getting first agent :

```
$agents = new Agent();
$agentsFromApi = $agents->getAgents();

$agentFactory = new AgentFactory();

/**
* @var array
*/
 $agents = $agentFactory->build($agentsFromApi);

$defaultActorId = $agents[0]->getId();

```

creating new Message and setting the Agent

```
$message = new Message();
$message->setActorId($defaultActorId);

```

4. Adding Message parts ,message parts has diffrent types text, images ,buttons.in this specific example we will add two parts a text and a image

```
$imageType = new ImageType();
$imageType->setResource($image_url);

$textType = new TextType();
$textType->setResource("Hi sir ,welcome to the World Cup");

$message->addMultipleParts([$imageType, $textType]);

```

5.Send the message , before sending the message you can check first if the incoming message is a UserMessage , we don't want to send a message if another agent send message (in this case)

```
if ($messageResponse->isUserMessage()) {
  $conversation->sendMessage($message);
}

```

New Features
------------

[](#new-features)

- Add integration testing for sending a message , getting agents
- Add other supported Freshchat message Types buttons
- Add api call to get all messages of a conversation (can be used to handle chatbot workflow)

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1986aa22bf3e65e86c9b9afe3c3359a48bc820bef4ee65276ad14b19c0d5060?d=identicon)[mohamed\_jolti](/maintainers/mohamed_jolti)

---

Top Contributors

[![mohamedjolti](https://avatars.githubusercontent.com/u/45952923?v=4)](https://github.com/mohamedjolti "mohamedjolti (11 commits)")

---

Tags

freshchat

### Embed Badge

![Health badge](/badges/jolti-freshchat-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/jolti-freshchat-sdk/health.svg)](https://phpackages.com/packages/jolti-freshchat-sdk)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
