integration: Add jotform integration.

Fixes #16554
This commit is contained in:
Gaurav Pandey 2020-10-22 00:26:33 +05:30 committed by Tim Abbott
parent 63eae63a07
commit 3d7462a0e7
9 changed files with 84 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -397,6 +397,7 @@ WEBHOOK_INTEGRATIONS: List[WebhookIntegration] = [
WebhookIntegration("insping", ["monitoring"], display_name="Insping"),
WebhookIntegration("intercom", ["customer-support"], display_name="Intercom"),
WebhookIntegration("jira", ["project-management"], display_name="JIRA"),
WebhookIntegration("jotform", ["misc"], display_name="Jotform"),
WebhookIntegration("librato", ["monitoring"]),
WebhookIntegration("mention", ["marketing"], display_name="Mention"),
WebhookIntegration("netlify", ["continuous-integration", "deployment"], display_name="Netlify"),
@ -689,6 +690,7 @@ DOC_SCREENSHOT_CONFIG: Dict[str, List[ScreenshotConfig]] = {
"insping": [ScreenshotConfig("website_state_available.json")],
"intercom": [ScreenshotConfig("conversation_admin_replied.json")],
"jira": [ScreenshotConfig("created_v1.json")],
"jotform": [ScreenshotConfig("response.json")],
"librato": [ScreenshotConfig("three_conditions_alert.json", payload_as_query_param=True)],
"mention": [ScreenshotConfig("webfeeds.json")],
"netlify": [ScreenshotConfig("deploy_building.json")],

View File

View File

@ -0,0 +1,17 @@
Get Zulip notifications for your JotForm responses!
1. {!create-stream.md!}
1. {!create-bot-construct-url-indented.md!}
By default, the integration will use the form's title as the topic.
1. In Jotform, go to **Form Builder**, and click on **Settings** tab.
1. Click on **INTEGRATIONS**, search for **WebHooks** and select it.
1. Add the above constructed **url** to the field, and click the
**COMPLETE INTEGRATION** button.
{!congrats.md!}
![](/static/images/integrations/jotform/001.png)

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,23 @@
from zerver.lib.test_classes import WebhookTestCase
class JotFormHookTests(WebhookTestCase):
STREAM_NAME = "test"
URL_TEMPLATE = "/api/v1/external/jotform?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "jotform"
def test_response(self) -> None:
expected_title = "Form"
expected_message = """
A new submission (ID 4791133489169827307) was received:
* Name:Gaurav Pandey
* Address:Lampgarden-street wolfsquare Bengaluru Karnataka 165578
* Signature:uploads/gauravguitarrocks/202944822449057/4791133489169827307/4791133489169827307_signature_4.png
""".strip()
self.check_webhook(
"response",
expected_title,
expected_message,
content_type="application/x-www-form-urlencoded",
)

View File

@ -0,0 +1,31 @@
# Webhooks for external integrations.
from typing import Any, Dict
from django.http import HttpRequest, HttpResponse
from zerver.decorator import webhook_view
from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile
@webhook_view("Jotform")
@has_request_variables
def api_jotform_webhook(
request: HttpRequest,
user_profile: UserProfile,
payload: Dict[str, Any] = REQ(argument_type="body"),
) -> HttpResponse:
topic = payload["formTitle"]
submission_id = payload["submissionID"]
fields_dict = list(payload["pretty"].split(", "))
form_response = f"A new submission (ID {submission_id}) was received:\n"
for field in fields_dict:
form_response += f"* {field}\n"
message = form_response.strip()
check_send_webhook_message(request, user_profile, topic, message)
return json_success()