From 2e78a56796b6cb1981cacc6f14c9c0f2e7febd7a Mon Sep 17 00:00:00 2001 From: Eeshan Garg Date: Sat, 2 Jun 2018 11:15:18 -0230 Subject: [PATCH] outgoing-webhooks.md: Add example payloads/fixtures. --- templates/zerver/api/fixtures.json | 40 +++++++++++++++++++++++ templates/zerver/api/outgoing-webhooks.md | 22 +++++++++++-- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/templates/zerver/api/fixtures.json b/templates/zerver/api/fixtures.json index 97de0bfce2..d1e1548dc1 100644 --- a/templates/zerver/api/fixtures.json +++ b/templates/zerver/api/fixtures.json @@ -331,5 +331,45 @@ "code": "BAD_REQUEST", "msg": "User not authorized for this query", "result": "error" + }, + "zulip-outgoing-webhook-payload": { + "data": "@**Outgoing Webhook Test** Zulip is the world\u2019s most productive group chat!", + "trigger": "mention", + "token": "xvOzfurIutdRRVLzpXrIIHXJvNfaJLJ0", + "message": { + "subject": "Verona2", + "sender_email": "iago@zulip.com", + "recipient_type": 2, + "timestamp": 1527876931, + "client": "website", + "submessages": [ + + ], + "recipient_id": 20, + "subject_links": [ + + ], + "sender_full_name": "Iago", + "sender_is_mirror_dummy": false, + "rendered_content": "

@Outgoing Webhook Test Zulip is the world\u2019s most productive group chat!

", + "sender_avatar_source": "G", + "sender_id": 5, + "stream_id": 5, + "content": "@**Outgoing Webhook Test** Zulip is the world\u2019s most productive group chat!", + "sender_realm_id": 1, + "sender_avatar_version": 1, + "display_recipient": "Verona", + "type": "stream", + "id": 112, + "is_me_message": false, + "reactions": [ + + ], + "sender_realm_str": "zulip", + "raw_display_recipient": "Verona", + "sender_short_name": "iago", + "recipient_type_id": 5 + }, + "bot_email": "outgoing-bot@localhost" } } diff --git a/templates/zerver/api/outgoing-webhooks.md b/templates/zerver/api/outgoing-webhooks.md index cd4a2c5514..3bafa594f1 100644 --- a/templates/zerver/api/outgoing-webhooks.md +++ b/templates/zerver/api/outgoing-webhooks.md @@ -69,6 +69,10 @@ A correctly implemented endpoint will do the following: * For a failed request, the endpoint should return data on the error. +### Example payload + +{generate_code_example|zulip-outgoing-webhook-payload|fixture} + ## Slack-format webhook format This interface translates the Zulip's outgoing webhook's request into @@ -91,11 +95,23 @@ trigger_word: trigger method service_id: id of bot user ``` -The above data is posted as list of tuples (not JSON). +The above data is posted as list of tuples (not JSON), here's an example: + +``` +[('token', 'abcdef'), + ('team_id', 'zulip'), + ('team_domain', 'zulip.com'), + ('channel_id', '123'), + ('channel_name', 'integrations'), + ('timestamp', 123456), + ('user_id', 21), + ('user_name', 'Sample User'), + ('text', '@**test**'), + ('trigger_word', 'mention'), + ('service_id', None)] +``` * For successful request, if data is returned, it returns that data, else it returns a blank response. * For failed request, it returns the reason of failure, as returned by the server, or the exception message. - -