mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	webhooks/intercom: Implement support for all events.
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 341 KiB After Width: | Height: | Size: 47 KiB  | 
@@ -1,32 +1,19 @@
 | 
			
		||||
{!create-stream.md!}
 | 
			
		||||
Get Intercom notifications in Zulip!
 | 
			
		||||
 | 
			
		||||
{!create-bot-construct-url.md!}
 | 
			
		||||
1. {!create-stream.md!}
 | 
			
		||||
 | 
			
		||||
Intercom will use the `intercom` stream by default if no stream is given
 | 
			
		||||
in the URL. Make sure the selected stream exists in Zulip.
 | 
			
		||||
1. {!create-bot-construct-url-indented.md!}
 | 
			
		||||
 | 
			
		||||
**Follow these steps:**
 | 
			
		||||
1. Go to your Intercom account's **Settings** page and click on **Developers**
 | 
			
		||||
   on the left sidebar. Click on **Developer Hub** and click **New app**.
 | 
			
		||||
 | 
			
		||||
1. Go to the Integrations Page of your Intercom Console.
 | 
			
		||||
1. Set **App name** to a name of your choice, such as `Zulip Webhook`. Set
 | 
			
		||||
   **Workspace** to the Intercom workspace of your choice, and click
 | 
			
		||||
   **Create app**.
 | 
			
		||||
 | 
			
		||||
2. Find and select the `Zapier` integration option.
 | 
			
		||||
 | 
			
		||||
3. Create an account on `Zapier` if you haven't
 | 
			
		||||
already. Click on **Explore Intercom on Zapier!**.
 | 
			
		||||
 | 
			
		||||
4. Select **Make A ZAP**. Choose `Intercom `in the apps section and
 | 
			
		||||
`Webhooks` in the built-in apps section.
 | 
			
		||||
 | 
			
		||||
5. Authenticate with your Intercom account to connect it with
 | 
			
		||||
`Zapier`.
 | 
			
		||||
 | 
			
		||||
6. Select the actions which will trigger the webhook.
 | 
			
		||||
 | 
			
		||||
7. Select **POST** on the page that says **Webhooks by Zapier Action**, and
 | 
			
		||||
click **Continue**.
 | 
			
		||||
 | 
			
		||||
8. In the **URL** field, enter the URL constructed above. Select `JSON`
 | 
			
		||||
for **Payload Type** and click **Continue**:
 | 
			
		||||
1. Click on **Webhooks** on the left sidebar. Set **Your request endpoint URL**
 | 
			
		||||
   to the URL constructed above. Select the topics you'd like to be notified
 | 
			
		||||
   about, and click **Save**.
 | 
			
		||||
 | 
			
		||||
{!congrats.md!}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										33
									
								
								zerver/webhooks/intercom/fixtures/company_created.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								zerver/webhooks/intercom/fixtures/company_created.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "company",
 | 
			
		||||
            "id": "5c96b2c0d1c4c1a2d455b937",
 | 
			
		||||
            "company_id": "5c96b2c0d1c4c1a2d455b936-qualification-company",
 | 
			
		||||
            "app_id": "i6wc9ipe",
 | 
			
		||||
            "name": "Kandra Labs",
 | 
			
		||||
            "plan_id": null,
 | 
			
		||||
            "remote_created_at": null,
 | 
			
		||||
            "created_at": "2019-03-23T22:27:12.078Z",
 | 
			
		||||
            "updated_at": "2019-03-23T22:27:12.147Z",
 | 
			
		||||
            "last_request_at": "2019-03-23T22:20:52.453Z",
 | 
			
		||||
            "monthly_spend": 0,
 | 
			
		||||
            "session_count": 0,
 | 
			
		||||
            "user_count": 1,
 | 
			
		||||
            "tag_ids": [],
 | 
			
		||||
            "custom_attributes": {}
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_1126b848-48b0-4bbb-8106-3df9d42f1a90",
 | 
			
		||||
    "topic": "company.created",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553380032,
 | 
			
		||||
    "created_at": 1553380032,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										78
									
								
								zerver/webhooks/intercom/fixtures/contact_added_email.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								zerver/webhooks/intercom/fixtures/contact_added_email.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,78 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "contact",
 | 
			
		||||
            "id": "5c96b122177026171b401e20",
 | 
			
		||||
            "user_id": "8f9ef493-c5f9-4817-895d-874c3704ea49",
 | 
			
		||||
            "anonymous": true,
 | 
			
		||||
            "email": "jerryguitarist@gmail.com",
 | 
			
		||||
            "phone": null,
 | 
			
		||||
            "name": null,
 | 
			
		||||
            "pseudonym": "Azure Bus from St. John's",
 | 
			
		||||
            "avatar": {
 | 
			
		||||
                "type": "avatar",
 | 
			
		||||
                "image_url": null
 | 
			
		||||
            },
 | 
			
		||||
            "app_id": "i6wc9ipe",
 | 
			
		||||
            "companies": {
 | 
			
		||||
                "type": "company.list",
 | 
			
		||||
                "companies": []
 | 
			
		||||
            },
 | 
			
		||||
            "location_data": {
 | 
			
		||||
                "type": "location_data",
 | 
			
		||||
                "city_name": "St. John's",
 | 
			
		||||
                "continent_code": "NA",
 | 
			
		||||
                "country_name": "Canada",
 | 
			
		||||
                "postal_code": "A1B",
 | 
			
		||||
                "region_name": "Newfoundland and Labrador",
 | 
			
		||||
                "timezone": "America/St_Johns",
 | 
			
		||||
                "country_code": "CAN",
 | 
			
		||||
                "latitude": null,
 | 
			
		||||
                "longitude": null
 | 
			
		||||
            },
 | 
			
		||||
            "last_request_at": "2019-03-23T22:20:52.453+00:00",
 | 
			
		||||
            "created_at": "2019-03-23T22:20:18.253+00:00",
 | 
			
		||||
            "remote_created_at": null,
 | 
			
		||||
            "signed_up_at": null,
 | 
			
		||||
            "updated_at": "2019-03-23T22:21:46.437+00:00",
 | 
			
		||||
            "session_count": 0,
 | 
			
		||||
            "social_profiles": {
 | 
			
		||||
                "type": "social_profile.list",
 | 
			
		||||
                "social_profiles": []
 | 
			
		||||
            },
 | 
			
		||||
            "unsubscribed_from_emails": false,
 | 
			
		||||
            "marked_email_as_spam": false,
 | 
			
		||||
            "has_hard_bounced": false,
 | 
			
		||||
            "tags": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "segments": {
 | 
			
		||||
                "type": "segment.list",
 | 
			
		||||
                "segments": []
 | 
			
		||||
            },
 | 
			
		||||
            "custom_attributes": {},
 | 
			
		||||
            "referrer": null,
 | 
			
		||||
            "utm_campaign": null,
 | 
			
		||||
            "utm_content": null,
 | 
			
		||||
            "utm_medium": null,
 | 
			
		||||
            "utm_source": null,
 | 
			
		||||
            "utm_term": null,
 | 
			
		||||
            "do_not_track": null,
 | 
			
		||||
            "last_seen_ip": null,
 | 
			
		||||
            "user_agent_data": null
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_0cdd6657-8227-439f-899e-957646831785",
 | 
			
		||||
    "topic": "contact.added_email",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553379706,
 | 
			
		||||
    "created_at": 1553379706,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										78
									
								
								zerver/webhooks/intercom/fixtures/contact_created.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								zerver/webhooks/intercom/fixtures/contact_created.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,78 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "contact",
 | 
			
		||||
            "id": "5c96b122177026171b401e20",
 | 
			
		||||
            "user_id": "8f9ef493-c5f9-4817-895d-874c3704ea49",
 | 
			
		||||
            "anonymous": true,
 | 
			
		||||
            "email": "aaron@zulip.com",
 | 
			
		||||
            "phone": null,
 | 
			
		||||
            "name": null,
 | 
			
		||||
            "pseudonym": "Azure Bus from St. John's",
 | 
			
		||||
            "avatar": {
 | 
			
		||||
                "type": "avatar",
 | 
			
		||||
                "image_url": "https://static.intercomassets.com/app/pseudonym_avatars_2019/azure-bus.png"
 | 
			
		||||
            },
 | 
			
		||||
            "app_id": "i6wc9ipe",
 | 
			
		||||
            "companies": {
 | 
			
		||||
                "type": "company.list",
 | 
			
		||||
                "companies": []
 | 
			
		||||
            },
 | 
			
		||||
            "location_data": {
 | 
			
		||||
                "type": "location_data",
 | 
			
		||||
                "city_name": "St. John's",
 | 
			
		||||
                "continent_code": "NA",
 | 
			
		||||
                "country_name": "Canada",
 | 
			
		||||
                "postal_code": "A1B",
 | 
			
		||||
                "region_name": "Newfoundland and Labrador",
 | 
			
		||||
                "timezone": "America/St_Johns",
 | 
			
		||||
                "country_code": "CAN",
 | 
			
		||||
                "latitude": null,
 | 
			
		||||
                "longitude": null
 | 
			
		||||
            },
 | 
			
		||||
            "last_request_at": "2019-03-23T22:20:52.453+00:00",
 | 
			
		||||
            "created_at": "2019-03-23T22:20:18.253+00:00",
 | 
			
		||||
            "remote_created_at": null,
 | 
			
		||||
            "signed_up_at": null,
 | 
			
		||||
            "updated_at": "2019-03-23T22:20:52.000Z",
 | 
			
		||||
            "session_count": 0,
 | 
			
		||||
            "social_profiles": {
 | 
			
		||||
                "type": "social_profile.list",
 | 
			
		||||
                "social_profiles": []
 | 
			
		||||
            },
 | 
			
		||||
            "unsubscribed_from_emails": false,
 | 
			
		||||
            "marked_email_as_spam": false,
 | 
			
		||||
            "has_hard_bounced": false,
 | 
			
		||||
            "tags": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "segments": {
 | 
			
		||||
                "type": "segment.list",
 | 
			
		||||
                "segments": []
 | 
			
		||||
            },
 | 
			
		||||
            "custom_attributes": {},
 | 
			
		||||
            "referrer": null,
 | 
			
		||||
            "utm_campaign": null,
 | 
			
		||||
            "utm_content": null,
 | 
			
		||||
            "utm_medium": null,
 | 
			
		||||
            "utm_source": null,
 | 
			
		||||
            "utm_term": null,
 | 
			
		||||
            "do_not_track": null,
 | 
			
		||||
            "last_seen_ip": null,
 | 
			
		||||
            "user_agent_data": null
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_dc69e41e-58c6-49d0-8d36-69669db7fc67",
 | 
			
		||||
    "topic": "contact.created",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553379652,
 | 
			
		||||
    "created_at": 1553379652,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										92
									
								
								zerver/webhooks/intercom/fixtures/contact_signed_up.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								zerver/webhooks/intercom/fixtures/contact_signed_up.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,92 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "user",
 | 
			
		||||
            "id": "5c96bcd732ba0a1531c0264c",
 | 
			
		||||
            "user_id": null,
 | 
			
		||||
            "anonymous": false,
 | 
			
		||||
            "email": "iago@zulip.com",
 | 
			
		||||
            "phone": null,
 | 
			
		||||
            "name": null,
 | 
			
		||||
            "pseudonym": "Lilac Raindrop from St. John's",
 | 
			
		||||
            "avatar": {
 | 
			
		||||
                "type": "avatar",
 | 
			
		||||
                "image_url": null
 | 
			
		||||
            },
 | 
			
		||||
            "app_id": "i6wc9ipe",
 | 
			
		||||
            "companies": {
 | 
			
		||||
                "type": "company.list",
 | 
			
		||||
                "companies": []
 | 
			
		||||
            },
 | 
			
		||||
            "location_data": {
 | 
			
		||||
                "type": "location_data",
 | 
			
		||||
                "city_name": "St. John's",
 | 
			
		||||
                "continent_code": "NA",
 | 
			
		||||
                "country_name": "Canada",
 | 
			
		||||
                "postal_code": "A1B",
 | 
			
		||||
                "region_name": "Newfoundland and Labrador",
 | 
			
		||||
                "timezone": "America/St_Johns",
 | 
			
		||||
                "country_code": "CAN",
 | 
			
		||||
                "latitude": null,
 | 
			
		||||
                "longitude": null
 | 
			
		||||
            },
 | 
			
		||||
            "last_request_at": "2019-03-23T23:14:41.517+00:00",
 | 
			
		||||
            "created_at": "2019-03-23T23:10:15.062+00:00",
 | 
			
		||||
            "remote_created_at": "2019-03-26T23:04:14.500+00:00",
 | 
			
		||||
            "signed_up_at": "2019-03-26T23:04:14.500+00:00",
 | 
			
		||||
            "updated_at": "2019-03-26T23:04:14.634+00:00",
 | 
			
		||||
            "session_count": 0,
 | 
			
		||||
            "social_profiles": {
 | 
			
		||||
                "type": "social_profile.list",
 | 
			
		||||
                "social_profiles": []
 | 
			
		||||
            },
 | 
			
		||||
            "unsubscribed_from_emails": false,
 | 
			
		||||
            "marked_email_as_spam": false,
 | 
			
		||||
            "has_hard_bounced": false,
 | 
			
		||||
            "tags": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "type": "tag",
 | 
			
		||||
                        "id": "2525085"
 | 
			
		||||
                    }
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "segments": {
 | 
			
		||||
                "type": "segment.list",
 | 
			
		||||
                "segments": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "type": "segment",
 | 
			
		||||
                        "id": "5ac7ad3ed9cd4bd75b1575e0"
 | 
			
		||||
                    },
 | 
			
		||||
                    {
 | 
			
		||||
                        "type": "segment",
 | 
			
		||||
                        "id": "5ac7ad3ed9cd4bd75b1575e1"
 | 
			
		||||
                    }
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "custom_attributes": {},
 | 
			
		||||
            "referrer": "http://localhost:9991/devlogin/",
 | 
			
		||||
            "utm_campaign": null,
 | 
			
		||||
            "utm_content": null,
 | 
			
		||||
            "utm_medium": null,
 | 
			
		||||
            "utm_source": null,
 | 
			
		||||
            "utm_term": null,
 | 
			
		||||
            "do_not_track": null,
 | 
			
		||||
            "last_seen_ip": null,
 | 
			
		||||
            "user_agent_data": null
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_ed7d1f52-8a8e-4389-b715-ab7d5c027354",
 | 
			
		||||
    "topic": "contact.signed_up",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553641454,
 | 
			
		||||
    "created_at": 1553641454,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										113
									
								
								zerver/webhooks/intercom/fixtures/contact_tag_created.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								zerver/webhooks/intercom/fixtures/contact_tag_created.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,113 @@
 | 
			
		||||
{
 | 
			
		||||
    "type":"notification_event",
 | 
			
		||||
    "app_id":"i6wc9ipe",
 | 
			
		||||
    "data":{
 | 
			
		||||
        "type":"notification_event_data",
 | 
			
		||||
        "item":{
 | 
			
		||||
            "type":"contact_tag",
 | 
			
		||||
            "created_at":1553291522,
 | 
			
		||||
            "tag":{
 | 
			
		||||
                "type":"tag",
 | 
			
		||||
                "id":"2525085",
 | 
			
		||||
                "name":"developer"
 | 
			
		||||
            },
 | 
			
		||||
            "contact":{
 | 
			
		||||
                "type":"contact",
 | 
			
		||||
                "id":"5c9553cb27e377f24eed49f7",
 | 
			
		||||
                "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
 | 
			
		||||
                "anonymous":true,
 | 
			
		||||
                "email":"jerryguitarist@gmail.com",
 | 
			
		||||
                "phone":"+17093452342",
 | 
			
		||||
                "name":"Eeshan Garg",
 | 
			
		||||
                "pseudonym":"Rose Poodle from St. John's",
 | 
			
		||||
                "avatar":{
 | 
			
		||||
                    "type":"avatar",
 | 
			
		||||
                    "image_url":"https://img.fullcontact.com/static/85ce413bcdac4cec3cfdb3a8da530f8b_8a853b478c3122d7e4ec9e14f81d9a3d9ea9da198d85c1985efc2403fa6bdb0c"
 | 
			
		||||
                },
 | 
			
		||||
                "app_id":"i6wc9ipe",
 | 
			
		||||
                "companies":{
 | 
			
		||||
                    "type":"company.list",
 | 
			
		||||
                    "companies":[
 | 
			
		||||
                        {
 | 
			
		||||
                            "type":"company",
 | 
			
		||||
                            "company_id":"5c9555b50af2951cc897b79a-qualification-company",
 | 
			
		||||
                            "id":"5c9555b50af2951cc897b79b",
 | 
			
		||||
                            "name":"Kandra Labs"
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                "location_data":{
 | 
			
		||||
                    "type":"location_data",
 | 
			
		||||
                    "city_name":"St. John's",
 | 
			
		||||
                    "continent_code":"NA",
 | 
			
		||||
                    "country_name":"Canada",
 | 
			
		||||
                    "postal_code":"A1B",
 | 
			
		||||
                    "region_name":"Newfoundland and Labrador",
 | 
			
		||||
                    "timezone":"America/St_Johns",
 | 
			
		||||
                    "country_code":"CAN",
 | 
			
		||||
                    "latitude":null,
 | 
			
		||||
                    "longitude":null
 | 
			
		||||
                },
 | 
			
		||||
                "last_request_at":"2019-03-22T21:42:36.634+00:00",
 | 
			
		||||
                "created_at":"2019-03-22T21:29:47.980+00:00",
 | 
			
		||||
                "remote_created_at":null,
 | 
			
		||||
                "signed_up_at":null,
 | 
			
		||||
                "updated_at":"2019-03-22T21:52:02.210+00:00",
 | 
			
		||||
                "session_count":0,
 | 
			
		||||
                "social_profiles":{
 | 
			
		||||
                    "type":"social_profile.list",
 | 
			
		||||
                    "social_profiles":[
 | 
			
		||||
                        {
 | 
			
		||||
                            "type":"social_profile",
 | 
			
		||||
                            "name":"github",
 | 
			
		||||
                            "id":null,
 | 
			
		||||
                            "username":"eeshangarg",
 | 
			
		||||
                            "url":"https://github.com/eeshangarg"
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                "unsubscribed_from_emails":false,
 | 
			
		||||
                "marked_email_as_spam":false,
 | 
			
		||||
                "has_hard_bounced":false,
 | 
			
		||||
                "tags":{
 | 
			
		||||
                    "type":"tag.list",
 | 
			
		||||
                    "tags":[
 | 
			
		||||
                        {
 | 
			
		||||
                            "type":"tag",
 | 
			
		||||
                            "id":"2525085"
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                "segments":{
 | 
			
		||||
                    "type":"segment.list",
 | 
			
		||||
                    "segments":[
 | 
			
		||||
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                "custom_attributes":{
 | 
			
		||||
 | 
			
		||||
                },
 | 
			
		||||
                "referrer":null,
 | 
			
		||||
                "utm_campaign":null,
 | 
			
		||||
                "utm_content":null,
 | 
			
		||||
                "utm_medium":null,
 | 
			
		||||
                "utm_source":null,
 | 
			
		||||
                "utm_term":null,
 | 
			
		||||
                "do_not_track":null,
 | 
			
		||||
                "last_seen_ip":null,
 | 
			
		||||
                "user_agent_data":null
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links":{
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
    "id":"notif_cac9735a-d7a1-4425-8b8b-c45cdf915892",
 | 
			
		||||
    "topic":"contact.tag.created",
 | 
			
		||||
    "delivery_status":"pending",
 | 
			
		||||
    "delivery_attempts":1,
 | 
			
		||||
    "delivered_at":0,
 | 
			
		||||
    "first_sent_at":1553291522,
 | 
			
		||||
    "created_at":1553291522,
 | 
			
		||||
    "self":null
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										110
									
								
								zerver/webhooks/intercom/fixtures/contact_tag_deleted.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								zerver/webhooks/intercom/fixtures/contact_tag_deleted.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,110 @@
 | 
			
		||||
{
 | 
			
		||||
    "type":"notification_event",
 | 
			
		||||
    "app_id":"i6wc9ipe",
 | 
			
		||||
    "data":{
 | 
			
		||||
        "type":"notification_event_data",
 | 
			
		||||
        "item":{
 | 
			
		||||
            "type":"contact_tag",
 | 
			
		||||
            "created_at":1553291644,
 | 
			
		||||
            "tag":{
 | 
			
		||||
                "type":"tag",
 | 
			
		||||
                "id":"2525085",
 | 
			
		||||
                "name":"developer"
 | 
			
		||||
            },
 | 
			
		||||
            "contact":{
 | 
			
		||||
                "type":"contact",
 | 
			
		||||
                "id":"5c9553cb27e377f24eed49f7",
 | 
			
		||||
                "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
 | 
			
		||||
                "anonymous":true,
 | 
			
		||||
                "email":"jerryguitarist@gmail.com",
 | 
			
		||||
                "phone":"+17093452342",
 | 
			
		||||
                "name":"Eeshan Garg",
 | 
			
		||||
                "pseudonym":"Rose Poodle from St. John's",
 | 
			
		||||
                "avatar":{
 | 
			
		||||
                    "type":"avatar",
 | 
			
		||||
                    "image_url":"https://img.fullcontact.com/static/85ce413bcdac4cec3cfdb3a8da530f8b_8a853b478c3122d7e4ec9e14f81d9a3d9ea9da198d85c1985efc2403fa6bdb0c"
 | 
			
		||||
                },
 | 
			
		||||
                "app_id":"i6wc9ipe",
 | 
			
		||||
                "companies":{
 | 
			
		||||
                    "type":"company.list",
 | 
			
		||||
                    "companies":[
 | 
			
		||||
                        {
 | 
			
		||||
                            "type":"company",
 | 
			
		||||
                            "company_id":"5c9555b50af2951cc897b79a-qualification-company",
 | 
			
		||||
                            "id":"5c9555b50af2951cc897b79b",
 | 
			
		||||
                            "name":"Kandra Labs"
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                "location_data":{
 | 
			
		||||
                    "type":"location_data",
 | 
			
		||||
                    "city_name":"St. John's",
 | 
			
		||||
                    "continent_code":"NA",
 | 
			
		||||
                    "country_name":"Canada",
 | 
			
		||||
                    "postal_code":"A1B",
 | 
			
		||||
                    "region_name":"Newfoundland and Labrador",
 | 
			
		||||
                    "timezone":"America/St_Johns",
 | 
			
		||||
                    "country_code":"CAN",
 | 
			
		||||
                    "latitude":null,
 | 
			
		||||
                    "longitude":null
 | 
			
		||||
                },
 | 
			
		||||
                "last_request_at":"2019-03-22T21:42:36.634+00:00",
 | 
			
		||||
                "created_at":"2019-03-22T21:29:47.980+00:00",
 | 
			
		||||
                "remote_created_at":null,
 | 
			
		||||
                "signed_up_at":null,
 | 
			
		||||
                "updated_at":"2019-03-22T21:54:04.618+00:00",
 | 
			
		||||
                "session_count":0,
 | 
			
		||||
                "social_profiles":{
 | 
			
		||||
                    "type":"social_profile.list",
 | 
			
		||||
                    "social_profiles":[
 | 
			
		||||
                        {
 | 
			
		||||
                            "type":"social_profile",
 | 
			
		||||
                            "name":"github",
 | 
			
		||||
                            "id":null,
 | 
			
		||||
                            "username":"eeshangarg",
 | 
			
		||||
                            "url":"https://github.com/eeshangarg"
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                "unsubscribed_from_emails":false,
 | 
			
		||||
                "marked_email_as_spam":false,
 | 
			
		||||
                "has_hard_bounced":false,
 | 
			
		||||
                "tags":{
 | 
			
		||||
                    "type":"tag.list",
 | 
			
		||||
                    "tags":[
 | 
			
		||||
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                "segments":{
 | 
			
		||||
                    "type":"segment.list",
 | 
			
		||||
                    "segments":[
 | 
			
		||||
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                "custom_attributes":{
 | 
			
		||||
 | 
			
		||||
                },
 | 
			
		||||
                "referrer":null,
 | 
			
		||||
                "utm_campaign":null,
 | 
			
		||||
                "utm_content":null,
 | 
			
		||||
                "utm_medium":null,
 | 
			
		||||
                "utm_source":null,
 | 
			
		||||
                "utm_term":null,
 | 
			
		||||
                "do_not_track":null,
 | 
			
		||||
                "last_seen_ip":null,
 | 
			
		||||
                "user_agent_data":null
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links":{
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
    "id":"notif_5cecbde1-e2f4-46dc-8f6a-378ddd22b1f7",
 | 
			
		||||
    "topic":"contact.tag.deleted",
 | 
			
		||||
    "delivery_status":"pending",
 | 
			
		||||
    "delivery_attempts":1,
 | 
			
		||||
    "delivered_at":0,
 | 
			
		||||
    "first_sent_at":1553291644,
 | 
			
		||||
    "created_at":1553291644,
 | 
			
		||||
    "self":null
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,103 @@
 | 
			
		||||
{
 | 
			
		||||
    "type":"notification_event",
 | 
			
		||||
    "app_id":"i6wc9ipe",
 | 
			
		||||
    "data":{
 | 
			
		||||
        "type":"notification_event_data",
 | 
			
		||||
        "item":{
 | 
			
		||||
            "type":"conversation",
 | 
			
		||||
            "id":"21322009097",
 | 
			
		||||
            "created_at":1553290933,
 | 
			
		||||
            "updated_at":1553291111,
 | 
			
		||||
            "user":{
 | 
			
		||||
                "type":"lead",
 | 
			
		||||
                "id":"5c9553cb27e377f24eed49f7",
 | 
			
		||||
                "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
 | 
			
		||||
                "name":"Eeshan Garg",
 | 
			
		||||
                "email":"jerryguitarist@gmail.com",
 | 
			
		||||
                "do_not_track":null
 | 
			
		||||
            },
 | 
			
		||||
            "assignee":{
 | 
			
		||||
                "type":"admin",
 | 
			
		||||
                "id":"1957471",
 | 
			
		||||
                "name":"Tim Abbott",
 | 
			
		||||
                "email":"tim@zulip.com"
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_message":{
 | 
			
		||||
                "type":"conversation_message",
 | 
			
		||||
                "id":"331499307",
 | 
			
		||||
                "url":"http://localhost:9991/api/",
 | 
			
		||||
                "subject":"",
 | 
			
		||||
                "body":"<p>Hello</p>",
 | 
			
		||||
                "author":{
 | 
			
		||||
                    "type":"user",
 | 
			
		||||
                    "id":"5c9553cb27e377f24eed49f7"
 | 
			
		||||
                },
 | 
			
		||||
                "attachments":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_parts":{
 | 
			
		||||
                "type":"conversation_part.list",
 | 
			
		||||
                "conversation_parts":[
 | 
			
		||||
                    {
 | 
			
		||||
                        "type":"conversation_part",
 | 
			
		||||
                        "id":"2824382500",
 | 
			
		||||
                        "part_type":"assignment",
 | 
			
		||||
                        "body":"<p>Hey Eeshan! How can I help?</p>",
 | 
			
		||||
                        "created_at":1553291111,
 | 
			
		||||
                        "updated_at":1553291111,
 | 
			
		||||
                        "notified_at":1553291111,
 | 
			
		||||
                        "assigned_to":{
 | 
			
		||||
                            "type":"admin",
 | 
			
		||||
                            "id":"1957471",
 | 
			
		||||
                            "name":"Eeshan Garg"
 | 
			
		||||
                        },
 | 
			
		||||
                        "author":{
 | 
			
		||||
                            "type":"admin",
 | 
			
		||||
                            "id":"1957471",
 | 
			
		||||
                            "name":"Eeshan Garg"
 | 
			
		||||
                        },
 | 
			
		||||
                        "attachments":[
 | 
			
		||||
 | 
			
		||||
                        ],
 | 
			
		||||
                        "external_id":null
 | 
			
		||||
                    }
 | 
			
		||||
                ],
 | 
			
		||||
                "total_count":1
 | 
			
		||||
            },
 | 
			
		||||
            "open":true,
 | 
			
		||||
            "state":"open",
 | 
			
		||||
            "snoozed_until":null,
 | 
			
		||||
            "read":false,
 | 
			
		||||
            "metadata":{
 | 
			
		||||
 | 
			
		||||
            },
 | 
			
		||||
            "tags":{
 | 
			
		||||
                "type":"tag.list",
 | 
			
		||||
                "tags":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "tags_added":{
 | 
			
		||||
                "type":"tag.list",
 | 
			
		||||
                "tags":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "links":{
 | 
			
		||||
                "conversation_web":"https://app.intercom.io/a/apps/i6wc9ipe/conversations/21322009097"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links":{
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
    "id":"notif_b577ea09-0998-45cf-ade1-df4d102a58ec",
 | 
			
		||||
    "topic":"conversation.admin.assigned",
 | 
			
		||||
    "delivery_status":"pending",
 | 
			
		||||
    "delivery_attempts":1,
 | 
			
		||||
    "delivered_at":0,
 | 
			
		||||
    "first_sent_at":1553291112,
 | 
			
		||||
    "created_at":1553291112,
 | 
			
		||||
    "self":null
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,99 @@
 | 
			
		||||
{
 | 
			
		||||
    "type":"notification_event",
 | 
			
		||||
    "app_id":"i6wc9ipe",
 | 
			
		||||
    "data":{
 | 
			
		||||
        "type":"notification_event_data",
 | 
			
		||||
        "item":{
 | 
			
		||||
            "type":"conversation",
 | 
			
		||||
            "id":"21322009097",
 | 
			
		||||
            "created_at":1553290933,
 | 
			
		||||
            "updated_at":1553291389,
 | 
			
		||||
            "user":{
 | 
			
		||||
                "type":"lead",
 | 
			
		||||
                "id":"5c9553cb27e377f24eed49f7",
 | 
			
		||||
                "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
 | 
			
		||||
                "name":"Eeshan Garg",
 | 
			
		||||
                "email":"jerryguitarist@gmail.com",
 | 
			
		||||
                "do_not_track":null
 | 
			
		||||
            },
 | 
			
		||||
            "assignee":{
 | 
			
		||||
                "type":"admin",
 | 
			
		||||
                "id":"1957471",
 | 
			
		||||
                "name":"Cordelia Lear",
 | 
			
		||||
                "email":"cordelia@zulip.com"
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_message":{
 | 
			
		||||
                "type":"conversation_message",
 | 
			
		||||
                "id":"331499307",
 | 
			
		||||
                "url":"http://localhost:9991/api/",
 | 
			
		||||
                "subject":"",
 | 
			
		||||
                "body":"<p>Hello</p>",
 | 
			
		||||
                "author":{
 | 
			
		||||
                    "type":"user",
 | 
			
		||||
                    "id":"5c9553cb27e377f24eed49f7"
 | 
			
		||||
                },
 | 
			
		||||
                "attachments":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_parts":{
 | 
			
		||||
                "type":"conversation_part.list",
 | 
			
		||||
                "conversation_parts":[
 | 
			
		||||
                    {
 | 
			
		||||
                        "type":"conversation_part",
 | 
			
		||||
                        "id":"2824395628",
 | 
			
		||||
                        "part_type":"close",
 | 
			
		||||
                        "body":null,
 | 
			
		||||
                        "created_at":1553291389,
 | 
			
		||||
                        "updated_at":1553291389,
 | 
			
		||||
                        "notified_at":1553291389,
 | 
			
		||||
                        "assigned_to":null,
 | 
			
		||||
                        "author":{
 | 
			
		||||
                            "type":"admin",
 | 
			
		||||
                            "id":"1957471",
 | 
			
		||||
                            "name":"Eeshan Garg"
 | 
			
		||||
                        },
 | 
			
		||||
                        "attachments":[
 | 
			
		||||
 | 
			
		||||
                        ],
 | 
			
		||||
                        "external_id":null
 | 
			
		||||
                    }
 | 
			
		||||
                ],
 | 
			
		||||
                "total_count":1
 | 
			
		||||
            },
 | 
			
		||||
            "open":false,
 | 
			
		||||
            "state":"closed",
 | 
			
		||||
            "snoozed_until":null,
 | 
			
		||||
            "read":true,
 | 
			
		||||
            "metadata":{
 | 
			
		||||
 | 
			
		||||
            },
 | 
			
		||||
            "tags":{
 | 
			
		||||
                "type":"tag.list",
 | 
			
		||||
                "tags":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "tags_added":{
 | 
			
		||||
                "type":"tag.list",
 | 
			
		||||
                "tags":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "links":{
 | 
			
		||||
                "conversation_web":"https://app.intercom.io/a/apps/i6wc9ipe/conversations/21322009097"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links":{
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
    "id":"notif_2bc4bf3a-0064-4fb0-9e17-dc44d91bcb9b",
 | 
			
		||||
    "topic":"conversation.admin.closed",
 | 
			
		||||
    "delivery_status":"pending",
 | 
			
		||||
    "delivery_attempts":1,
 | 
			
		||||
    "delivered_at":0,
 | 
			
		||||
    "first_sent_at":1553291390,
 | 
			
		||||
    "created_at":1553291390,
 | 
			
		||||
    "self":null
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,87 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "conversation",
 | 
			
		||||
            "id": "21330067382",
 | 
			
		||||
            "created_at": 1553378082,
 | 
			
		||||
            "updated_at": 1553378536,
 | 
			
		||||
            "user": {
 | 
			
		||||
                "type": "lead",
 | 
			
		||||
                "id": "5c9553cb27e377f24eed49f7",
 | 
			
		||||
                "user_id": "75067020-1204-495c-8edc-abb7d88bdd43",
 | 
			
		||||
                "name": "Eeshan Garg",
 | 
			
		||||
                "email": "jerryguitarist@gmail.com",
 | 
			
		||||
                "do_not_track": null
 | 
			
		||||
            },
 | 
			
		||||
            "assignee": {
 | 
			
		||||
                "type": "admin",
 | 
			
		||||
                "id": "1957471",
 | 
			
		||||
                "name": "Cordelia Lear",
 | 
			
		||||
                "email": "cordelia@zulip.com"
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_message": {
 | 
			
		||||
                "type": "conversation_message",
 | 
			
		||||
                "id": "331786931",
 | 
			
		||||
                "url": "http://localhost:9991/api/",
 | 
			
		||||
                "subject": "",
 | 
			
		||||
                "body": "<p>Hey! I'd like to set up a new account</p>",
 | 
			
		||||
                "author": {
 | 
			
		||||
                    "type": "user",
 | 
			
		||||
                    "id": "5c9553cb27e377f24eed49f7"
 | 
			
		||||
                },
 | 
			
		||||
                "attachments": []
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_parts": {
 | 
			
		||||
                "type": "conversation_part.list",
 | 
			
		||||
                "conversation_parts": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "type": "conversation_part",
 | 
			
		||||
                        "id": "2826904904",
 | 
			
		||||
                        "part_type": "note",
 | 
			
		||||
                        "body": "<p>Talk to Tim about this user's query.</p>",
 | 
			
		||||
                        "created_at": 1553378536,
 | 
			
		||||
                        "updated_at": 1553378536,
 | 
			
		||||
                        "notified_at": 1553378536,
 | 
			
		||||
                        "assigned_to": null,
 | 
			
		||||
                        "author": {
 | 
			
		||||
                            "type": "admin",
 | 
			
		||||
                            "id": "1957471",
 | 
			
		||||
                            "name": "Eeshan Garg"
 | 
			
		||||
                        },
 | 
			
		||||
                        "attachments": [],
 | 
			
		||||
                        "external_id": null
 | 
			
		||||
                    }
 | 
			
		||||
                ],
 | 
			
		||||
                "total_count": 1
 | 
			
		||||
            },
 | 
			
		||||
            "open": true,
 | 
			
		||||
            "state": "open",
 | 
			
		||||
            "snoozed_until": null,
 | 
			
		||||
            "read": true,
 | 
			
		||||
            "metadata": {},
 | 
			
		||||
            "tags": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "tags_added": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "links": {
 | 
			
		||||
                "conversation_web": "https://app.intercom.io/a/apps/i6wc9ipe/conversations/21330067382"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_2087a079-b2de-408b-8f30-8d56695fe2d9",
 | 
			
		||||
    "topic": "conversation.admin.noted",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553378537,
 | 
			
		||||
    "created_at": 1553378537,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,91 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "conversation",
 | 
			
		||||
            "id": "21330229536",
 | 
			
		||||
            "created_at": 1553380785,
 | 
			
		||||
            "updated_at": 1553380931,
 | 
			
		||||
            "user": {
 | 
			
		||||
                "type": "lead",
 | 
			
		||||
                "id": "5c96b58c27e3772c4751b2a3",
 | 
			
		||||
                "user_id": "ced6189f-e3b0-40b6-ab3a-9fdb27f4b3b0",
 | 
			
		||||
                "name": "Cordelia Lear",
 | 
			
		||||
                "email": "eg3800@mun.ca",
 | 
			
		||||
                "do_not_track": null
 | 
			
		||||
            },
 | 
			
		||||
            "assignee": {
 | 
			
		||||
                "type": "admin",
 | 
			
		||||
                "id": "1957471",
 | 
			
		||||
                "name": "Eeshan Garg",
 | 
			
		||||
                "email": "jerryguitarist@gmail.com"
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_message": {
 | 
			
		||||
                "type": "conversation_message",
 | 
			
		||||
                "id": "331793703",
 | 
			
		||||
                "url": "http://localhost:9991/integrations/",
 | 
			
		||||
                "subject": "",
 | 
			
		||||
                "body": "<p>Hello</p>",
 | 
			
		||||
                "author": {
 | 
			
		||||
                    "type": "user",
 | 
			
		||||
                    "id": "5c96b58c27e3772c4751b2a3"
 | 
			
		||||
                },
 | 
			
		||||
                "attachments": []
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_parts": {
 | 
			
		||||
                "type": "conversation_part.list",
 | 
			
		||||
                "conversation_parts": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "type": "conversation_part",
 | 
			
		||||
                        "id": "2826953202",
 | 
			
		||||
                        "part_type": "open",
 | 
			
		||||
                        "body": null,
 | 
			
		||||
                        "created_at": 1553380931,
 | 
			
		||||
                        "updated_at": 1553380931,
 | 
			
		||||
                        "notified_at": 1553380931,
 | 
			
		||||
                        "assigned_to": {
 | 
			
		||||
                            "type": "admin",
 | 
			
		||||
                            "id": "1957471",
 | 
			
		||||
                            "name": "Eeshan Garg"
 | 
			
		||||
                        },
 | 
			
		||||
                        "author": {
 | 
			
		||||
                            "type": "admin",
 | 
			
		||||
                            "id": "1957471",
 | 
			
		||||
                            "name": "Eeshan Garg"
 | 
			
		||||
                        },
 | 
			
		||||
                        "attachments": [],
 | 
			
		||||
                        "external_id": null
 | 
			
		||||
                    }
 | 
			
		||||
                ],
 | 
			
		||||
                "total_count": 1
 | 
			
		||||
            },
 | 
			
		||||
            "open": true,
 | 
			
		||||
            "state": "open",
 | 
			
		||||
            "snoozed_until": null,
 | 
			
		||||
            "read": true,
 | 
			
		||||
            "metadata": {},
 | 
			
		||||
            "tags": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "tags_added": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "links": {
 | 
			
		||||
                "conversation_web": "https://app.intercom.io/a/apps/i6wc9ipe/conversations/21330229536"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_d8906f30-db91-466e-9be2-4715fce4ab8b",
 | 
			
		||||
    "topic": "conversation.admin.opened",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553380932,
 | 
			
		||||
    "created_at": 1553380932,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,103 @@
 | 
			
		||||
{
 | 
			
		||||
    "type":"notification_event",
 | 
			
		||||
    "app_id":"i6wc9ipe",
 | 
			
		||||
    "data":{
 | 
			
		||||
        "type":"notification_event_data",
 | 
			
		||||
        "item":{
 | 
			
		||||
            "type":"conversation",
 | 
			
		||||
            "id":"21322009097",
 | 
			
		||||
            "created_at":1553290933,
 | 
			
		||||
            "updated_at":1553291111,
 | 
			
		||||
            "user":{
 | 
			
		||||
                "type":"lead",
 | 
			
		||||
                "id":"5c9553cb27e377f24eed49f7",
 | 
			
		||||
                "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
 | 
			
		||||
                "name":"Eeshan Garg",
 | 
			
		||||
                "email":"jerryguitarist@gmail.com",
 | 
			
		||||
                "do_not_track":null
 | 
			
		||||
            },
 | 
			
		||||
            "assignee":{
 | 
			
		||||
                "type": "admin",
 | 
			
		||||
                "id": "1957471",
 | 
			
		||||
                "name": "Cordelia Lear",
 | 
			
		||||
                "email": "cordelia@zulip.com"
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_message":{
 | 
			
		||||
                "type":"conversation_message",
 | 
			
		||||
                "id":"331499307",
 | 
			
		||||
                "url":"http://localhost:9991/api/",
 | 
			
		||||
                "subject":"",
 | 
			
		||||
                "body":"<p>Hello</p>",
 | 
			
		||||
                "author":{
 | 
			
		||||
                    "type":"user",
 | 
			
		||||
                    "id":"5c9553cb27e377f24eed49f7"
 | 
			
		||||
                },
 | 
			
		||||
                "attachments":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_parts":{
 | 
			
		||||
                "type":"conversation_part.list",
 | 
			
		||||
                "conversation_parts":[
 | 
			
		||||
                    {
 | 
			
		||||
                        "type":"conversation_part",
 | 
			
		||||
                        "id":"2824382500",
 | 
			
		||||
                        "part_type":"assignment",
 | 
			
		||||
                        "body":"<p>Hey Eeshan! How can I help?</p>",
 | 
			
		||||
                        "created_at":1553291111,
 | 
			
		||||
                        "updated_at":1553291111,
 | 
			
		||||
                        "notified_at":1553291111,
 | 
			
		||||
                        "assigned_to":{
 | 
			
		||||
                            "type":"admin",
 | 
			
		||||
                            "id":"1957471",
 | 
			
		||||
                            "name":"Eeshan Garg"
 | 
			
		||||
                        },
 | 
			
		||||
                        "author":{
 | 
			
		||||
                            "type":"admin",
 | 
			
		||||
                            "id":"1957471",
 | 
			
		||||
                            "name":"Eeshan Garg"
 | 
			
		||||
                        },
 | 
			
		||||
                        "attachments":[
 | 
			
		||||
 | 
			
		||||
                        ],
 | 
			
		||||
                        "external_id":null
 | 
			
		||||
                    }
 | 
			
		||||
                ],
 | 
			
		||||
                "total_count":1
 | 
			
		||||
            },
 | 
			
		||||
            "open":true,
 | 
			
		||||
            "state":"open",
 | 
			
		||||
            "snoozed_until":null,
 | 
			
		||||
            "read":false,
 | 
			
		||||
            "metadata":{
 | 
			
		||||
 | 
			
		||||
            },
 | 
			
		||||
            "tags":{
 | 
			
		||||
                "type":"tag.list",
 | 
			
		||||
                "tags":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "tags_added":{
 | 
			
		||||
                "type":"tag.list",
 | 
			
		||||
                "tags":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "links":{
 | 
			
		||||
                "conversation_web":"https://app.intercom.io/a/apps/i6wc9ipe/conversations/21322009097"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links":{
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
    "id":"notif_44d1f763-d3ad-4927-8e5c-da6cd6ca78d2",
 | 
			
		||||
    "topic":"conversation.admin.replied",
 | 
			
		||||
    "delivery_status":"pending",
 | 
			
		||||
    "delivery_attempts":1,
 | 
			
		||||
    "delivered_at":0,
 | 
			
		||||
    "first_sent_at":1553291112,
 | 
			
		||||
    "created_at":1553291112,
 | 
			
		||||
    "self":null
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,69 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "conversation",
 | 
			
		||||
            "id": "21330075292",
 | 
			
		||||
            "created_at": 1553378181,
 | 
			
		||||
            "updated_at": 1553378181,
 | 
			
		||||
            "user": {
 | 
			
		||||
                "type": "lead",
 | 
			
		||||
                "id": "5c9553cb27e377f24eed49f7",
 | 
			
		||||
                "user_id": "75067020-1204-495c-8edc-abb7d88bdd43",
 | 
			
		||||
                "name": "Eeshan Garg",
 | 
			
		||||
                "email": "jerryguitarist@gmail.com",
 | 
			
		||||
                "do_not_track": null
 | 
			
		||||
            },
 | 
			
		||||
            "assignee": {
 | 
			
		||||
                "type": "admin",
 | 
			
		||||
                "id": "1957471",
 | 
			
		||||
                "name": "Cordelia Lear",
 | 
			
		||||
                "email": "cordelia@zulip.com"
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_message": {
 | 
			
		||||
                "type": "conversation_message",
 | 
			
		||||
                "id": "331787154",
 | 
			
		||||
                "url": null,
 | 
			
		||||
                "subject": "Hello",
 | 
			
		||||
                "body": "<p>Hi Eeshan, What's up</p>",
 | 
			
		||||
                "author": {
 | 
			
		||||
                    "type": "admin",
 | 
			
		||||
                    "id": "1957471"
 | 
			
		||||
                },
 | 
			
		||||
                "attachments": []
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_parts": {
 | 
			
		||||
                "type": "conversation_part.list",
 | 
			
		||||
                "conversation_parts": [],
 | 
			
		||||
                "total_count": 0
 | 
			
		||||
            },
 | 
			
		||||
            "open": false,
 | 
			
		||||
            "state": "closed",
 | 
			
		||||
            "snoozed_until": null,
 | 
			
		||||
            "read": false,
 | 
			
		||||
            "metadata": {},
 | 
			
		||||
            "tags": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "tags_added": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "links": {
 | 
			
		||||
                "conversation_web": "https://app.intercom.io/a/apps/i6wc9ipe/conversations/21330075292"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_ca44c80b-1eaa-411c-b10f-046890017eea",
 | 
			
		||||
    "topic": "conversation.admin.single.created",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553378181,
 | 
			
		||||
    "created_at": 1553378181,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,87 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "conversation",
 | 
			
		||||
            "id": "21330067382",
 | 
			
		||||
            "created_at": 1553378082,
 | 
			
		||||
            "updated_at": 1553378413,
 | 
			
		||||
            "user": {
 | 
			
		||||
                "type": "lead",
 | 
			
		||||
                "id": "5c9553cb27e377f24eed49f7",
 | 
			
		||||
                "user_id": "75067020-1204-495c-8edc-abb7d88bdd43",
 | 
			
		||||
                "name": "Eeshan Garg",
 | 
			
		||||
                "email": "jerryguitarist@gmail.com",
 | 
			
		||||
                "do_not_track": null
 | 
			
		||||
            },
 | 
			
		||||
            "assignee": {
 | 
			
		||||
                "type": "admin",
 | 
			
		||||
                "id": "1957471",
 | 
			
		||||
                "name": "Cordelia Lear",
 | 
			
		||||
                "email": "cordelia@zulip.com"
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_message": {
 | 
			
		||||
                "type": "conversation_message",
 | 
			
		||||
                "id": "331786931",
 | 
			
		||||
                "url": "http://localhost:9991/api/",
 | 
			
		||||
                "subject": "",
 | 
			
		||||
                "body": "<p>Hey! I'd like to set up a new account</p>",
 | 
			
		||||
                "author": {
 | 
			
		||||
                    "type": "user",
 | 
			
		||||
                    "id": "5c9553cb27e377f24eed49f7"
 | 
			
		||||
                },
 | 
			
		||||
                "attachments": []
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_parts": {
 | 
			
		||||
                "type": "conversation_part.list",
 | 
			
		||||
                "conversation_parts": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "type": "conversation_part",
 | 
			
		||||
                        "id": "2826902108",
 | 
			
		||||
                        "part_type": "snoozed",
 | 
			
		||||
                        "body": null,
 | 
			
		||||
                        "created_at": 1553378413,
 | 
			
		||||
                        "updated_at": 1553378413,
 | 
			
		||||
                        "notified_at": 1553378413,
 | 
			
		||||
                        "assigned_to": null,
 | 
			
		||||
                        "author": {
 | 
			
		||||
                            "type": "admin",
 | 
			
		||||
                            "id": "1957471",
 | 
			
		||||
                            "name": "Eeshan Garg"
 | 
			
		||||
                        },
 | 
			
		||||
                        "attachments": [],
 | 
			
		||||
                        "external_id": null
 | 
			
		||||
                    }
 | 
			
		||||
                ],
 | 
			
		||||
                "total_count": 1
 | 
			
		||||
            },
 | 
			
		||||
            "open": true,
 | 
			
		||||
            "state": "snoozed",
 | 
			
		||||
            "snoozed_until": 1553513400,
 | 
			
		||||
            "read": true,
 | 
			
		||||
            "metadata": {},
 | 
			
		||||
            "tags": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "tags_added": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "links": {
 | 
			
		||||
                "conversation_web": "https://app.intercom.io/a/apps/i6wc9ipe/conversations/21330067382"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_0530a65a-8052-4f67-9070-a50f1363dc68",
 | 
			
		||||
    "topic": "conversation.admin.snoozed",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553378414,
 | 
			
		||||
    "created_at": 1553378414,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,87 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "conversation",
 | 
			
		||||
            "id": "21330067382",
 | 
			
		||||
            "created_at": 1553378082,
 | 
			
		||||
            "updated_at": 1553378474,
 | 
			
		||||
            "user": {
 | 
			
		||||
                "type": "lead",
 | 
			
		||||
                "id": "5c9553cb27e377f24eed49f7",
 | 
			
		||||
                "user_id": "75067020-1204-495c-8edc-abb7d88bdd43",
 | 
			
		||||
                "name": "Eeshan Garg",
 | 
			
		||||
                "email": "jerryguitarist@gmail.com",
 | 
			
		||||
                "do_not_track": null
 | 
			
		||||
            },
 | 
			
		||||
            "assignee": {
 | 
			
		||||
                "type": "admin",
 | 
			
		||||
                "id": "1957471",
 | 
			
		||||
                "name": "Cordelia Lear",
 | 
			
		||||
                "email": "cordelia@zulip.com"
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_message": {
 | 
			
		||||
                "type": "conversation_message",
 | 
			
		||||
                "id": "331786931",
 | 
			
		||||
                "url": "http://localhost:9991/api/",
 | 
			
		||||
                "subject": "",
 | 
			
		||||
                "body": "<p>Hey! I'd like to set up a new account</p>",
 | 
			
		||||
                "author": {
 | 
			
		||||
                    "type": "user",
 | 
			
		||||
                    "id": "5c9553cb27e377f24eed49f7"
 | 
			
		||||
                },
 | 
			
		||||
                "attachments": []
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_parts": {
 | 
			
		||||
                "type": "conversation_part.list",
 | 
			
		||||
                "conversation_parts": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "type": "conversation_part",
 | 
			
		||||
                        "id": "2826903472",
 | 
			
		||||
                        "part_type": "unsnoozed",
 | 
			
		||||
                        "body": null,
 | 
			
		||||
                        "created_at": 1553378474,
 | 
			
		||||
                        "updated_at": 1553378474,
 | 
			
		||||
                        "notified_at": 1553378474,
 | 
			
		||||
                        "assigned_to": null,
 | 
			
		||||
                        "author": {
 | 
			
		||||
                            "type": "admin",
 | 
			
		||||
                            "id": "1957471",
 | 
			
		||||
                            "name": "Eeshan Garg"
 | 
			
		||||
                        },
 | 
			
		||||
                        "attachments": [],
 | 
			
		||||
                        "external_id": null
 | 
			
		||||
                    }
 | 
			
		||||
                ],
 | 
			
		||||
                "total_count": 1
 | 
			
		||||
            },
 | 
			
		||||
            "open": true,
 | 
			
		||||
            "state": "open",
 | 
			
		||||
            "snoozed_until": null,
 | 
			
		||||
            "read": true,
 | 
			
		||||
            "metadata": {},
 | 
			
		||||
            "tags": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "tags_added": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "links": {
 | 
			
		||||
                "conversation_web": "https://app.intercom.io/a/apps/i6wc9ipe/conversations/21330067382"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_f0f76ee2-f2c0-4526-90cd-caebecfc5ec5",
 | 
			
		||||
    "topic": "conversation.admin.unsnoozed",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553378475,
 | 
			
		||||
    "created_at": 1553378475,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,98 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "conversation",
 | 
			
		||||
            "id": "21330067382",
 | 
			
		||||
            "created_at": 1553378082,
 | 
			
		||||
            "updated_at": 1553378536,
 | 
			
		||||
            "user": {
 | 
			
		||||
                "type": "lead",
 | 
			
		||||
                "id": "5c9553cb27e377f24eed49f7",
 | 
			
		||||
                "user_id": "75067020-1204-495c-8edc-abb7d88bdd43",
 | 
			
		||||
                "name": "Eeshan Garg",
 | 
			
		||||
                "email": "jerryguitarist@gmail.com",
 | 
			
		||||
                "do_not_track": null
 | 
			
		||||
            },
 | 
			
		||||
            "assignee": {
 | 
			
		||||
                "type": "nobody_admin",
 | 
			
		||||
                "id": null
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_message": {
 | 
			
		||||
                "type": "conversation_message",
 | 
			
		||||
                "id": "331786931",
 | 
			
		||||
                "url": "http://localhost:9991/api/",
 | 
			
		||||
                "subject": "",
 | 
			
		||||
                "body": "<p>Hey! I'd like to set up a new account</p>",
 | 
			
		||||
                "author": {
 | 
			
		||||
                    "type": "user",
 | 
			
		||||
                    "id": "5c9553cb27e377f24eed49f7"
 | 
			
		||||
                },
 | 
			
		||||
                "attachments": []
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_parts": {
 | 
			
		||||
                "type": "conversation_part.list",
 | 
			
		||||
                "conversation_parts": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "type": "conversation_part",
 | 
			
		||||
                        "id": "331786931",
 | 
			
		||||
                        "part_type": "comment",
 | 
			
		||||
                        "body": "<p>Hey! I'd like to set up a new account</p>",
 | 
			
		||||
                        "created_at": 1553378082,
 | 
			
		||||
                        "updated_at": 1553378744,
 | 
			
		||||
                        "notified_at": 1553378082,
 | 
			
		||||
                        "assigned_to": null,
 | 
			
		||||
                        "author": {
 | 
			
		||||
                            "type": "user",
 | 
			
		||||
                            "id": "5c9553cb27e377f24eed49f7",
 | 
			
		||||
                            "name": "Eeshan Garg",
 | 
			
		||||
                            "email": "jerryguitarist@gmail.com"
 | 
			
		||||
                        },
 | 
			
		||||
                        "attachments": [],
 | 
			
		||||
                        "external_id": null
 | 
			
		||||
                    }
 | 
			
		||||
                ],
 | 
			
		||||
                "total_count": 1
 | 
			
		||||
            },
 | 
			
		||||
            "open": true,
 | 
			
		||||
            "state": "open",
 | 
			
		||||
            "snoozed_until": null,
 | 
			
		||||
            "read": true,
 | 
			
		||||
            "metadata": {},
 | 
			
		||||
            "tags": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "type": "tag",
 | 
			
		||||
                        "id": "2525085",
 | 
			
		||||
                        "name": "developer"
 | 
			
		||||
                    }
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "tags_added": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "type": "tag",
 | 
			
		||||
                        "id": "2525085",
 | 
			
		||||
                        "name": "developer"
 | 
			
		||||
                    }
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "links": {
 | 
			
		||||
                "conversation_web": "https://app.intercom.io/a/apps/i6wc9ipe/conversations/21330067382"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_11aef68a-8049-4f29-bbd9-48a7adfc8f30",
 | 
			
		||||
    "topic": "conversation_part.tag.created",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553378744,
 | 
			
		||||
    "created_at": 1553378744,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,79 @@
 | 
			
		||||
{
 | 
			
		||||
    "type":"notification_event",
 | 
			
		||||
    "app_id":"i6wc9ipe",
 | 
			
		||||
    "data":{
 | 
			
		||||
        "type":"notification_event_data",
 | 
			
		||||
        "item":{
 | 
			
		||||
            "type":"conversation",
 | 
			
		||||
            "id":"21321941764",
 | 
			
		||||
            "created_at":1553290198,
 | 
			
		||||
            "updated_at":1553290198,
 | 
			
		||||
            "user":{
 | 
			
		||||
                "type":"lead",
 | 
			
		||||
                "id":"5c9553cb27e377f24eed49f7",
 | 
			
		||||
                "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
 | 
			
		||||
                "name":"Rose Poodle from St. John's",
 | 
			
		||||
                "email":"",
 | 
			
		||||
                "do_not_track":null
 | 
			
		||||
            },
 | 
			
		||||
            "assignee":{
 | 
			
		||||
                "type":"nobody_admin",
 | 
			
		||||
                "id":null
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_message":{
 | 
			
		||||
                "type":"conversation_message",
 | 
			
		||||
                "id":"331494375",
 | 
			
		||||
                "url":"http://localhost:9991/api/",
 | 
			
		||||
                "subject":"",
 | 
			
		||||
                "body":"<p>Hello everyone!</p>",
 | 
			
		||||
                "author":{
 | 
			
		||||
                    "type":"user",
 | 
			
		||||
                    "id":"5c9553cb27e377f24eed49f7"
 | 
			
		||||
                },
 | 
			
		||||
                "attachments":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_parts":{
 | 
			
		||||
                "type":"conversation_part.list",
 | 
			
		||||
                "conversation_parts":[
 | 
			
		||||
 | 
			
		||||
                ],
 | 
			
		||||
                "total_count":0
 | 
			
		||||
            },
 | 
			
		||||
            "open":true,
 | 
			
		||||
            "state":"open",
 | 
			
		||||
            "snoozed_until":null,
 | 
			
		||||
            "read":true,
 | 
			
		||||
            "metadata":{
 | 
			
		||||
 | 
			
		||||
            },
 | 
			
		||||
            "tags":{
 | 
			
		||||
                "type":"tag.list",
 | 
			
		||||
                "tags":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "tags_added":{
 | 
			
		||||
                "type":"tag.list",
 | 
			
		||||
                "tags":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "links":{
 | 
			
		||||
                "conversation_web":"https://app.intercom.io/a/apps/i6wc9ipe/conversations/21321941764"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links":{
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
    "id":"notif_3ac27816-d27c-45fd-a65a-bbaf021cf780",
 | 
			
		||||
    "topic":"conversation.user.created",
 | 
			
		||||
    "delivery_status":"pending",
 | 
			
		||||
    "delivery_attempts":1,
 | 
			
		||||
    "delivered_at":0,
 | 
			
		||||
    "first_sent_at":1553290198,
 | 
			
		||||
    "created_at":1553290198,
 | 
			
		||||
    "self":null
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										100
									
								
								zerver/webhooks/intercom/fixtures/conversation_user_replied.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										100
									
								
								zerver/webhooks/intercom/fixtures/conversation_user_replied.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,100 @@
 | 
			
		||||
{
 | 
			
		||||
    "type":"notification_event",
 | 
			
		||||
    "app_id":"i6wc9ipe",
 | 
			
		||||
    "data":{
 | 
			
		||||
        "type":"notification_event_data",
 | 
			
		||||
        "item":{
 | 
			
		||||
            "type":"conversation",
 | 
			
		||||
            "id":"21322009097",
 | 
			
		||||
            "created_at":1553290933,
 | 
			
		||||
            "updated_at":1553291307,
 | 
			
		||||
            "user":{
 | 
			
		||||
                "type":"lead",
 | 
			
		||||
                "id":"5c9553cb27e377f24eed49f7",
 | 
			
		||||
                "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
 | 
			
		||||
                "name":"Eeshan Garg",
 | 
			
		||||
                "email":"jerryguitarist@gmail.com",
 | 
			
		||||
                "do_not_track":null
 | 
			
		||||
            },
 | 
			
		||||
            "assignee":{
 | 
			
		||||
                "type":"admin",
 | 
			
		||||
                "id":"1957471",
 | 
			
		||||
                "name":"Eeshan Garg",
 | 
			
		||||
                "email":"jerryguitarist@gmail.com"
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_message":{
 | 
			
		||||
                "type":"conversation_message",
 | 
			
		||||
                "id":"331499307",
 | 
			
		||||
                "url":"http://localhost:9991/api/",
 | 
			
		||||
                "subject":"",
 | 
			
		||||
                "body":"<p>Hello</p>",
 | 
			
		||||
                "author":{
 | 
			
		||||
                    "type":"user",
 | 
			
		||||
                    "id":"5c9553cb27e377f24eed49f7"
 | 
			
		||||
                },
 | 
			
		||||
                "attachments":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "conversation_parts":{
 | 
			
		||||
                "type":"conversation_part.list",
 | 
			
		||||
                "conversation_parts":[
 | 
			
		||||
                    {
 | 
			
		||||
                        "type":"conversation_part",
 | 
			
		||||
                        "id":"2824391734",
 | 
			
		||||
                        "part_type":"comment",
 | 
			
		||||
                        "body":"<p>Well, I need some help getting access to a developer account.</p>",
 | 
			
		||||
                        "created_at":1553291307,
 | 
			
		||||
                        "updated_at":1553291307,
 | 
			
		||||
                        "notified_at":1553291307,
 | 
			
		||||
                        "assigned_to":null,
 | 
			
		||||
                        "author":{
 | 
			
		||||
                            "type":"user",
 | 
			
		||||
                            "id":"5c9553cb27e377f24eed49f7",
 | 
			
		||||
                            "name":"Eeshan Garg",
 | 
			
		||||
                            "email":"jerryguitarist@gmail.com"
 | 
			
		||||
                        },
 | 
			
		||||
                        "attachments":[
 | 
			
		||||
 | 
			
		||||
                        ],
 | 
			
		||||
                        "external_id":null
 | 
			
		||||
                    }
 | 
			
		||||
                ],
 | 
			
		||||
                "total_count":1
 | 
			
		||||
            },
 | 
			
		||||
            "open":true,
 | 
			
		||||
            "state":"open",
 | 
			
		||||
            "snoozed_until":null,
 | 
			
		||||
            "read":true,
 | 
			
		||||
            "metadata":{
 | 
			
		||||
 | 
			
		||||
            },
 | 
			
		||||
            "tags":{
 | 
			
		||||
                "type":"tag.list",
 | 
			
		||||
                "tags":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "tags_added":{
 | 
			
		||||
                "type":"tag.list",
 | 
			
		||||
                "tags":[
 | 
			
		||||
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "links":{
 | 
			
		||||
                "conversation_web":"https://app.intercom.io/a/apps/i6wc9ipe/conversations/21322009097"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links":{
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
    "id":"notif_2c71fff0-65ef-46be-bbfe-dbf637bbff15",
 | 
			
		||||
    "topic":"conversation.user.replied",
 | 
			
		||||
    "delivery_status":"pending",
 | 
			
		||||
    "delivery_attempts":1,
 | 
			
		||||
    "delivered_at":0,
 | 
			
		||||
    "first_sent_at":1553291308,
 | 
			
		||||
    "created_at":1553291308,
 | 
			
		||||
    "self":null
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										27
									
								
								zerver/webhooks/intercom/fixtures/event_created.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								zerver/webhooks/intercom/fixtures/event_created.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "event",
 | 
			
		||||
            "event_name": "invited-friend",
 | 
			
		||||
            "id": "84ca8d44-8f2e-11e3-bbc6-6d72c14baf72",
 | 
			
		||||
            "intercom_user_id": "5c9aabdf2ddf20549a41453a",
 | 
			
		||||
            "user_id": "12",
 | 
			
		||||
            "email": "jerryguitarist@gmail.com",
 | 
			
		||||
            "metadata": {},
 | 
			
		||||
            "created_at": 1391691571,
 | 
			
		||||
            "ext_metadata": {}
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_da25b9d8-797b-4858-ac4a-4a2e9bbecee4",
 | 
			
		||||
    "topic": "event.created",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553642228,
 | 
			
		||||
    "created_at": 1553642228,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										22
									
								
								zerver/webhooks/intercom/fixtures/ping.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								zerver/webhooks/intercom/fixtures/ping.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
{
 | 
			
		||||
    "type":"notification_event",
 | 
			
		||||
    "app_id":"i6wc9ipe",
 | 
			
		||||
    "data":{
 | 
			
		||||
        "type":"notification_event_data",
 | 
			
		||||
        "item":{
 | 
			
		||||
            "type":"ping",
 | 
			
		||||
            "message":"something something interzen"
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links":{
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
    "id":null,
 | 
			
		||||
    "topic":"ping",
 | 
			
		||||
    "delivery_status":null,
 | 
			
		||||
    "delivery_attempts":1,
 | 
			
		||||
    "delivered_at":0,
 | 
			
		||||
    "first_sent_at":1553288147,
 | 
			
		||||
    "created_at":1553288147,
 | 
			
		||||
    "self":null
 | 
			
		||||
}
 | 
			
		||||
@@ -1,77 +1,74 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "vsahmbmw",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "user_tag",
 | 
			
		||||
            "user": {
 | 
			
		||||
                "type": "user",
 | 
			
		||||
                "id": "5a364a4a4716ab4dc29e87ba",
 | 
			
		||||
                "user_id": "5",
 | 
			
		||||
                "anonymous": false,
 | 
			
		||||
                "email": "john.doe@gmail.com",
 | 
			
		||||
                "phone": 9876543211,
 | 
			
		||||
                "name": "John Doe",
 | 
			
		||||
                "pseudonym": null,
 | 
			
		||||
                "avatar": {
 | 
			
		||||
                    "type": "avatar",
 | 
			
		||||
                    "image_url": null
 | 
			
		||||
                },
 | 
			
		||||
                "app_id": "vsahmbmw",
 | 
			
		||||
                "companies": {
 | 
			
		||||
                    "type": "company.list",
 | 
			
		||||
                    "companies": []
 | 
			
		||||
                },
 | 
			
		||||
                "location_data": {},
 | 
			
		||||
                "last_request_at": null,
 | 
			
		||||
                "last_seen_ip": null,
 | 
			
		||||
                "created_at": "2017-12-17T10:43:22.000Z",
 | 
			
		||||
                "remote_created_at": null,
 | 
			
		||||
                "signed_up_at": null,
 | 
			
		||||
                "updated_at": "2017-12-17T10:43:22.496Z",
 | 
			
		||||
                "session_count": 0,
 | 
			
		||||
                "social_profiles": {
 | 
			
		||||
                    "type": "social_profile.list",
 | 
			
		||||
                    "social_profiles": []
 | 
			
		||||
                },
 | 
			
		||||
                "unsubscribed_from_emails": false,
 | 
			
		||||
                "marked_email_as_spam": false,
 | 
			
		||||
                "has_hard_bounced": false,
 | 
			
		||||
                "user_agent_data": null,
 | 
			
		||||
                "tags": {
 | 
			
		||||
                    "type": "tag.list",
 | 
			
		||||
                    "tags": [
 | 
			
		||||
                        {
 | 
			
		||||
                            "type": "tag",
 | 
			
		||||
                            "id": "1449318"
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                "segments": {
 | 
			
		||||
                    "type": "segment.list",
 | 
			
		||||
                    "segments": []
 | 
			
		||||
                },
 | 
			
		||||
                "custom_attributes": {}
 | 
			
		||||
            "type": "user",
 | 
			
		||||
            "id": "5c9ab3e78cd7330140ce5033",
 | 
			
		||||
            "user_id": "25",
 | 
			
		||||
            "anonymous": false,
 | 
			
		||||
            "email": "aaron@zulip.com",
 | 
			
		||||
            "phone": "2345570987",
 | 
			
		||||
            "name": "Aaron Smith",
 | 
			
		||||
            "pseudonym": null,
 | 
			
		||||
            "avatar": {
 | 
			
		||||
                "type": "avatar",
 | 
			
		||||
                "image_url": null
 | 
			
		||||
            },
 | 
			
		||||
            "tag": {
 | 
			
		||||
                "type": "tag",
 | 
			
		||||
                "id": "1449318",
 | 
			
		||||
                "name": "CSV Import - 2017-12-17 10:42:59 UTC"
 | 
			
		||||
            "app_id": "i6wc9ipe",
 | 
			
		||||
            "companies": {
 | 
			
		||||
                "type": "company.list",
 | 
			
		||||
                "companies": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "type": "company",
 | 
			
		||||
                        "company_id": "366",
 | 
			
		||||
                        "id": "5c9ab3e78cd7330140ce5034",
 | 
			
		||||
                        "name": "Zulip"
 | 
			
		||||
                    }
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "created_at": 1513507402,
 | 
			
		||||
            "admin": {
 | 
			
		||||
                "type": "admin"
 | 
			
		||||
            }
 | 
			
		||||
            "location_data": {},
 | 
			
		||||
            "last_request_at": null,
 | 
			
		||||
            "created_at": "2019-03-26T23:21:11.907+00:00",
 | 
			
		||||
            "remote_created_at": "2014-02-18T13:48:51.000+00:00",
 | 
			
		||||
            "signed_up_at": "2014-02-18T13:48:51.000+00:00",
 | 
			
		||||
            "updated_at": "2019-03-26T23:21:11.904+00:00",
 | 
			
		||||
            "session_count": 0,
 | 
			
		||||
            "social_profiles": {
 | 
			
		||||
                "type": "social_profile.list",
 | 
			
		||||
                "social_profiles": []
 | 
			
		||||
            },
 | 
			
		||||
            "unsubscribed_from_emails": false,
 | 
			
		||||
            "marked_email_as_spam": false,
 | 
			
		||||
            "has_hard_bounced": false,
 | 
			
		||||
            "tags": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "segments": {
 | 
			
		||||
                "type": "segment.list",
 | 
			
		||||
                "segments": []
 | 
			
		||||
            },
 | 
			
		||||
            "custom_attributes": {},
 | 
			
		||||
            "referrer": null,
 | 
			
		||||
            "utm_campaign": null,
 | 
			
		||||
            "utm_content": null,
 | 
			
		||||
            "utm_medium": null,
 | 
			
		||||
            "utm_source": null,
 | 
			
		||||
            "utm_term": null,
 | 
			
		||||
            "do_not_track": null,
 | 
			
		||||
            "last_seen_ip": null,
 | 
			
		||||
            "user_agent_data": null
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_1a6fd8a0-e317-11e7-b721-d77135370663",
 | 
			
		||||
    "topic": "user.tag.created",
 | 
			
		||||
    "id": "notif_61f436a9-6a2e-4f9b-9e85-68043477da63",
 | 
			
		||||
    "topic": "user.created",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1513507402,
 | 
			
		||||
    "created_at": 1513507402,
 | 
			
		||||
    "first_sent_at": 1553642472,
 | 
			
		||||
    "created_at": 1553642471,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								zerver/webhooks/intercom/fixtures/user_deleted.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								zerver/webhooks/intercom/fixtures/user_deleted.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "user",
 | 
			
		||||
            "id": "5c9553cb27e377f24eed49f7",
 | 
			
		||||
            "user_id": "75067020-1204-495c-8edc-abb7d88bdd43",
 | 
			
		||||
            "email": "jerryguitarist@gmail.com"
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_03e00e17-30d8-4c8a-91a4-6486a3df66e0",
 | 
			
		||||
    "topic": "user.deleted",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553379090,
 | 
			
		||||
    "created_at": 1553379090,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										78
									
								
								zerver/webhooks/intercom/fixtures/user_email_updated.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								zerver/webhooks/intercom/fixtures/user_email_updated.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,78 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "contact",
 | 
			
		||||
            "id": "5c96b122177026171b401e20",
 | 
			
		||||
            "user_id": "8f9ef493-c5f9-4817-895d-874c3704ea49",
 | 
			
		||||
            "anonymous": true,
 | 
			
		||||
            "email": "aaron@zulip.com",
 | 
			
		||||
            "phone": null,
 | 
			
		||||
            "name": null,
 | 
			
		||||
            "pseudonym": "Azure Bus from St. John's",
 | 
			
		||||
            "avatar": {
 | 
			
		||||
                "type": "avatar",
 | 
			
		||||
                "image_url": "https://static.intercomassets.com/app/pseudonym_avatars_2019/azure-bus.png"
 | 
			
		||||
            },
 | 
			
		||||
            "app_id": "i6wc9ipe",
 | 
			
		||||
            "companies": {
 | 
			
		||||
                "type": "company.list",
 | 
			
		||||
                "companies": []
 | 
			
		||||
            },
 | 
			
		||||
            "location_data": {
 | 
			
		||||
                "type": "location_data",
 | 
			
		||||
                "city_name": "St. John's",
 | 
			
		||||
                "continent_code": "NA",
 | 
			
		||||
                "country_name": "Canada",
 | 
			
		||||
                "postal_code": "A1B",
 | 
			
		||||
                "region_name": "Newfoundland and Labrador",
 | 
			
		||||
                "timezone": "America/St_Johns",
 | 
			
		||||
                "country_code": "CAN",
 | 
			
		||||
                "latitude": null,
 | 
			
		||||
                "longitude": null
 | 
			
		||||
            },
 | 
			
		||||
            "last_request_at": "2019-03-23T22:20:52.453+00:00",
 | 
			
		||||
            "created_at": "2019-03-23T22:20:18.253+00:00",
 | 
			
		||||
            "remote_created_at": null,
 | 
			
		||||
            "signed_up_at": null,
 | 
			
		||||
            "updated_at": "2019-03-23T22:20:59.490+00:00",
 | 
			
		||||
            "session_count": 0,
 | 
			
		||||
            "social_profiles": {
 | 
			
		||||
                "type": "social_profile.list",
 | 
			
		||||
                "social_profiles": []
 | 
			
		||||
            },
 | 
			
		||||
            "unsubscribed_from_emails": false,
 | 
			
		||||
            "marked_email_as_spam": false,
 | 
			
		||||
            "has_hard_bounced": false,
 | 
			
		||||
            "tags": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "segments": {
 | 
			
		||||
                "type": "segment.list",
 | 
			
		||||
                "segments": []
 | 
			
		||||
            },
 | 
			
		||||
            "custom_attributes": {},
 | 
			
		||||
            "referrer": null,
 | 
			
		||||
            "utm_campaign": null,
 | 
			
		||||
            "utm_content": null,
 | 
			
		||||
            "utm_medium": null,
 | 
			
		||||
            "utm_source": null,
 | 
			
		||||
            "utm_term": null,
 | 
			
		||||
            "do_not_track": null,
 | 
			
		||||
            "last_seen_ip": null,
 | 
			
		||||
            "user_agent_data": null
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_687f7dfc-afd2-48ce-b31a-7a087d2ebf71",
 | 
			
		||||
    "topic": "user.email.updated",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553379706,
 | 
			
		||||
    "created_at": 1553379706,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										92
									
								
								zerver/webhooks/intercom/fixtures/user_tag_created.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								zerver/webhooks/intercom/fixtures/user_tag_created.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,92 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "user_tag",
 | 
			
		||||
            "user": {
 | 
			
		||||
                "type": "user",
 | 
			
		||||
                "id": "5c9aabdf2ddf20549a41453a",
 | 
			
		||||
                "user_id": "12",
 | 
			
		||||
                "anonymous": false,
 | 
			
		||||
                "email": "jerryguitarist@gmail.com",
 | 
			
		||||
                "phone": null,
 | 
			
		||||
                "name": "eeshangarg",
 | 
			
		||||
                "pseudonym": null,
 | 
			
		||||
                "avatar": {
 | 
			
		||||
                    "type": "avatar",
 | 
			
		||||
                    "image_url": "https://img.fullcontact.com/static/85ce413bcdac4cec3cfdb3a8da530f8b_8a853b478c3122d7e4ec9e14f81d9a3d9ea9da198d85c1985efc2403fa6bdb0c"
 | 
			
		||||
                },
 | 
			
		||||
                "app_id": "i6wc9ipe",
 | 
			
		||||
                "companies": {
 | 
			
		||||
                    "type": "company.list",
 | 
			
		||||
                    "companies": []
 | 
			
		||||
                },
 | 
			
		||||
                "location_data": {},
 | 
			
		||||
                "last_request_at": null,
 | 
			
		||||
                "created_at": "2019-03-26T22:46:55.851+00:00",
 | 
			
		||||
                "remote_created_at": "2019-03-03T00:00:00.000+00:00",
 | 
			
		||||
                "signed_up_at": "2019-03-03T00:00:00.000+00:00",
 | 
			
		||||
                "updated_at": "2019-03-26T22:46:56.045+00:00",
 | 
			
		||||
                "session_count": 0,
 | 
			
		||||
                "social_profiles": {
 | 
			
		||||
                    "type": "social_profile.list",
 | 
			
		||||
                    "social_profiles": [
 | 
			
		||||
                        {
 | 
			
		||||
                            "type": "social_profile",
 | 
			
		||||
                            "name": "github",
 | 
			
		||||
                            "id": null,
 | 
			
		||||
                            "username": "eeshangarg",
 | 
			
		||||
                            "url": "https://github.com/eeshangarg"
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                "unsubscribed_from_emails": false,
 | 
			
		||||
                "marked_email_as_spam": false,
 | 
			
		||||
                "has_hard_bounced": false,
 | 
			
		||||
                "tags": {
 | 
			
		||||
                    "type": "tag.list",
 | 
			
		||||
                    "tags": [
 | 
			
		||||
                        {
 | 
			
		||||
                            "type": "tag",
 | 
			
		||||
                            "id": "2525085"
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                "segments": {
 | 
			
		||||
                    "type": "segment.list",
 | 
			
		||||
                    "segments": []
 | 
			
		||||
                },
 | 
			
		||||
                "custom_attributes": {},
 | 
			
		||||
                "referrer": null,
 | 
			
		||||
                "utm_campaign": null,
 | 
			
		||||
                "utm_content": null,
 | 
			
		||||
                "utm_medium": null,
 | 
			
		||||
                "utm_source": null,
 | 
			
		||||
                "utm_term": null,
 | 
			
		||||
                "do_not_track": null,
 | 
			
		||||
                "last_seen_ip": null,
 | 
			
		||||
                "user_agent_data": null
 | 
			
		||||
            },
 | 
			
		||||
            "tag": {
 | 
			
		||||
                "type": "tag",
 | 
			
		||||
                "id": "2525085",
 | 
			
		||||
                "name": "developer"
 | 
			
		||||
            },
 | 
			
		||||
            "created_at": 1553640416,
 | 
			
		||||
            "admin": {
 | 
			
		||||
                "type": "admin"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_800ae4f0-e326-41e7-a4e9-c4e7a97d45f4",
 | 
			
		||||
    "topic": "user.tag.created",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553640416,
 | 
			
		||||
    "created_at": 1553640416,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										92
									
								
								zerver/webhooks/intercom/fixtures/user_tag_deleted.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								zerver/webhooks/intercom/fixtures/user_tag_deleted.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,92 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "user_tag",
 | 
			
		||||
            "user": {
 | 
			
		||||
                "type": "user",
 | 
			
		||||
                "id": "5c9aabdf2ddf20549a41453a",
 | 
			
		||||
                "user_id": "12",
 | 
			
		||||
                "anonymous": false,
 | 
			
		||||
                "email": "jerryguitarist@gmail.com",
 | 
			
		||||
                "phone": null,
 | 
			
		||||
                "name": "eeshangarg",
 | 
			
		||||
                "pseudonym": null,
 | 
			
		||||
                "avatar": {
 | 
			
		||||
                    "type": "avatar",
 | 
			
		||||
                    "image_url": "https://img.fullcontact.com/static/85ce413bcdac4cec3cfdb3a8da530f8b_8a853b478c3122d7e4ec9e14f81d9a3d9ea9da198d85c1985efc2403fa6bdb0c"
 | 
			
		||||
                },
 | 
			
		||||
                "app_id": "i6wc9ipe",
 | 
			
		||||
                "companies": {
 | 
			
		||||
                    "type": "company.list",
 | 
			
		||||
                    "companies": []
 | 
			
		||||
                },
 | 
			
		||||
                "location_data": {},
 | 
			
		||||
                "last_request_at": null,
 | 
			
		||||
                "created_at": "2019-03-26T22:46:55.851+00:00",
 | 
			
		||||
                "remote_created_at": "2019-03-03T00:00:00.000+00:00",
 | 
			
		||||
                "signed_up_at": "2019-03-03T00:00:00.000+00:00",
 | 
			
		||||
                "updated_at": "2019-03-26T22:48:23.743+00:00",
 | 
			
		||||
                "session_count": 0,
 | 
			
		||||
                "social_profiles": {
 | 
			
		||||
                    "type": "social_profile.list",
 | 
			
		||||
                    "social_profiles": [
 | 
			
		||||
                        {
 | 
			
		||||
                            "type": "social_profile",
 | 
			
		||||
                            "name": "github",
 | 
			
		||||
                            "id": null,
 | 
			
		||||
                            "username": "eeshangarg",
 | 
			
		||||
                            "url": "https://github.com/eeshangarg"
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                "unsubscribed_from_emails": false,
 | 
			
		||||
                "marked_email_as_spam": false,
 | 
			
		||||
                "has_hard_bounced": false,
 | 
			
		||||
                "tags": {
 | 
			
		||||
                    "type": "tag.list",
 | 
			
		||||
                    "tags": [
 | 
			
		||||
                        {
 | 
			
		||||
                            "type": "tag",
 | 
			
		||||
                            "id": "2525085"
 | 
			
		||||
                        }
 | 
			
		||||
                    ]
 | 
			
		||||
                },
 | 
			
		||||
                "segments": {
 | 
			
		||||
                    "type": "segment.list",
 | 
			
		||||
                    "segments": []
 | 
			
		||||
                },
 | 
			
		||||
                "custom_attributes": {},
 | 
			
		||||
                "referrer": null,
 | 
			
		||||
                "utm_campaign": null,
 | 
			
		||||
                "utm_content": null,
 | 
			
		||||
                "utm_medium": null,
 | 
			
		||||
                "utm_source": null,
 | 
			
		||||
                "utm_term": null,
 | 
			
		||||
                "do_not_track": null,
 | 
			
		||||
                "last_seen_ip": null,
 | 
			
		||||
                "user_agent_data": null
 | 
			
		||||
            },
 | 
			
		||||
            "tag": {
 | 
			
		||||
                "type": "tag",
 | 
			
		||||
                "id": "2535149",
 | 
			
		||||
                "name": "CSV Import - 2019-03-26 22:46:04 UTC"
 | 
			
		||||
            },
 | 
			
		||||
            "created_at": 1553640503,
 | 
			
		||||
            "admin": {
 | 
			
		||||
                "type": "admin"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_89864fe7-ef26-4b32-b410-160871aa7fb9",
 | 
			
		||||
    "topic": "user.tag.deleted",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553640503,
 | 
			
		||||
    "created_at": 1553640503,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										93
									
								
								zerver/webhooks/intercom/fixtures/user_unsubscribed.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								zerver/webhooks/intercom/fixtures/user_unsubscribed.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,93 @@
 | 
			
		||||
{
 | 
			
		||||
    "type": "notification_event",
 | 
			
		||||
    "app_id": "i6wc9ipe",
 | 
			
		||||
    "data": {
 | 
			
		||||
        "type": "notification_event_data",
 | 
			
		||||
        "item": {
 | 
			
		||||
            "type": "contact",
 | 
			
		||||
            "id": "5c96b122177026171b401e20",
 | 
			
		||||
            "user_id": "8f9ef493-c5f9-4817-895d-874c3704ea49",
 | 
			
		||||
            "anonymous": true,
 | 
			
		||||
            "email": "jerryguitarist@gmail.com",
 | 
			
		||||
            "phone": "+17982347588",
 | 
			
		||||
            "name": "Eeshan Garg",
 | 
			
		||||
            "pseudonym": "Azure Bus from St. John's",
 | 
			
		||||
            "avatar": {
 | 
			
		||||
                "type": "avatar",
 | 
			
		||||
                "image_url": "https://img.fullcontact.com/static/85ce413bcdac4cec3cfdb3a8da530f8b_8a853b478c3122d7e4ec9e14f81d9a3d9ea9da198d85c1985efc2403fa6bdb0c"
 | 
			
		||||
            },
 | 
			
		||||
            "app_id": "i6wc9ipe",
 | 
			
		||||
            "companies": {
 | 
			
		||||
                "type": "company.list",
 | 
			
		||||
                "companies": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "type": "company",
 | 
			
		||||
                        "company_id": "5c96b2c0d1c4c1a2d455b936-qualification-company",
 | 
			
		||||
                        "id": "5c96b2c0d1c4c1a2d455b937",
 | 
			
		||||
                        "name": "Kandra Labs"
 | 
			
		||||
                    }
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "location_data": {
 | 
			
		||||
                "type": "location_data",
 | 
			
		||||
                "city_name": "St. John's",
 | 
			
		||||
                "continent_code": "NA",
 | 
			
		||||
                "country_name": "Canada",
 | 
			
		||||
                "postal_code": "A1B",
 | 
			
		||||
                "region_name": "Newfoundland and Labrador",
 | 
			
		||||
                "timezone": "America/St_Johns",
 | 
			
		||||
                "country_code": "CAN",
 | 
			
		||||
                "latitude": null,
 | 
			
		||||
                "longitude": null
 | 
			
		||||
            },
 | 
			
		||||
            "last_request_at": "2019-03-23T22:20:52.453+00:00",
 | 
			
		||||
            "created_at": "2019-03-23T22:20:18.253+00:00",
 | 
			
		||||
            "remote_created_at": null,
 | 
			
		||||
            "signed_up_at": null,
 | 
			
		||||
            "updated_at": "2019-03-23T22:28:55.055+00:00",
 | 
			
		||||
            "session_count": 0,
 | 
			
		||||
            "social_profiles": {
 | 
			
		||||
                "type": "social_profile.list",
 | 
			
		||||
                "social_profiles": [
 | 
			
		||||
                    {
 | 
			
		||||
                        "type": "social_profile",
 | 
			
		||||
                        "name": "github",
 | 
			
		||||
                        "id": null,
 | 
			
		||||
                        "username": "eeshangarg",
 | 
			
		||||
                        "url": "https://github.com/eeshangarg"
 | 
			
		||||
                    }
 | 
			
		||||
                ]
 | 
			
		||||
            },
 | 
			
		||||
            "unsubscribed_from_emails": true,
 | 
			
		||||
            "marked_email_as_spam": false,
 | 
			
		||||
            "has_hard_bounced": false,
 | 
			
		||||
            "tags": {
 | 
			
		||||
                "type": "tag.list",
 | 
			
		||||
                "tags": []
 | 
			
		||||
            },
 | 
			
		||||
            "segments": {
 | 
			
		||||
                "type": "segment.list",
 | 
			
		||||
                "segments": []
 | 
			
		||||
            },
 | 
			
		||||
            "custom_attributes": {},
 | 
			
		||||
            "referrer": null,
 | 
			
		||||
            "utm_campaign": null,
 | 
			
		||||
            "utm_content": null,
 | 
			
		||||
            "utm_medium": null,
 | 
			
		||||
            "utm_source": null,
 | 
			
		||||
            "utm_term": null,
 | 
			
		||||
            "do_not_track": null,
 | 
			
		||||
            "last_seen_ip": null,
 | 
			
		||||
            "user_agent_data": null
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "links": {},
 | 
			
		||||
    "id": "notif_71d6309c-0655-4793-86e5-19141d36642b",
 | 
			
		||||
    "topic": "user.unsubscribed",
 | 
			
		||||
    "delivery_status": "pending",
 | 
			
		||||
    "delivery_attempts": 1,
 | 
			
		||||
    "delivered_at": 0,
 | 
			
		||||
    "first_sent_at": 1553380135,
 | 
			
		||||
    "created_at": 1553380135,
 | 
			
		||||
    "self": null
 | 
			
		||||
}
 | 
			
		||||
@@ -1,3 +1,5 @@
 | 
			
		||||
from mock import MagicMock, patch
 | 
			
		||||
 | 
			
		||||
from zerver.lib.test_classes import WebhookTestCase
 | 
			
		||||
 | 
			
		||||
class IntercomWebHookTests(WebhookTestCase):
 | 
			
		||||
@@ -5,15 +7,261 @@ class IntercomWebHookTests(WebhookTestCase):
 | 
			
		||||
    URL_TEMPLATE = "/api/v1/external/intercom?&api_key={api_key}&stream={stream}"
 | 
			
		||||
    FIXTURE_DIR_NAME = 'intercom'
 | 
			
		||||
 | 
			
		||||
    def test_user_created_message(self) -> None:
 | 
			
		||||
        expected_topic = u"user tag created"
 | 
			
		||||
        expected_message = ('*10:43:22 2017-12-17* **user tag created**: \n'
 | 
			
		||||
                            ' - User Name: John Doe\n'
 | 
			
		||||
                            ' - User Email: john.doe@gmail.com\n'
 | 
			
		||||
                            ' - User Phone: 9876543211')
 | 
			
		||||
    @patch('zerver.webhooks.intercom.view.check_send_webhook_message')
 | 
			
		||||
    def test_ping_ignore(self, check_send_webhook_message_mock: MagicMock) -> None:
 | 
			
		||||
        self.url = self.build_webhook_url()
 | 
			
		||||
        payload = self.get_body('ping')
 | 
			
		||||
        result = self.client_post(self.url, payload, content_type="application/json")
 | 
			
		||||
        self.assertFalse(check_send_webhook_message_mock.called)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
 | 
			
		||||
        self.send_and_test_stream_message('user_created', expected_topic, expected_message,
 | 
			
		||||
                                          content_type="application/x-www-form-urlencoded")
 | 
			
		||||
    def test_company_created(self) -> None:
 | 
			
		||||
        expected_topic = "Companies"
 | 
			
		||||
        expected_message = """
 | 
			
		||||
New company **Kandra Labs** created:
 | 
			
		||||
* **User count**: 1
 | 
			
		||||
* **Monthly spending**: 0
 | 
			
		||||
""".strip()
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'company_created',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_contact_added_email(self) -> None:
 | 
			
		||||
        expected_topic = "Contact: Azure Bus from St. John's"
 | 
			
		||||
        expected_message = "New email jerryguitarist@gmail.com added to contact."
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'contact_added_email',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_contact_created(self) -> None:
 | 
			
		||||
        expected_topic = "Contact: Azure Bus from St. John's"
 | 
			
		||||
        expected_message = """
 | 
			
		||||
New contact created:
 | 
			
		||||
* **Name (or pseudonym)**: Azure Bus from St. John's
 | 
			
		||||
* **Email**: aaron@zulip.com
 | 
			
		||||
* **Location**: St. John's, Newfoundland and Labrador, Canada
 | 
			
		||||
""".strip()
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'contact_created',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_contact_signed_up(self) -> None:
 | 
			
		||||
        expected_topic = "User: Lilac Raindrop from St. John's"
 | 
			
		||||
        expected_message = """
 | 
			
		||||
Contact signed up:
 | 
			
		||||
* **Email**: iago@zulip.com
 | 
			
		||||
* **Location**: St. John's, Newfoundland and Labrador, Canada
 | 
			
		||||
""".strip()
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'contact_signed_up',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_contact_tag_created(self) -> None:
 | 
			
		||||
        expected_topic = "Contact: Eeshan Garg"
 | 
			
		||||
        expected_message = "Contact tagged with the `developer` tag."
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'contact_tag_created',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_contact_tag_deleted(self) -> None:
 | 
			
		||||
        expected_topic = "Contact: Eeshan Garg"
 | 
			
		||||
        expected_message = "The tag `developer` was removed from the contact."
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'contact_tag_deleted',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_conversation_admin_assigned(self) -> None:
 | 
			
		||||
        expected_topic = "Lead: Eeshan Garg"
 | 
			
		||||
        expected_message = "Tim Abbott assigned to conversation."
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'conversation_admin_assigned',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_conversation_admin_opened(self) -> None:
 | 
			
		||||
        expected_topic = "Lead: Cordelia Lear"
 | 
			
		||||
        expected_message = "Eeshan Garg opened the conversation."
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'conversation_admin_opened',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_conversation_admin_closed(self) -> None:
 | 
			
		||||
        expected_topic = "Lead: Eeshan Garg"
 | 
			
		||||
        expected_message = "Cordelia Lear closed the conversation."
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'conversation_admin_closed',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_conversation_admin_snoozed(self) -> None:
 | 
			
		||||
        expected_topic = "Lead: Eeshan Garg"
 | 
			
		||||
        expected_message = "Cordelia Lear snoozed the conversation."
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'conversation_admin_snoozed',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_conversation_admin_unsnoozed(self) -> None:
 | 
			
		||||
        expected_topic = "Lead: Eeshan Garg"
 | 
			
		||||
        expected_message = "Cordelia Lear unsnoozed the conversation."
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'conversation_admin_unsnoozed',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_conversation_admin_replied(self) -> None:
 | 
			
		||||
        expected_topic = "Lead: Eeshan Garg"
 | 
			
		||||
        expected_message = """
 | 
			
		||||
Cordelia Lear replied to the conversation:
 | 
			
		||||
 | 
			
		||||
``` quote
 | 
			
		||||
Hey Eeshan! How can I help?
 | 
			
		||||
```
 | 
			
		||||
""".strip()
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'conversation_admin_replied',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_conversation_admin_noted(self) -> None:
 | 
			
		||||
        expected_topic = "Lead: Eeshan Garg"
 | 
			
		||||
        expected_message = """
 | 
			
		||||
Cordelia Lear added a note to the conversation:
 | 
			
		||||
 | 
			
		||||
``` quote
 | 
			
		||||
Talk to Tim about this user's query.
 | 
			
		||||
```
 | 
			
		||||
""".strip()
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'conversation_admin_noted',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_conversation_admin_single_created(self) -> None:
 | 
			
		||||
        expected_topic = "Lead: Eeshan Garg"
 | 
			
		||||
        expected_message = """
 | 
			
		||||
Cordelia Lear initiated a conversation:
 | 
			
		||||
 | 
			
		||||
``` quote
 | 
			
		||||
Hi Eeshan, What's up
 | 
			
		||||
```
 | 
			
		||||
""".strip()
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'conversation_admin_single_created',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_conversation_user_created(self) -> None:
 | 
			
		||||
        expected_topic = "Lead: Rose Poodle from St. John's"
 | 
			
		||||
        expected_message = """
 | 
			
		||||
Rose Poodle from St. John's initiated a conversation:
 | 
			
		||||
 | 
			
		||||
``` quote
 | 
			
		||||
Hello everyone!
 | 
			
		||||
```
 | 
			
		||||
""".strip()
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'conversation_user_created',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_conversation_user_replied(self) -> None:
 | 
			
		||||
        expected_topic = "Lead: Eeshan Garg"
 | 
			
		||||
        expected_message = """
 | 
			
		||||
Eeshan Garg replied to the conversation:
 | 
			
		||||
 | 
			
		||||
``` quote
 | 
			
		||||
Well, I need some help getting access to a developer account.
 | 
			
		||||
```
 | 
			
		||||
""".strip()
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'conversation_user_replied',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_event_created(self) -> None:
 | 
			
		||||
        expected_topic = "Events"
 | 
			
		||||
        expected_message = "New event **invited-friend** created."
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'event_created',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_user_created(self) -> None:
 | 
			
		||||
        expected_topic = "User: Aaron Smith"
 | 
			
		||||
        expected_message = """
 | 
			
		||||
New user created:
 | 
			
		||||
* **Name**: Aaron Smith
 | 
			
		||||
* **Email**: aaron@zulip.com
 | 
			
		||||
""".strip()
 | 
			
		||||
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'user_created',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_user_deleted(self) -> None:
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'user_deleted',
 | 
			
		||||
            'User: jerryguitarist@gmail.com',
 | 
			
		||||
            'User deleted.'
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_user_email_updated(self) -> None:
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'user_email_updated',
 | 
			
		||||
            'Contact: Azure Bus from St. John\'s',
 | 
			
		||||
            'User\'s email was updated to aaron@zulip.com.'
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_user_tag_created(self) -> None:
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'user_tag_created',
 | 
			
		||||
            'User: eeshangarg',
 | 
			
		||||
            'The tag `developer` was added to the user.'
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_user_tag_deleted(self) -> None:
 | 
			
		||||
        expected_topic = 'User: eeshangarg'
 | 
			
		||||
        expected_message = 'The tag `CSV Import - 2019-03-26 22:46:04 UTC` was removed from the user.'
 | 
			
		||||
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'user_tag_deleted',
 | 
			
		||||
            expected_topic,
 | 
			
		||||
            expected_message
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_user_unsubscribed(self) -> None:
 | 
			
		||||
        self.send_and_test_stream_message(
 | 
			
		||||
            'user_unsubscribed',
 | 
			
		||||
            'Contact: Eeshan Garg',
 | 
			
		||||
            'User unsubscribed from emails.'
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def get_body(self, fixture_name: str) -> str:
 | 
			
		||||
        return self.webhook_fixture_data('intercom', fixture_name, file_type="json")
 | 
			
		||||
 
 | 
			
		||||
@@ -1,29 +1,297 @@
 | 
			
		||||
import datetime
 | 
			
		||||
from typing import Any, Dict
 | 
			
		||||
from functools import partial
 | 
			
		||||
from html.parser import HTMLParser
 | 
			
		||||
from typing import Any, Dict, Tuple, Callable, List
 | 
			
		||||
 | 
			
		||||
from django.http import HttpRequest, HttpResponse
 | 
			
		||||
 | 
			
		||||
from zerver.decorator import api_key_only_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.lib.webhooks.common import check_send_webhook_message, \
 | 
			
		||||
    UnexpectedWebhookEventType
 | 
			
		||||
from zerver.models import UserProfile
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
COMPANY_CREATED = """
 | 
			
		||||
New company **{name}** created:
 | 
			
		||||
* **User count**: {user_count}
 | 
			
		||||
* **Monthly spending**: {monthly_spend}
 | 
			
		||||
""".strip()
 | 
			
		||||
 | 
			
		||||
CONTACT_EMAIL_ADDED = "New email {email} added to contact."
 | 
			
		||||
 | 
			
		||||
CONTACT_CREATED = """
 | 
			
		||||
New contact created:
 | 
			
		||||
* **Name (or pseudonym)**: {name}
 | 
			
		||||
* **Email**: {email}
 | 
			
		||||
* **Location**: {location_info}
 | 
			
		||||
""".strip()
 | 
			
		||||
 | 
			
		||||
CONTACT_SIGNED_UP = """
 | 
			
		||||
Contact signed up:
 | 
			
		||||
* **Email**: {email}
 | 
			
		||||
* **Location**: {location_info}
 | 
			
		||||
""".strip()
 | 
			
		||||
 | 
			
		||||
CONTACT_TAG_CREATED = "Contact tagged with the `{name}` tag."
 | 
			
		||||
 | 
			
		||||
CONTACT_TAG_DELETED = "The tag `{name}` was removed from the contact."
 | 
			
		||||
 | 
			
		||||
CONVERSATION_ADMIN_ASSIGNED = "{name} assigned to conversation."
 | 
			
		||||
 | 
			
		||||
CONVERSATION_ADMIN_TEMPLATE = "{admin_name} {action} the conversation."
 | 
			
		||||
 | 
			
		||||
CONVERSATION_ADMIN_REPLY_TEMPLATE = """
 | 
			
		||||
{admin_name} {action} the conversation:
 | 
			
		||||
 | 
			
		||||
``` quote
 | 
			
		||||
{content}
 | 
			
		||||
```
 | 
			
		||||
""".strip()
 | 
			
		||||
 | 
			
		||||
CONVERSATION_ADMIN_INITIATED_CONVERSATION = """
 | 
			
		||||
{admin_name} initiated a conversation:
 | 
			
		||||
 | 
			
		||||
``` quote
 | 
			
		||||
{content}
 | 
			
		||||
```
 | 
			
		||||
""".strip()
 | 
			
		||||
 | 
			
		||||
EVENT_CREATED = "New event **{event_name}** created."
 | 
			
		||||
 | 
			
		||||
USER_CREATED = """
 | 
			
		||||
New user created:
 | 
			
		||||
* **Name**: {name}
 | 
			
		||||
* **Email**: {email}
 | 
			
		||||
""".strip()
 | 
			
		||||
 | 
			
		||||
class MLStripper(HTMLParser):
 | 
			
		||||
    def __init__(self) -> None:
 | 
			
		||||
        self.reset()
 | 
			
		||||
        self.strict = False
 | 
			
		||||
        self.convert_charrefs = True
 | 
			
		||||
        self.fed = []  # type: List[str]
 | 
			
		||||
 | 
			
		||||
    def handle_data(self, d: str) -> None:
 | 
			
		||||
        self.fed.append(d)
 | 
			
		||||
 | 
			
		||||
    def get_data(self) -> str:
 | 
			
		||||
        return ''.join(self.fed)
 | 
			
		||||
 | 
			
		||||
def strip_tags(html: str) -> str:
 | 
			
		||||
    s = MLStripper()
 | 
			
		||||
    s.feed(html)
 | 
			
		||||
    return s.get_data()
 | 
			
		||||
 | 
			
		||||
def get_topic_for_contacts(user: Dict[str, Any]) -> str:
 | 
			
		||||
    topic = "{type}: {name}".format(
 | 
			
		||||
        type=user['type'].capitalize(),
 | 
			
		||||
        name=user.get('name') or user.get('pseudonym') or user.get('email')
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    return topic
 | 
			
		||||
 | 
			
		||||
def get_company_created_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    body = COMPANY_CREATED.format(**payload['data']['item'])
 | 
			
		||||
    return ('Companies', body)
 | 
			
		||||
 | 
			
		||||
def get_contact_added_email_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    user = payload['data']['item']
 | 
			
		||||
    body = CONTACT_EMAIL_ADDED.format(email=user['email'])
 | 
			
		||||
    topic = get_topic_for_contacts(user)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_contact_created_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    contact = payload['data']['item']
 | 
			
		||||
    body = CONTACT_CREATED.format(
 | 
			
		||||
        name=contact.get('name') or contact.get('pseudonym'),
 | 
			
		||||
        email=contact['email'],
 | 
			
		||||
        location_info="{city_name}, {region_name}, {country_name}".format(
 | 
			
		||||
            **contact['location_data']
 | 
			
		||||
        )
 | 
			
		||||
    )
 | 
			
		||||
    topic = get_topic_for_contacts(contact)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_contact_signed_up_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    contact = payload['data']['item']
 | 
			
		||||
    body = CONTACT_SIGNED_UP.format(
 | 
			
		||||
        email=contact['email'],
 | 
			
		||||
        location_info="{city_name}, {region_name}, {country_name}".format(
 | 
			
		||||
            **contact['location_data']
 | 
			
		||||
        )
 | 
			
		||||
    )
 | 
			
		||||
    topic = get_topic_for_contacts(contact)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_contact_tag_created_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    body = CONTACT_TAG_CREATED.format(**payload['data']['item']['tag'])
 | 
			
		||||
    contact = payload['data']['item']['contact']
 | 
			
		||||
    topic = get_topic_for_contacts(contact)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_contact_tag_deleted_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    body = CONTACT_TAG_DELETED.format(**payload['data']['item']['tag'])
 | 
			
		||||
    contact = payload['data']['item']['contact']
 | 
			
		||||
    topic = get_topic_for_contacts(contact)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_conversation_admin_assigned_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    body = CONVERSATION_ADMIN_ASSIGNED.format(**payload['data']['item']['assignee'])
 | 
			
		||||
    user = payload['data']['item']['user']
 | 
			
		||||
    topic = get_topic_for_contacts(user)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_conversation_admin_message(
 | 
			
		||||
        payload: Dict[str, Any],
 | 
			
		||||
        action: str
 | 
			
		||||
) -> Tuple[str, str]:
 | 
			
		||||
    assignee = payload['data']['item']['assignee']
 | 
			
		||||
    user = payload['data']['item']['user']
 | 
			
		||||
    body = CONVERSATION_ADMIN_TEMPLATE.format(
 | 
			
		||||
        admin_name=assignee.get('name'),
 | 
			
		||||
        action=action
 | 
			
		||||
    )
 | 
			
		||||
    topic = get_topic_for_contacts(user)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_conversation_admin_reply_message(
 | 
			
		||||
        payload: Dict[str, Any],
 | 
			
		||||
        action: str
 | 
			
		||||
) -> Tuple[str, str]:
 | 
			
		||||
    assignee = payload['data']['item']['assignee']
 | 
			
		||||
    user = payload['data']['item']['user']
 | 
			
		||||
    note = payload['data']['item']['conversation_parts']['conversation_parts'][0]
 | 
			
		||||
    content = strip_tags(note['body'])
 | 
			
		||||
    body = CONVERSATION_ADMIN_REPLY_TEMPLATE.format(
 | 
			
		||||
        admin_name=assignee.get('name'),
 | 
			
		||||
        action=action,
 | 
			
		||||
        content=content
 | 
			
		||||
    )
 | 
			
		||||
    topic = get_topic_for_contacts(user)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_conversation_admin_single_created_message(
 | 
			
		||||
        payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    assignee = payload['data']['item']['assignee']
 | 
			
		||||
    user = payload['data']['item']['user']
 | 
			
		||||
    conversation_body = payload['data']['item']['conversation_message']['body']
 | 
			
		||||
    content = strip_tags(conversation_body)
 | 
			
		||||
    body = CONVERSATION_ADMIN_INITIATED_CONVERSATION.format(
 | 
			
		||||
        admin_name=assignee.get('name'),
 | 
			
		||||
        content=content
 | 
			
		||||
    )
 | 
			
		||||
    topic = get_topic_for_contacts(user)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_conversation_user_created_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    user = payload['data']['item']['user']
 | 
			
		||||
    conversation_body = payload['data']['item']['conversation_message']['body']
 | 
			
		||||
    content = strip_tags(conversation_body)
 | 
			
		||||
    body = CONVERSATION_ADMIN_INITIATED_CONVERSATION.format(
 | 
			
		||||
        admin_name=user.get('name'),
 | 
			
		||||
        content=content
 | 
			
		||||
    )
 | 
			
		||||
    topic = get_topic_for_contacts(user)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_conversation_user_replied_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    user = payload['data']['item']['user']
 | 
			
		||||
    note = payload['data']['item']['conversation_parts']['conversation_parts'][0]
 | 
			
		||||
    content = strip_tags(note['body'])
 | 
			
		||||
    body = CONVERSATION_ADMIN_REPLY_TEMPLATE.format(
 | 
			
		||||
        admin_name=user.get('name'),
 | 
			
		||||
        action='replied to',
 | 
			
		||||
        content=content
 | 
			
		||||
    )
 | 
			
		||||
    topic = get_topic_for_contacts(user)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_event_created_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    event = payload['data']['item']
 | 
			
		||||
    body = EVENT_CREATED.format(**event)
 | 
			
		||||
    return ('Events', body)
 | 
			
		||||
 | 
			
		||||
def get_user_created_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    user = payload['data']['item']
 | 
			
		||||
    body = USER_CREATED.format(**user)
 | 
			
		||||
    topic = get_topic_for_contacts(user)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_user_deleted_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    user = payload['data']['item']
 | 
			
		||||
    topic = get_topic_for_contacts(user)
 | 
			
		||||
    return (topic, 'User deleted.')
 | 
			
		||||
 | 
			
		||||
def get_user_email_updated_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    user = payload['data']['item']
 | 
			
		||||
    body = 'User\'s email was updated to {}.'.format(user['email'])
 | 
			
		||||
    topic = get_topic_for_contacts(user)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_user_tagged_message(
 | 
			
		||||
        payload: Dict[str, Any],
 | 
			
		||||
        action: str
 | 
			
		||||
) -> Tuple[str, str]:
 | 
			
		||||
    user = payload['data']['item']['user']
 | 
			
		||||
    tag = payload['data']['item']['tag']
 | 
			
		||||
    topic = get_topic_for_contacts(user)
 | 
			
		||||
    body = 'The tag `{tag_name}` was {action} the user.'.format(
 | 
			
		||||
        tag_name=tag['name'],
 | 
			
		||||
        action=action
 | 
			
		||||
    )
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
def get_user_unsubscribed_message(payload: Dict[str, Any]) -> Tuple[str, str]:
 | 
			
		||||
    user = payload['data']['item']
 | 
			
		||||
    body = 'User unsubscribed from emails.'
 | 
			
		||||
    topic = get_topic_for_contacts(user)
 | 
			
		||||
    return (topic, body)
 | 
			
		||||
 | 
			
		||||
EVENT_TO_FUNCTION_MAPPER = {
 | 
			
		||||
    'company.created': get_company_created_message,
 | 
			
		||||
    'contact.added_email': get_contact_added_email_message,
 | 
			
		||||
    'contact.created': get_contact_created_message,
 | 
			
		||||
    'contact.signed_up': get_contact_signed_up_message,
 | 
			
		||||
    'contact.tag.created': get_contact_tag_created_message,
 | 
			
		||||
    'contact.tag.deleted': get_contact_tag_deleted_message,
 | 
			
		||||
    'conversation.admin.assigned': get_conversation_admin_assigned_message,
 | 
			
		||||
    'conversation.admin.closed': partial(get_conversation_admin_message, action='closed'),
 | 
			
		||||
    'conversation.admin.opened': partial(get_conversation_admin_message, action='opened'),
 | 
			
		||||
    'conversation.admin.snoozed': partial(get_conversation_admin_message, action='snoozed'),
 | 
			
		||||
    'conversation.admin.unsnoozed': partial(get_conversation_admin_message, action='unsnoozed'),
 | 
			
		||||
    'conversation.admin.replied': partial(get_conversation_admin_reply_message, action='replied to'),
 | 
			
		||||
    'conversation.admin.noted': partial(get_conversation_admin_reply_message, action='added a note to'),
 | 
			
		||||
    'conversation.admin.single.created': get_conversation_admin_single_created_message,
 | 
			
		||||
    'conversation.user.created': get_conversation_user_created_message,
 | 
			
		||||
    'conversation.user.replied': get_conversation_user_replied_message,
 | 
			
		||||
    'event.created': get_event_created_message,
 | 
			
		||||
    'user.created': get_user_created_message,
 | 
			
		||||
    'user.deleted': get_user_deleted_message,
 | 
			
		||||
    'user.email.updated': get_user_email_updated_message,
 | 
			
		||||
    'user.tag.created': partial(get_user_tagged_message, action='added to'),
 | 
			
		||||
    'user.tag.deleted': partial(get_user_tagged_message, action='removed from'),
 | 
			
		||||
    'user.unsubscribed': get_user_unsubscribed_message,
 | 
			
		||||
    # Note that we do not have a payload for visitor.signed_up
 | 
			
		||||
    # but it should be identical to contact.signed_up
 | 
			
		||||
    'visitor.signed_up': get_contact_signed_up_message,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
def get_event_handler(event_type: str) -> Callable[..., Tuple[str, str]]:
 | 
			
		||||
    handler = EVENT_TO_FUNCTION_MAPPER.get(event_type)  # type: Any
 | 
			
		||||
    if handler is None:
 | 
			
		||||
        raise UnexpectedWebhookEventType("Intercom", event_type)
 | 
			
		||||
    return handler
 | 
			
		||||
 | 
			
		||||
@api_key_only_webhook_view('Intercom')
 | 
			
		||||
@has_request_variables
 | 
			
		||||
def api_intercom_webhook(request: HttpRequest, user_profile: UserProfile,
 | 
			
		||||
                         payload: Dict[str, Any] = REQ(argument_type='body')) -> HttpResponse:
 | 
			
		||||
    topic = payload['topic']
 | 
			
		||||
    topic = topic.replace('.', ' ')
 | 
			
		||||
                         payload: Dict[str, Any]=REQ(argument_type='body')) -> HttpResponse:
 | 
			
		||||
    event_type = payload['topic']
 | 
			
		||||
    if event_type == 'ping':
 | 
			
		||||
        return json_success()
 | 
			
		||||
 | 
			
		||||
    created_at = datetime.datetime.fromtimestamp(int(payload['created_at'])).strftime('%H:%M:%S %Y-%m-%d')
 | 
			
		||||
    body = '*{created_at}* **{topic}**: \n'.format(topic=topic, created_at=created_at)
 | 
			
		||||
 | 
			
		||||
    if payload['data']['item']['type'] == 'user_tag':
 | 
			
		||||
        data = payload['data']['item']['user']
 | 
			
		||||
        body += ' - User Name: {}\n' \
 | 
			
		||||
                ' - User Email: {}\n' \
 | 
			
		||||
                ' - User Phone: {}\n'.format(data['name'], data['email'], data['phone'])
 | 
			
		||||
    topic, body = get_event_handler(event_type)(payload)
 | 
			
		||||
 | 
			
		||||
    check_send_webhook_message(request, user_profile, topic, body)
 | 
			
		||||
    return json_success()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user