snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
This commit is contained in:
0
zerver/webhooks/delighted/__init__.py
Normal file
0
zerver/webhooks/delighted/__init__.py
Normal file
30
zerver/webhooks/delighted/doc.md
Normal file
30
zerver/webhooks/delighted/doc.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Zulip Delighted integration
|
||||
|
||||
Get notifications about updates in feedback responses organized by
|
||||
Delighted in Zulip.
|
||||
|
||||
{start_tabs}
|
||||
|
||||
1. {!create-an-incoming-webhook.md!}
|
||||
|
||||
1. {!generate-webhook-url-basic.md!}
|
||||
|
||||
1. On your Delighted dashboard, select **Settings** in the
|
||||
top-right corner.
|
||||
|
||||
1. Select **Integrations**, and then select **Webhooks**.
|
||||
|
||||
1. Under **Send webhook notifications for**, set **Webhook URL**
|
||||
to the URL generated above.
|
||||
|
||||
1. Select **Save and turn on**.
|
||||
|
||||
{end_tabs}
|
||||
|
||||
{!congrats.md!}
|
||||
|
||||

|
||||
|
||||
### Related documentation
|
||||
|
||||
{!webhooks-url-specification.md!}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"event_type": "survey_response.updated",
|
||||
"event_id": "b8d057c59327541d7ec2104c0a9a255ad1997fb00831b9c6bbf09561e6d5cbd0",
|
||||
"event_data": {
|
||||
"id": "5435",
|
||||
"person": {
|
||||
"id": "5975",
|
||||
"email": "paul_gravis@example.com",
|
||||
"name": "Paul Gravis",
|
||||
"created_at": 1482589349
|
||||
},
|
||||
"score": 5,
|
||||
"comment": "Your service is slow, but nearly flawless! Keep up the good work!",
|
||||
"permalink": "https://delighted.com/r/5pFDpmlyC8GUc5oxU6USto5VonSKAqOa",
|
||||
"created_at": 1482589409,
|
||||
"updated_at": 1482590009,
|
||||
"person_properties": null,
|
||||
"notes": [],
|
||||
"tags": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"event_type": "survey_response.updated",
|
||||
"event_id": "b8d057c59327541d7ec2104c0a9a255ad1997fb00831b9c6bbf09561e6d5cbd0",
|
||||
"event_data": {
|
||||
"id": "5435",
|
||||
"person": {
|
||||
"id": "5975",
|
||||
"email": "charlie_gravis@example.com",
|
||||
"name": "Charlie Gravis",
|
||||
"created_at": 1482589349
|
||||
},
|
||||
"score": 9,
|
||||
"comment": "Your service is fast and flawless!",
|
||||
"permalink": "https://delighted.com/r/5pFDpmlyC8GUc5oxU6USto5VonSKAqOa",
|
||||
"created_at": 1482589409,
|
||||
"updated_at": 1482590009,
|
||||
"person_properties": null,
|
||||
"notes": [],
|
||||
"tags": []
|
||||
}
|
||||
}
|
||||
43
zerver/webhooks/delighted/tests.py
Normal file
43
zerver/webhooks/delighted/tests.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
|
||||
class DelightedHookTests(WebhookTestCase):
|
||||
def test_feedback_message_promoter(self) -> None:
|
||||
expected_topic_name = "Survey response"
|
||||
expected_message = """
|
||||
Kudos! You have a new promoter. Score of 9/10 from charlie_gravis@example.com:
|
||||
|
||||
``` quote
|
||||
Your service is fast and flawless!
|
||||
```
|
||||
""".strip()
|
||||
|
||||
self.check_webhook(
|
||||
"survey_response_updated_promoter",
|
||||
expected_topic_name,
|
||||
expected_message,
|
||||
content_type="application/x-www-form-urlencoded",
|
||||
)
|
||||
|
||||
def test_feedback_message_non_promoter(self) -> None:
|
||||
expected_topic_name = "Survey response"
|
||||
expected_message = (
|
||||
"Great! You have new feedback.\n"
|
||||
">Score of 5/10 from paul_gravis@example.com"
|
||||
"\n>Your service is slow, but nearly flawless! "
|
||||
"Keep up the good work!"
|
||||
)
|
||||
expected_message = """
|
||||
Great! You have new feedback. Score of 5/10 from paul_gravis@example.com:
|
||||
|
||||
``` quote
|
||||
Your service is slow, but nearly flawless! Keep up the good work!
|
||||
```
|
||||
""".strip()
|
||||
|
||||
self.check_webhook(
|
||||
"survey_response_updated_non_promoter",
|
||||
expected_topic_name,
|
||||
expected_message,
|
||||
content_type="application/x-www-form-urlencoded",
|
||||
)
|
||||
52
zerver/webhooks/delighted/view.py
Normal file
52
zerver/webhooks/delighted/view.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import webhook_view
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint
|
||||
from zerver.lib.validator import WildValue, check_int, check_string
|
||||
from zerver.lib.webhooks.common import check_send_webhook_message
|
||||
from zerver.models import UserProfile
|
||||
|
||||
PROMOTER = """
|
||||
Kudos! You have a new promoter. Score of {score}/10 from {email}:
|
||||
|
||||
``` quote
|
||||
{comment}
|
||||
```
|
||||
""".strip()
|
||||
|
||||
FEEDBACK = """
|
||||
Great! You have new feedback. Score of {score}/10 from {email}:
|
||||
|
||||
``` quote
|
||||
{comment}
|
||||
```
|
||||
""".strip()
|
||||
|
||||
|
||||
def body_template(score: int) -> str:
|
||||
if score >= 7:
|
||||
return PROMOTER
|
||||
else:
|
||||
return FEEDBACK
|
||||
|
||||
|
||||
@webhook_view("Delighted")
|
||||
@typed_endpoint
|
||||
def api_delighted_webhook(
|
||||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
*,
|
||||
payload: JsonBodyPayload[WildValue],
|
||||
) -> HttpResponse:
|
||||
person = payload["event_data"]["person"]
|
||||
email = person["email"].tame(check_string)
|
||||
score = payload["event_data"]["score"].tame(check_int)
|
||||
comment = payload["event_data"]["comment"].tame(check_string)
|
||||
|
||||
BODY_TEMPLATE = body_template(score)
|
||||
body = BODY_TEMPLATE.format(email=email, score=score, comment=comment)
|
||||
topic_name = "Survey response"
|
||||
|
||||
check_send_webhook_message(request, user_profile, topic_name, body)
|
||||
return json_success(request)
|
||||
Reference in New Issue
Block a user