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/groove/__init__.py
Normal file
0
zerver/webhooks/groove/__init__.py
Normal file
32
zerver/webhooks/groove/doc.md
Normal file
32
zerver/webhooks/groove/doc.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# Zulip Groove integration
|
||||
|
||||
Get Zulip notifications for your Groove events!
|
||||
|
||||
{start_tabs}
|
||||
|
||||
1. {!create-an-incoming-webhook.md!}
|
||||
|
||||
1. {!generate-webhook-url-basic.md!}
|
||||
|
||||
1. Got to **Settings** on your Groove dashboard. Under **Company**,
|
||||
click on **API**. Open the **Add Webhook** dropdown and select one
|
||||
of the [events](#filtering-incoming-events) supported by this
|
||||
integration.
|
||||
|
||||
1. In the space below the event, enter the URL generated above. Click
|
||||
**Add Webhook**.
|
||||
|
||||
1. Repeat the last two steps, using the same generated URL, for every
|
||||
event listed below that you'd like to be notified about.
|
||||
|
||||
{end_tabs}
|
||||
|
||||
{!congrats.md!}
|
||||
|
||||

|
||||
|
||||
{!event-filtering-additional-feature.md!}
|
||||
|
||||
### Related documentation
|
||||
|
||||
{!webhooks-url-specification.md!}
|
||||
25
zerver/webhooks/groove/fixtures/agent_replied.json
Normal file
25
zerver/webhooks/groove/fixtures/agent_replied.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"links": {
|
||||
"author": {
|
||||
"href": "http://api.groovehq.com/v1/agents/agent@example.com"
|
||||
},
|
||||
"recipient": {
|
||||
"href": "http://api.groovehq.com/v1/customers/rambo@example.com"
|
||||
},
|
||||
"ticket": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/776"
|
||||
}
|
||||
},
|
||||
"created_at": "2017-12-14 21:17:29 +0530",
|
||||
"updated_at": "2017-12-14 21:17:29 +0530",
|
||||
"note": false,
|
||||
"id": "5308968422",
|
||||
"body": "Hello , This is a reply from an agent to a ticket",
|
||||
"href": "http://api.groovehq.com/v1/messages/5308968422",
|
||||
"plain_text_body": "Hello , This is a reply from an agent to a ticket",
|
||||
"agent_response": true,
|
||||
"type": "Comment",
|
||||
"attachments": [],
|
||||
"deliver_by": null,
|
||||
"app_ticket_url": "https://ghostfox.groovehq.com/groove_client/tickets/68667295"
|
||||
}
|
||||
22
zerver/webhooks/groove/fixtures/customer_replied.json
Normal file
22
zerver/webhooks/groove/fixtures/customer_replied.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"links": {
|
||||
"author": {
|
||||
"href": "http://api.groovehq.com/v1/customers/rambo@example.com"
|
||||
},
|
||||
"ticket": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/440"
|
||||
}
|
||||
},
|
||||
"created_at": "2017-12-14 15:54:26 UTC",
|
||||
"updated_at": "2017-12-14 15:54:26 UTC",
|
||||
"note": false,
|
||||
"id": "4810291604",
|
||||
"body": "<p>Hello agent, thanks for getting back. This is how a reply from customer looks like.</p>",
|
||||
"href": "http://api.groovehq.com/v1/messages/4810291604",
|
||||
"plain_text_body": "Hello agent, thanks for getting back. This is how a reply from customer looks like.",
|
||||
"agent_response": false,
|
||||
"type": null,
|
||||
"attachments": [],
|
||||
"deliver_by": null,
|
||||
"app_ticket_url": "https://ghostfox.groovehq.com/groove_client/tickets/68666538"
|
||||
}
|
||||
22
zerver/webhooks/groove/fixtures/note_added.json
Normal file
22
zerver/webhooks/groove/fixtures/note_added.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"links": {
|
||||
"author": {
|
||||
"href": "http://api.groovehq.com/v1/agents/anotheragent@example.com"
|
||||
},
|
||||
"ticket": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/776"
|
||||
}
|
||||
},
|
||||
"created_at": "2017-12-14 15:53:33 UTC",
|
||||
"updated_at": "2017-12-14 15:53:33 UTC",
|
||||
"note": true,
|
||||
"id": "4658911092",
|
||||
"body": "<div>This is a note added to a ticket.\n</div>",
|
||||
"href": "http://api.groovehq.com/v1/messages/4658911092",
|
||||
"plain_text_body": "This is a note added to a ticket",
|
||||
"agent_response": true,
|
||||
"type": null,
|
||||
"attachments": [],
|
||||
"deliver_by": null,
|
||||
"app_ticket_url": "https://ghostfox.groovehq.com/groove_client/tickets/68667295"
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"created_at": "2017-12-14 20:09:19 +0530",
|
||||
"href": "http://api.groovehq.com/v1/tickets/9",
|
||||
"links": {
|
||||
"customer": {
|
||||
"id": "0070883940",
|
||||
"href": "http://api.groovehq.com/v1/customers/customer@example.com"
|
||||
},
|
||||
"drafts": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/drafts"
|
||||
},
|
||||
"state": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/state"
|
||||
},
|
||||
"messages": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/messages"
|
||||
},
|
||||
"assignee": {
|
||||
"id": "1734497920",
|
||||
"href": "http://api.groovehq.com/v1/agents/agent@example.com"
|
||||
}
|
||||
},
|
||||
"number": 9,
|
||||
"priority": "low",
|
||||
"resolution_time": null,
|
||||
"state": "opened",
|
||||
"title": "Test Subject",
|
||||
"updated_at": "2017-12-14 20:52:26 +0530",
|
||||
"system_updated_at": "2017-12-14 20:52:26 +0530",
|
||||
"assigned_group_id": "1414937220",
|
||||
"assigned_group": "group2",
|
||||
"closed_by": null,
|
||||
"tags": [],
|
||||
"tag_ids": [],
|
||||
"mailbox": "Inbox",
|
||||
"mailbox_id": "5063661921",
|
||||
"message_count": 1,
|
||||
"attachment_count": 0,
|
||||
"summary": "The content of the body goes here.",
|
||||
"search_summary": null,
|
||||
"last_message_type": "enduser",
|
||||
"last_message_author": {
|
||||
"id": "1734497920",
|
||||
"type": "Agent"
|
||||
},
|
||||
"type": "Widget",
|
||||
"snoozed_until": null,
|
||||
"snoozed_by_id": null,
|
||||
"interaction_count": 1,
|
||||
"state_changed_at": "2017-12-14 20:09:19 +0530",
|
||||
"assigned_at": "2017-12-14 20:52:26 +0530",
|
||||
"deleted_at": null,
|
||||
"browser": null,
|
||||
"page_title": null,
|
||||
"page_url": null,
|
||||
"platform": null,
|
||||
"last_message": "The content of the body goes here.",
|
||||
"assignee": "agent@example.com",
|
||||
"app_url": "https://testteam.groovehq.com/groove_client/tickets/68659446",
|
||||
"app_customer_url": "https://testteam.groovehq.com/groove_client/contacts/customers/49825873",
|
||||
"customer_name": "Test Name",
|
||||
"last_message_plain_text": "The content of the body goes here."
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"created_at": "2017-12-14 20:09:19 +0530",
|
||||
"href": "http://api.groovehq.com/v1/tickets/9",
|
||||
"links": {
|
||||
"customer": {
|
||||
"id": "0070883940",
|
||||
"href": "http://api.groovehq.com/v1/customers/customer@example.lcom"
|
||||
},
|
||||
"drafts": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/drafts"
|
||||
},
|
||||
"state": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/state"
|
||||
},
|
||||
"messages": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/messages"
|
||||
},
|
||||
"assignee": {
|
||||
"id": "9804030737",
|
||||
"href": "http://api.groovehq.com/v1/agents/agent@example.com"
|
||||
}
|
||||
},
|
||||
"number": 9,
|
||||
"priority": "low",
|
||||
"resolution_time": null,
|
||||
"state": "opened",
|
||||
"title": "Test Subject",
|
||||
"updated_at": "2017-12-14 20:17:57 +0530",
|
||||
"system_updated_at": "2017-12-14 20:17:57 +0530",
|
||||
"assigned_group_id": null,
|
||||
"assigned_group": null,
|
||||
"closed_by": null,
|
||||
"tags": [],
|
||||
"tag_ids": [],
|
||||
"mailbox": "Inbox",
|
||||
"mailbox_id": "5063661921",
|
||||
"message_count": 1,
|
||||
"attachment_count": 0,
|
||||
"summary": "The content of the body goes here.",
|
||||
"search_summary": null,
|
||||
"last_message_type": "enduser",
|
||||
"last_message_author": {
|
||||
"id": "1734497920",
|
||||
"type": "Agent"
|
||||
},
|
||||
"type": "Widget",
|
||||
"snoozed_until": null,
|
||||
"snoozed_by_id": null,
|
||||
"interaction_count": 1,
|
||||
"state_changed_at": "2017-12-14 20:09:19 +0530",
|
||||
"assigned_at": "2017-12-14 20:17:57 +0530",
|
||||
"deleted_at": null,
|
||||
"browser": null,
|
||||
"page_title": null,
|
||||
"page_url": null,
|
||||
"platform": null,
|
||||
"last_message": "The content of the body goes here.",
|
||||
"assignee": "agent@example.com",
|
||||
"app_url": "https://testteam.groovehq.com/groove_client/tickets/68659446",
|
||||
"app_customer_url": "https://testteam.groovehq.com/groove_client/contacts/customers/49825873",
|
||||
"customer_name": "Test Name",
|
||||
"last_message_plain_text": "The content of the body goes here."
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"created_at": "2017-12-14 20:09:19 +0530",
|
||||
"href": "http://api.groovehq.com/v1/tickets/9",
|
||||
"links": {
|
||||
"customer": {
|
||||
"id": "0070883940",
|
||||
"href": "http://api.groovehq.com/v1/customers/customer@example.com"
|
||||
},
|
||||
"drafts": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/drafts"
|
||||
},
|
||||
"state": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/state"
|
||||
},
|
||||
"messages": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/messages"
|
||||
}
|
||||
},
|
||||
"number": 9,
|
||||
"priority": "low",
|
||||
"resolution_time": null,
|
||||
"state": "pending",
|
||||
"title": "Test Subject",
|
||||
"updated_at": "2017-12-14 20:52:26 +0530",
|
||||
"system_updated_at": "2017-12-14 20:52:26 +0530",
|
||||
"assigned_group_id": "1414937220",
|
||||
"assigned_group": "group2",
|
||||
"closed_by": null,
|
||||
"tags": [],
|
||||
"tag_ids": [],
|
||||
"mailbox": "Inbox",
|
||||
"mailbox_id": "5063661921",
|
||||
"message_count": 1,
|
||||
"attachment_count": 0,
|
||||
"summary": "The content of the body goes here.",
|
||||
"search_summary": null,
|
||||
"last_message_type": "enduser",
|
||||
"last_message_author": {
|
||||
"id": "1734497920",
|
||||
"type": "Agent"
|
||||
},
|
||||
"type": "Widget",
|
||||
"snoozed_until": null,
|
||||
"snoozed_by_id": null,
|
||||
"interaction_count": 1,
|
||||
"state_changed_at": "2017-12-14 20:09:19 +0530",
|
||||
"assigned_at": "2017-12-14 20:52:26 +0530",
|
||||
"deleted_at": null,
|
||||
"browser": null,
|
||||
"page_title": null,
|
||||
"page_url": null,
|
||||
"platform": null,
|
||||
"last_message": "The content of the body goes here.",
|
||||
"assignee": null,
|
||||
"app_url": "https://testteam.groovehq.com/groove_client/tickets/68659446",
|
||||
"app_customer_url": "https://testteam.groovehq.com/groove_client/contacts/customers/49825873",
|
||||
"customer_name": "Test Name",
|
||||
"last_message_plain_text": "The content of the body goes here."
|
||||
}
|
||||
59
zerver/webhooks/groove/fixtures/ticket_assigned__no_one.json
Normal file
59
zerver/webhooks/groove/fixtures/ticket_assigned__no_one.json
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"created_at": "2017-12-14 20:09:19 +0530",
|
||||
"href": "http://api.groovehq.com/v1/tickets/9",
|
||||
"links": {
|
||||
"customer": {
|
||||
"id": "0070883940",
|
||||
"href": "http://api.groovehq.com/v1/customers/customer@example.lcom"
|
||||
},
|
||||
"drafts": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/drafts"
|
||||
},
|
||||
"state": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/state"
|
||||
},
|
||||
"messages": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/messages"
|
||||
}
|
||||
},
|
||||
"number": 9,
|
||||
"priority": "low",
|
||||
"resolution_time": null,
|
||||
"state": "closed",
|
||||
"title": "Test Subject",
|
||||
"updated_at": "2017-12-14 20:17:57 +0530",
|
||||
"system_updated_at": "2017-12-14 20:17:57 +0530",
|
||||
"assigned_group_id": null,
|
||||
"assigned_group": null,
|
||||
"closed_by": null,
|
||||
"tags": [],
|
||||
"tag_ids": [],
|
||||
"mailbox": "Inbox",
|
||||
"mailbox_id": "5063661921",
|
||||
"message_count": 1,
|
||||
"attachment_count": 0,
|
||||
"summary": "The content of the body goes here.",
|
||||
"search_summary": null,
|
||||
"last_message_type": "enduser",
|
||||
"last_message_author": {
|
||||
"id": "1734497920",
|
||||
"type": "Agent"
|
||||
},
|
||||
"type": "Widget",
|
||||
"snoozed_until": null,
|
||||
"snoozed_by_id": null,
|
||||
"interaction_count": 1,
|
||||
"state_changed_at": "2017-12-14 20:09:19 +0530",
|
||||
"assigned_at": "2017-12-14 20:17:57 +0530",
|
||||
"deleted_at": null,
|
||||
"browser": null,
|
||||
"page_title": null,
|
||||
"page_url": null,
|
||||
"platform": null,
|
||||
"last_message": "The content of the body goes here.",
|
||||
"assignee": null,
|
||||
"app_url": "https://testteam.groovehq.com/groove_client/tickets/68659446",
|
||||
"app_customer_url": "https://testteam.groovehq.com/groove_client/contacts/customers/49825873",
|
||||
"customer_name": "Test Name",
|
||||
"last_message_plain_text": "The content of the body goes here."
|
||||
}
|
||||
59
zerver/webhooks/groove/fixtures/ticket_started.json
Normal file
59
zerver/webhooks/groove/fixtures/ticket_started.json
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"created_at": "2017-12-14 20:09:19 +0530",
|
||||
"href": "http://api.groovehq.com/v1/tickets/9",
|
||||
"links": {
|
||||
"customer": {
|
||||
"id": "0070883940",
|
||||
"href": "http://api.groovehq.com/v1/customers/customer@example.lcom"
|
||||
},
|
||||
"drafts": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/drafts"
|
||||
},
|
||||
"state": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/state"
|
||||
},
|
||||
"messages": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/9/messages"
|
||||
}
|
||||
},
|
||||
"number": 9,
|
||||
"priority": "low",
|
||||
"resolution_time": null,
|
||||
"state": "opened",
|
||||
"title": "Test Subject",
|
||||
"updated_at": "2017-12-14 20:09:19 +0530",
|
||||
"system_updated_at": "2017-12-14 20:09:19 +0530",
|
||||
"assigned_group_id": null,
|
||||
"assigned_group": null,
|
||||
"closed_by": null,
|
||||
"tags": [],
|
||||
"tag_ids": [],
|
||||
"mailbox": "Inbox",
|
||||
"mailbox_id": "5063661921",
|
||||
"message_count": 1,
|
||||
"attachment_count": 0,
|
||||
"summary": "The content of the body goes here.",
|
||||
"search_summary": null,
|
||||
"last_message_type": "enduser",
|
||||
"last_message_author": {
|
||||
"id": "1734497920",
|
||||
"type": "Agent"
|
||||
},
|
||||
"type": "Widget",
|
||||
"snoozed_until": null,
|
||||
"snoozed_by_id": null,
|
||||
"interaction_count": 1,
|
||||
"state_changed_at": "2017-12-14 20:09:19 +0530",
|
||||
"assigned_at": null,
|
||||
"deleted_at": null,
|
||||
"browser": null,
|
||||
"page_title": null,
|
||||
"page_url": null,
|
||||
"platform": null,
|
||||
"last_message": "The content of the body goes here.",
|
||||
"assignee": null,
|
||||
"app_url": "https://ghostfox.groovehq.com/groove_client/tickets/68659446",
|
||||
"app_customer_url": "https://ghostfox.groovehq.com/groove_client/contacts/customers/49825873",
|
||||
"customer_name": "Test Name",
|
||||
"last_message_plain_text": "The content of the body goes here."
|
||||
}
|
||||
69
zerver/webhooks/groove/fixtures/ticket_state_changed.json
Normal file
69
zerver/webhooks/groove/fixtures/ticket_state_changed.json
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"href": "/v1/tickets/776",
|
||||
"state": "pending",
|
||||
"ticket_number": 776,
|
||||
"ticket": {
|
||||
"created_at": "2017-12-14 21:12:24 +0530",
|
||||
"href": "http://api.groovehq.com/v1/tickets/776",
|
||||
"links": {
|
||||
"customer": {
|
||||
"id": "6383949050",
|
||||
"href": "http://api.groovehq.com/v1/customers/rambo@example.com"
|
||||
},
|
||||
"drafts": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/776/drafts"
|
||||
},
|
||||
"state": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/776/state"
|
||||
},
|
||||
"messages": {
|
||||
"href": "http://api.groovehq.com/v1/tickets/776/messages"
|
||||
},
|
||||
"assignee": {
|
||||
"id": "1734497920",
|
||||
"href": "http://api.groovehq.com/v1/agents/agent@example.com"
|
||||
}
|
||||
},
|
||||
"number": 776,
|
||||
"priority": "low",
|
||||
"resolution_time": null,
|
||||
"state": "pending",
|
||||
"title": "Subject will be here",
|
||||
"updated_at": "2017-12-14 21:17:29 +0530",
|
||||
"system_updated_at": "2017-12-14 21:17:29 +0530",
|
||||
"assigned_group_id": null,
|
||||
"assigned_group": null,
|
||||
"closed_by": null,
|
||||
"tags": [],
|
||||
"tag_ids": [],
|
||||
"mailbox": "Inbox",
|
||||
"mailbox_id": "5063661921",
|
||||
"message_count": 2,
|
||||
"attachment_count": 0,
|
||||
"summary": "Hello , This is a reply from an agent to a ticket",
|
||||
"search_summary": null,
|
||||
"last_message_type": "enduser",
|
||||
"last_message_author": {
|
||||
"id": "1734497920",
|
||||
"type": "Agent"
|
||||
},
|
||||
"type": "Email",
|
||||
"snoozed_until": null,
|
||||
"snoozed_by_id": null,
|
||||
"interaction_count": 4,
|
||||
"state_changed_at": "2017-12-14 21:17:29 +0530",
|
||||
"assigned_at": "2017-12-14 21:17:29 +0530",
|
||||
"deleted_at": null,
|
||||
"browser": null,
|
||||
"page_title": null,
|
||||
"page_url": null,
|
||||
"platform": null,
|
||||
"last_message": "Hello , This is a reply from an agent to a ticket",
|
||||
"assignee": "agent@example.com",
|
||||
"app_url": "https://ghostfox.groovehq.com/groove_client/tickets/68667295",
|
||||
"app_customer_url": "https://ghostfox.groovehq.com/groove_client/contacts/customers/49829231",
|
||||
"customer_name": "RAMBO",
|
||||
"last_message_plain_text": "Hello , This is a reply from an agent to a ticket"
|
||||
},
|
||||
"app_url": "https://ghostfox.groovehq.com/groove_client/tickets/68667295"
|
||||
}
|
||||
124
zerver/webhooks/groove/tests.py
Normal file
124
zerver/webhooks/groove/tests.py
Normal file
@@ -0,0 +1,124 @@
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
|
||||
class GrooveHookTests(WebhookTestCase):
|
||||
# This test simulates the condition when a new ticket comes.
|
||||
def test_groove_ticket_started(self) -> None:
|
||||
expected_topic_name = "notifications"
|
||||
expected_message = """
|
||||
Test Name submitted new ticket [#9: Test Subject](https://ghostfox.groovehq.com/groove_client/tickets/68659446):
|
||||
|
||||
``` quote
|
||||
The content of the body goes here.
|
||||
```
|
||||
""".strip()
|
||||
|
||||
self.check_webhook(
|
||||
"ticket_started",
|
||||
expected_topic_name,
|
||||
expected_message,
|
||||
content_type="application/x-www-form-urlencoded",
|
||||
)
|
||||
|
||||
# This simulates the condition when a ticket
|
||||
# is assigned to an agent.
|
||||
def test_groove_ticket_assigned_agent_only(self) -> None:
|
||||
expected_topic_name = "notifications"
|
||||
expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (open) assigned to agent@example.com."
|
||||
self.check_webhook(
|
||||
"ticket_assigned__agent_only",
|
||||
expected_topic_name,
|
||||
expected_message,
|
||||
content_type="application/x-www-form-urlencoded",
|
||||
)
|
||||
|
||||
# This simulates the condition when a ticket
|
||||
# is assigned to an agent in a group.
|
||||
def test_groove_ticket_assigned_agent_and_group(self) -> None:
|
||||
expected_topic_name = "notifications"
|
||||
expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (open) assigned to agent@example.com from group2."
|
||||
|
||||
self.check_webhook(
|
||||
"ticket_assigned__agent_and_group",
|
||||
expected_topic_name,
|
||||
expected_message,
|
||||
content_type="application/x-www-form-urlencoded",
|
||||
)
|
||||
|
||||
# This simulates the condition when a ticket
|
||||
# is assigned to a group.
|
||||
def test_groove_ticket_assigned_group_only(self) -> None:
|
||||
expected_topic_name = "notifications"
|
||||
expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (pending) assigned to group2."
|
||||
self.check_webhook(
|
||||
"ticket_assigned__group_only",
|
||||
expected_topic_name,
|
||||
expected_message,
|
||||
content_type="application/x-www-form-urlencoded",
|
||||
)
|
||||
|
||||
# This simulates the condition when a ticket
|
||||
# is assigned to no one.
|
||||
def test_groove_ticket_assigned_no_one(self) -> None:
|
||||
self.subscribe(self.test_user, self.channel_name)
|
||||
result = self.client_post(
|
||||
self.url,
|
||||
self.get_body("ticket_assigned__no_one"),
|
||||
content_type="application/x-www-form-urlencoded",
|
||||
HTTP_X_GROOVE_EVENT="ticket_assigned",
|
||||
)
|
||||
self.assert_json_success(result)
|
||||
|
||||
# This simulates the notification when an agent replied to a ticket.
|
||||
def test_groove_agent_replied(self) -> None:
|
||||
expected_topic_name = "notifications"
|
||||
expected_message = """
|
||||
agent@example.com replied to [ticket #776](https://ghostfox.groovehq.com/groove_client/tickets/68667295):
|
||||
|
||||
``` quote
|
||||
Hello , This is a reply from an agent to a ticket
|
||||
```
|
||||
""".strip()
|
||||
|
||||
self.check_webhook(
|
||||
"agent_replied",
|
||||
expected_topic_name,
|
||||
expected_message,
|
||||
content_type="application/x-www-form-urlencoded",
|
||||
)
|
||||
|
||||
# This simulates the condition when a customer replied to a ticket.
|
||||
def test_groove_customer_replied(self) -> None:
|
||||
expected_topic_name = "notifications"
|
||||
expected_message = """
|
||||
rambo@example.com replied to [ticket #440](https://ghostfox.groovehq.com/groove_client/tickets/68666538):
|
||||
|
||||
``` quote
|
||||
Hello agent, thanks for getting back. This is how a reply from customer looks like.
|
||||
```
|
||||
""".strip()
|
||||
|
||||
self.check_webhook(
|
||||
"customer_replied",
|
||||
expected_topic_name,
|
||||
expected_message,
|
||||
content_type="application/x-www-form-urlencoded",
|
||||
)
|
||||
|
||||
# This simulates the condition when an agent left a note.
|
||||
def test_groove_note_added(self) -> None:
|
||||
expected_topic_name = "notifications"
|
||||
expected_message = """
|
||||
anotheragent@example.com left a note on [ticket #776](https://ghostfox.groovehq.com/groove_client/tickets/68667295):
|
||||
|
||||
``` quote
|
||||
This is a note added to a ticket
|
||||
```
|
||||
""".strip()
|
||||
|
||||
self.check_webhook(
|
||||
"note_added",
|
||||
expected_topic_name,
|
||||
expected_message,
|
||||
content_type="application/x-ww-form-urlencoded",
|
||||
)
|
||||
126
zerver/webhooks/groove/view.py
Normal file
126
zerver/webhooks/groove/view.py
Normal file
@@ -0,0 +1,126 @@
|
||||
# Webhooks for external integrations.
|
||||
from collections.abc import Callable
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import webhook_view
|
||||
from zerver.lib.exceptions import UnsupportedWebhookEventTypeError
|
||||
from zerver.lib.partial import partial
|
||||
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_none_or, check_string, check_url
|
||||
from zerver.lib.webhooks.common import (
|
||||
check_send_webhook_message,
|
||||
default_fixture_to_headers,
|
||||
get_event_header,
|
||||
)
|
||||
from zerver.models import UserProfile
|
||||
|
||||
TICKET_STARTED_TEMPLATE = """
|
||||
{customer_name} submitted new ticket [#{number}: {title}]({app_url}):
|
||||
|
||||
``` quote
|
||||
{summary}
|
||||
```
|
||||
""".strip()
|
||||
|
||||
TICKET_ASSIGNED_TEMPLATE = "[#{number}: {title}]({app_url}) ({state}) assigned to {assignee_info}."
|
||||
|
||||
AGENT_REPLIED_TEMPLATE = """
|
||||
{actor} {action} [ticket #{number}]({app_ticket_url}):
|
||||
|
||||
``` quote
|
||||
{plain_text_body}
|
||||
```
|
||||
""".strip()
|
||||
|
||||
|
||||
def ticket_started_body(payload: WildValue) -> str:
|
||||
return TICKET_STARTED_TEMPLATE.format(
|
||||
customer_name=payload["customer_name"].tame(check_string),
|
||||
number=payload["number"].tame(check_int),
|
||||
title=payload["title"].tame(check_string),
|
||||
app_url=payload["app_url"].tame(check_url),
|
||||
summary=payload["summary"].tame(check_string),
|
||||
)
|
||||
|
||||
|
||||
def ticket_assigned_body(payload: WildValue) -> str | None:
|
||||
state = payload["state"].tame(check_string)
|
||||
kwargs = {
|
||||
"state": "open" if state == "opened" else state,
|
||||
"number": payload["number"].tame(check_int),
|
||||
"title": payload["title"].tame(check_string),
|
||||
"app_url": payload["app_url"].tame(check_url),
|
||||
}
|
||||
|
||||
assignee = payload["assignee"].tame(check_none_or(check_string))
|
||||
assigned_group = payload["assigned_group"].tame(check_none_or(check_string))
|
||||
|
||||
if assignee or assigned_group:
|
||||
if assignee and assigned_group:
|
||||
kwargs["assignee_info"] = f"{assignee} from {assigned_group}"
|
||||
elif assignee:
|
||||
kwargs["assignee_info"] = f"{assignee}"
|
||||
elif assigned_group:
|
||||
kwargs["assignee_info"] = f"{assigned_group}"
|
||||
|
||||
return TICKET_ASSIGNED_TEMPLATE.format(**kwargs)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def replied_body(actor: str, action: str, payload: WildValue) -> str:
|
||||
actor_url = "http://api.groovehq.com/v1/{}/".format(actor + "s")
|
||||
actor = payload["links"]["author"]["href"].tame(check_url).split(actor_url)[1]
|
||||
number = (
|
||||
payload["links"]["ticket"]["href"]
|
||||
.tame(check_url)
|
||||
.split("http://api.groovehq.com/v1/tickets/")[1]
|
||||
)
|
||||
|
||||
body = AGENT_REPLIED_TEMPLATE.format(
|
||||
actor=actor,
|
||||
action=action,
|
||||
number=number,
|
||||
app_ticket_url=payload["app_ticket_url"].tame(check_url),
|
||||
plain_text_body=payload["plain_text_body"].tame(check_string),
|
||||
)
|
||||
|
||||
return body
|
||||
|
||||
|
||||
EVENTS_FUNCTION_MAPPER: dict[str, Callable[[WildValue], str | None]] = {
|
||||
"ticket_started": ticket_started_body,
|
||||
"ticket_assigned": ticket_assigned_body,
|
||||
"agent_replied": partial(replied_body, "agent", "replied to"),
|
||||
"customer_replied": partial(replied_body, "customer", "replied to"),
|
||||
"note_added": partial(replied_body, "agent", "left a note on"),
|
||||
}
|
||||
|
||||
ALL_EVENT_TYPES = list(EVENTS_FUNCTION_MAPPER.keys())
|
||||
|
||||
|
||||
@webhook_view("Groove", all_event_types=ALL_EVENT_TYPES)
|
||||
@typed_endpoint
|
||||
def api_groove_webhook(
|
||||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
*,
|
||||
payload: JsonBodyPayload[WildValue],
|
||||
) -> HttpResponse:
|
||||
event = get_event_header(request, "X-Groove-Event", "Groove")
|
||||
handler = EVENTS_FUNCTION_MAPPER.get(event)
|
||||
if handler is None:
|
||||
raise UnsupportedWebhookEventTypeError(event)
|
||||
|
||||
body = handler(payload)
|
||||
topic_name = "notifications"
|
||||
|
||||
if body is not None:
|
||||
check_send_webhook_message(request, user_profile, topic_name, body, event)
|
||||
|
||||
return json_success(request)
|
||||
|
||||
|
||||
fixture_to_headers = default_fixture_to_headers("HTTP_X_GROOVE_EVENT")
|
||||
Reference in New Issue
Block a user