PHPackages                             import-ai/flarum-webhook - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. import-ai/flarum-webhook

ActiveFlarum-extension[Utility &amp; Helpers](/categories/utility)

import-ai/flarum-webhook
========================

Trigger webhooks when users create new posts

v0.1.2(3mo ago)1641Apache-2.0PHPCI passing

Since Jan 30Pushed 3mo agoCompare

[ Source](https://github.com/import-ai/flarum-webhook)[ Packagist](https://packagist.org/packages/import-ai/flarum-webhook)[ RSS](/packages/import-ai-flarum-webhook/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (0)

Flarum Webhook
==============

[](#flarum-webhook)

This file provides guidance to developers when working with code in this repository.

Overview
--------

[](#overview)

This is a Flarum extension (`import-ai/flarum-webhook`) that triggers HTTP webhooks for various forum events including post creation, editing, deletion, and discussion changes. It sends POST requests with JSON payloads containing full model data.

Development Commands
--------------------

[](#development-commands)

### Frontend (JavaScript)

[](#frontend-javascript)

```
cd js
npm install          # Install dependencies
npm run dev          # Watch mode for development
npm run build        # Production build
```

Architecture
------------

[](#architecture)

### Backend (PHP)

[](#backend-php)

- **Namespace**: `ImportAI\Webhook`
- **Entry point**: `extend.php` - Registers extenders for admin frontend, locales, event listeners, and settings
- **Event listeners**:
    - `src/Listener/PostCreatedListener.php` - Listens to `Flarum\Post\Event\Posted` for new posts
    - `src/Listener/PostRevisedListener.php` - Listens to `Flarum\Post\Event\Revised` for post edits
    - `src/Listener/PostHiddenListener.php` - Listens to `Flarum\Post\Event\Hidden` for soft-deleted (hidden) posts
    - `src/Listener/PostDeletedListener.php` - Listens to `Flarum\Post\Event\Deleted` for hard-deleted posts
    - `src/Listener/DiscussionRenamedListener.php` - Listens to `Flarum\Discussion\Event\Renamed` for title changes
    - `src/Listener/DiscussionHiddenListener.php` - Listens to `Flarum\Discussion\Event\Hidden` for soft-deleted (hidden) discussions
    - `src/Listener/DiscussionDeletedListener.php` - Listens to `Flarum\Discussion\Event\Deleted` for hard-deleted discussions

### Frontend (JavaScript)

[](#frontend-javascript-1)

- **Admin panel**: `js/src/admin/index.js` - Registers a settings field for the webhook URL

### Settings

[](#settings)

- `import-ai-webhook.webhook_url` - The target URL for webhook POST requests

### Webhook Payload

[](#webhook-payload)

The webhook sends a JSON payload with full model data. The payload structure varies by event type:

**Post Events** (`post.created`, `post.revised`, `post.hidden`, `post.deleted`):

```
{
  "event": "post.created | post.revised | post.hidden | post.deleted",
  "user": { /* full user model attributes */ },
  "post": { /* full post model attributes */ },
  "discussion": { /* full discussion model attributes */ },
  "actor": { /* full actor model attributes (user who triggered the event) */ }
}
```

**Discussion Renamed Event** (`discussion.renamed`):

```
{
  "event": "discussion.renamed",
  "discussion": { /* full discussion model attributes */ },
  "old_title": "Previous discussion title",
  "actor": { /* full actor model attributes */ }
}
```

**Discussion Deleted Event** (`discussion.hidden`, `discussion.deleted`):

```
{
  "event": "discussion.hidden | discussion.deleted",
  "discussion": { /* full discussion model attributes */ },
  "actor": { /* full actor model attributes */ }
}
```

**Event Types**:

- `post.created` - Triggered when a new post is created
- `post.revised` - Triggered when an existing post is edited
- `post.hidden` - Triggered when a post is soft-deleted (hidden) via the UI
- `post.deleted` - Triggered when a post is permanently (hard) deleted
- `discussion.renamed` - Triggered when a discussion title is changed
- `discussion.hidden` - Triggered when a discussion is soft-deleted (hidden) via the UI
- `discussion.deleted` - Triggered when a discussion is permanently (hard) deleted

### Identifying Discussion Creation

[](#identifying-discussion-creation)

Flarum Webhook does not have a separate `discussion.created` event. When a new discussion is created, it triggers a `post.created` event for the first post. To identify if a `post.created` event represents a new discussion:

```
{
  "event": "post.created",
  "post": {
    "number": 1,           // First post has number = 1
    "id": 9,
    // ...
  },
  "discussion": {
    "first_post_id": null,  // null for newly created discussions (or equals post.id)
    "comment_count": 1,      // Only one comment in the discussion
    "last_post_id": 9,       // Equals post.id
    // ...
  }
}
```

**Check conditions**:

- `post.number === 1` - The post is the first in sequence
- `discussion.comment_count === 1` - Only one comment exists
- `discussion.first_post_id === null` OR `discussion.first_post_id === post.id` - For newly created discussions

### Localization

[](#localization)

- `locale/en.yml` - English translations
- `locale/zh-Hans.yml` - Simplified Chinese translations

Git Commit Guidelines
---------------------

[](#git-commit-guidelines)

**Format**: `type(scope): Description`

**Types**:

- `feat` - New features
- `fix` - Bug fixes
- `docs` - Documentation changes
- `style` - Styling changes
- `refactor` - Code refactoring
- `perf` - Performance improvements
- `test` - Test additions or changes
- `chore` - Maintenance tasks
- `revert` - Revert previous commits
- `build` - Build system changes

**Rules**:

- Scope is required (e.g., `sidebar`, `tasks`, `auth`)
- Description in sentence case with capital first letter
- Use present tense action verbs (Add, Fix, Support, Update, Replace, Optimize)
- No period at the end
- Keep it concise and focused

**Examples**:

```
feat(apple): Support apple signin
fix(sidebar): Change the abnormal scrolling
chore(children): Optimize children api
refactor(tasks): Add timeout status

```

**Do NOT include**:

- "Generated with Claude Code" or similar attribution
- "Co-Authored-By: Claude" or any Claude co-author tags

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance86

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity27

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.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

98d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1c6fa04ffefda5bef57e9401b6e723e2a56db702f5ea28b92e039febd0ea050f?d=identicon)[import-ai](/maintainers/import-ai)

---

Top Contributors

[![LucienShui](https://avatars.githubusercontent.com/u/30151093?v=4)](https://github.com/LucienShui "LucienShui (13 commits)")

---

Tags

flarum

### Embed Badge

![Health badge](/badges/import-ai-flarum-webhook/health.svg)

```
[![Health](https://phpackages.com/badges/import-ai-flarum-webhook/health.svg)](https://phpackages.com/packages/import-ai-flarum-webhook)
```

###  Alternatives

[fof/byobu

Well integrated, advanced private discussions.

61105.8k9](/packages/fof-byobu)[fof/user-bio

Add a user bio to user profiles

2196.5k9](/packages/fof-user-bio)[fof/sitemap

Generate a sitemap

1988.7k2](/packages/fof-sitemap)[fof/drafts

Allow users to create post and discussion drafts

1771.1k5](/packages/fof-drafts)

PHPackages © 2026

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