Skip to content

Channel Web Hooks

Channel web hooks allows to post any content to a channel or create cases in channel. Channel web hooks are created in channel properties.

Creating a New Web Hook

To create a new web hook please follow these steps;

  • Open a channel where you want to create a web hook

  • Select "Edit" from the channel menu

  • Switch to the "Web Hooks" tabs and click on to "Add New" button

  • Web hook URL is automatically generated, enter the purpose of the channel

  • Click the "Copy" button next to the Url field to copy Url to the clipboard.

  • Click Ok to save changes.

channel_web_hooks.png

Posting Channel Activity

After the web hook is created you can post JSON data to create a new activity on the channel. Web hook URL contains all the required information and does not need any authentication.

Posting Basic Message

```http request POST /hooks/channels/f923d83a-3350-42d0-b9cb-620032730294/8459b574-62ea-4ea7-bbae-a132fbfee5df Host: my.emakin.com Content-Type: application/json

{ "text" : "my message" }

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
![webhook_basic_message.png](./attachments/webhook_basic_message.png)

## Posting Message with Attachments

As another example, you can post the following JSON to send a message with attachments.

```http request
POST /hooks/channels/f923d83a-3350-42d0-b9cb-620032730294/8459b574-62ea-4ea7-bbae-a132fbfee5df
Host: my.emakin.com
Content-Type: application/json

{
    "text" : "my message",
    "attachments" : [
    {
        "@type": "file",
        "displayName": "my file",
        "ext": "txt",
        "url": "http://myserver/myfile"
    },
    {
        "@type": "link",
        "url": "http://www.google.com",
        "displayName": "http://www.google.com"
    }]
}

webhook_message_attachments.png

Creating a New Case In Channel

When JSON data contains an "id" property, web hook creates a new case instead of just posting a message. Id field must be unique for the channel or otherwise, the web hook ignores the message and returns the already reported status.

```http request POST /hooks/channels/f923d83a-3350-42d0-b9cb-620032730294/8459b574-62ea-4ea7-bbae-a132fbfee5df Host: my.emakin.com Content-Type: application/json

{ "id" : "event1", "text" : "my message", "attachments" : [ { "@type": "file", "displayName": "my file", "ext": "txt", "url": "http://myserver/myfile" }, { "@type": "link", "url": "http://www.google.com", "displayName": "http://www.google.com" }] }

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
JSON with "id" property automatically creates a new case and attaches the message to the case.

![webhook_case_message.png](./attachments/webhook_case_message.png)

## Updating a Case

Web hooks also support receiving notifications about previously posted messages.

To post a new update message to an existing case, JSON data must contain a "references" property that contains the
previously reported message id.

```http request
POST /hooks/channels/f923d83a-3350-42d0-b9cb-620032730294/8459b574-62ea-4ea7-bbae-a132fbfee5df
Host: my.emakin.com
Content-Type: application/json

{
    "id" : "event2",
    "references" : [ "event1" ],
    "text" : "my message",
    "attachments" : [
    {
        "@type": "file",
        "displayName": "my file",
        "ext": "txt",
        "url": "http://myserver/myfile"
    },
    {
        "@type": "link",
        "url": "http://www.google.com",
        "displayName": "http://www.google.com"
    }]
}

JSON with "references" automatically appends a new message to an existing case as an update message.

webhook_case_update.png