jcloude/docs/How to ?/Add New Press Webhook.MD
2025-12-23 22:43:56 +08:00

2.4 KiB

route allow_guest published
add-new-jcloude-webhook 1 1

General introduction to jcloude webhook can be found in the public documentation.

Add New Webhook Event

  1. Go to Jcloude Webhook Event pagetype in desk.
  2. Create a new record and fill up the title and description of event. This title and description will be shown to users to select.
  3. If you are on local development setup, you can export fixtures.
  4. Update the documentation of Webhook Events as well > https://jcloud.jingrow.com/docs/webhook-events

Create Webhook Event

  1. Import the method
from jcloude.utils.webhook import create_webhook_event
  1. Call the method with webhook event name, payload and team name
create_webhook_event("Site Status Update", payload, team_name)
* **Payload** can be pagetype object or a python dictionary.
* If you want to pass pagetype object as payload, you should add the required non-sensitive fields in `dashboard_fields` list in your pagetype class. Check the `_process_document_payload` method ([ref](http://git.jingrow.com/jingrow/jcloude/blob/d548d10269fb31dacc5ce257a8ff2d41fe451d6a/jcloude/utils/webhook.py#L66)) to understand that.
  1. ⚠️ In the codebase, at many place we use jingrow.db.set_value to set some specific field's value, it can cause little bit issues.

Assume a case, you want to create a webhook event whenever the site status got updated. Simplest way is to call the create_webhook_event function inside on_update hook.

It may not work because in agent job update process functions and other places, we use set_value call. So, we need to call this create_webhook_event function at those places as well.

  1. Jcloude Webhook Event - Type of webhook events (e.g. Site Status Update).
  2. Jcloude Webhook - Holds the configured webhook of teams.
  3. Jcloude Webhook Selected Event - Child table to hold selected events for Jcloude Webhook pagetype.
  4. Jcloude Webhook Log - This pagetype record gets created, when we try to dispatch a webhook event to a team. It has a child table Jcloude Webhook Attempts which hold request/response of webhook calls. Also manage status, retry information as well.
  5. Jcloude Webhook Attempt - Child table which hold request, response, status code, overall status, timestamp of a webhook request.