Webhooks

설정

TalkPlus 대시보드에서 다음과 같이 webhook 설정을 할 수 있습니다:

  • Webhook 기능 활성화

  • 이벤트 트리거 대상 endpoint 입력

  • Webhook를 트리거할 이벤트 선택

Endpoint

  • HTTP POST request를 받을 수 있어야 합니다.

  • JSON 형태의 이벤트 데이터를 처리할 수 있어야 합니다.

TalkPlus 서버에서 endpoint를 호출하고 응답이 없을 시, 5초 이후 1회 재시도 합니다.

TalkPlus에서는 다음 헤더 값을 가지고 endpoint를 호출합니다.

User-Agent

TalkPlus

content-type

application/json

x-talkplus-signature

payload를 App API Key로 sign하고(SHA-256) 결과값을 base64로 인코딩한 값

Verification

TalkPlus서버에서 보낸 request 진위여부를 확인하기 위해, request header의 x-talkplus-signature 값과 response body의 해시값을 직접 계산하여 동일한지 확인 할 수 있습니다.

responseBody := "{\"event\":\"channel_added\",\"appId\":\"34f633c9-b012-4ca9-b453-2a4a460f464a\",\"channel\":{\"id\":\"webhook_test\",\"name\":\"webhook_test\",\"imageUrl\":\"\",\"data\":{\"test\":\"1\"},\"ownerId\":\"test1\",\"type\":\"public\",\"category\":\"categoryA\",\"subcategory\":\"subcategoryB\",\"privateTag\":\"\",\"invitationCode\":\"\",\"isFrozen\":false,\"memberCount\":1,\"maxMemberCount\":100,\"hideMessagesBeforeJoin\":false,\"members\":[{\"id\":\"test1\",\"username\":\"test1\",\"profileImageUrl\":\"\",\"disablePushNotification\":false,\"data\":{\"test\":\"1\"},\"updatedAt\":1699606163973,\"createdAt\":1697797296688,\"memberInfo\":{},\"lastReadAt\":0,\"lastSentAt\":0}],\"bannedUsers\":[],\"lastSentAt\":1699606164578,\"updatedAt\":0,\"createdAt\":1699606164578,\"mutedUsers\":[],\"pushNotificationDisabled\":false,\"pushNotificationSoundAOS\":\"\",\"pushNotificationSoundIOS\":\"\",\"privateData\":null,\"unreadCount\":0,\"lastReadAt\":0,\"lastMessage\":null}}"
apiKey := "92935b03e231483fc2cf75d9020f7e492c8fd9c7481eb4c79620ace7fe207d81"
signatureFromHeader := "i7a/Z+7iS1P6kNpnmw6P0ZSmq83LGnrtacwaffTvIdo="

hash := hmac.New(sha256.New, []byte(apiKey))
hash.Write([]byte(responseBody))
computedSignature := base64.StdEncoding.EncodeToString(hash.Sum(nil))

fmt.Printf("signatures match: %v\n", signatureFromHeader == computedSignature)

Webhook Events

Event

Trigger

message

메시지 전송

message_deleted

메시지 삭제

reaction_added

메시지 리액션 추가

reaction_deleted

메시지 리액션 삭제

channel_added

채널 생성

channel_changed

채널 수정

channel_removed

채널 삭제

member_added

채널에 사용자 추가

member_left

채널에서 사용자 나감 또는 제외됨

member_banned

채널 사용자 차단

member_unbanned

채널 사용자 차단 해제

user_blocked

사용자 차단

user_unblocked

사용자 차단 해제

Webhook Event Payloads

message

{
    "event": "message",
    "appId": "YOUR_APP_ID",
    "channel":
    {
        "id": "YOUR_CHANNEL_ID",
        "name": "YOUR_CHANNEL_NAME",
        "ownerId": "user123",
        "type": "public",
        "imageUrl": "image url",
        "invitationCode": "",
        "isFrozen": false,
        "hideMessagesBeforeJoin": false,
        "category": "",
        "subcategory": "",
        "memberCount": 1,
        "maxMemberCount": 100,
        "data": {
            "someMetaKey1": "someMetaValue1",
            "someMetaKey2": "someMetaValue2"
        },
        "members":
        [
            {
                "id": "user123",
                "username": "user123",
                "profileImageUrl": "http://cnd.test.com/123.jpg",
                "updatedAt": 1603184094285,
                "createdAt": 1603184094285,
                "lastReadAt": 0,
                "lastSentAt": 1603244275376
            }
        ],
        "mutedUsers": [],
        "bannedUsers": [],
        "updatedAt": 0,
        "createdAt": 0,
        "unreadCount": 0,
        "lastReadAt": 0,
        "lastMessage":
        {
            "id": "sdf2l5s9j",
            "channelId": "YOUR_CHANNEL_ID",
            "userId": "user123",
            "username": "user123",
            "profileImageUrl": "http://cdn.test.com/123.jpg",
            "type": "text",
            "text": "Hello world",
            "translations": {},
            "data": {
                "customField": "customData"
            },
            "createdAt": 1583921400
        }
    },
    "sender":
    {
        "id": "user123",
        "username": "user123",
        "profileImageUrl": "http://cnd.test.com/123.jpg",
        "updatedAt": 1583924400,
        "createdAt": 1583921400
    },
    "message":
    {
        "id": "sdf2l5s9j",
        "channelId": "YOUR_CHANNEL_ID",
        "userId": "user123",
        "username": "user123",
        "profileImageUrl": "http://cdn.test.com/123.jpg",
        "type": "text",
        "text": "Hello world",
        "translations": {},
        "data":
        {
            "customField": "customData"
        },
        "createdAt": 1583921400
    }
}

message_deleted

{
    "event": "message_deleted",
    "appId": "YOUR_APP_ID",
    "channel":
    {
        "id": "YOUR_CHANNEL_ID",
        "name": "YOUR_CHANNEL_NAME",
        "ownerId": "user123",
        "type": "public",
        "invitationCode": "",
        "isFrozen": false,
        "hideMessagesBeforeJoin": false,
        "category": "",
        "subcategory": "",
        "memberCount": 1,
        "maxMemberCount": 100,
        "data": {
            "someMetaKey1": "someMetaValue1",
            "someMetaKey2": "someMetaValue2"
        },
        "members":
        [
            {
                "id": "user123",
                "username": "user123",
                "profileImageUrl": "http://cnd.test.com/123.jpg",
                "updatedAt": 1603184094285,
                "createdAt": 1603184094285,
                "lastReadAt": 0,
                "lastSentAt": 1603244275376
            }
        ],
        "mutedUsers": [],
        "bannedUsers": [],
        "updatedAt": 0,
        "createdAt": 0,
        "unreadCount": 0,
        "lastReadAt": 0,
        "lastMessage":
        {
            "id": "sdf2l5s9j",
            "channelId": "YOUR_CHANNEL_ID",
            "userId": "user123",
            "username": "user123",
            "profileImageUrl": "http://cdn.test.com/123.jpg",
            "type": "text",
            "text": "Hello world",
            "translations": {},
            "data":
            {
                "customField": "customData"
            },
            "createdAt": 1583921400
        }
    },
    "sender": // might be empty
    {
        "id": "user123",
        "username": "user123",
        "profileImageUrl": "http://cnd.test.com/123.jpg",
        "updatedAt": 1583924400,
        "createdAt": 1583921400
    },
    "message":
    {
        "id": "sdf2l5s9j",
        "channelId": "YOUR_CHANNEL_ID",
        "userId": "user123",
        "username": "user123",
        "profileImageUrl": "http://cdn.test.com/123.jpg",
        "type": "text",
        "text": "Hello world",
        "translations": {},
        "data":
        {
            "customField": "customData"
        },
        "createdAt": 1583921400
    }
}

reaction_added

{
    "event": "reaction_added",
    "appId": "YOUR_APP_ID",
    "channel":
    {
        "id": "YOUR_CHANNEL_ID",
        "name": "YOUR_CHANNEL_NAME",
        "ownerId": "user123",
        "type": "public",
        "invitationCode": "",
        "isFrozen": false,
        "hideMessagesBeforeJoin": false,
        "category": "",
        "subcategory": "",
        "memberCount": 1,
        "maxMemberCount": 100,
        "data": {
            "someMetaKey1": "someMetaValue1",
            "someMetaKey2": "someMetaValue2"
        },
        "members":
        [
            {
                "id": "user123",
                "username": "user123",
                "profileImageUrl": "http://cnd.test.com/123.jpg",
                "updatedAt": 1603184094285,
                "createdAt": 1603184094285,
                "lastReadAt": 0,
                "lastSentAt": 1603244275376
            }
        ],
        "mutedUsers": [],
        "bannedUsers": [],
        "updatedAt": 0,
        "createdAt": 0,
        "unreadCount": 0,
        "lastReadAt": 0,
        "lastMessage":
        {
            "id": "sdf2l5s9j",
            "channelId": "YOUR_CHANNEL_ID",
            "userId": "user123",
            "username": "user123",
            "profileImageUrl": "http://cdn.test.com/123.jpg",
            "type": "text",
            "text": "Hello world",
            "translations": {},
            "data":
            {
                "customField": "customData"
            },
            "createdAt": 1583921400
        }
    },
    "user":
    {
        "id": "user123",
        "username": "user123",
        "profileImageUrl": "http://cnd.test.com/123.jpg",
        "updatedAt": 1583924400,
        "createdAt": 1583921400
    },
    "message":
    {
        "id": "sdf2l5s9j",
        "channelId": "YOUR_CHANNEL_ID",
        "userId": "user123",
        "username": "user123",
        "profileImageUrl": "http://cdn.test.com/123.jpg",
        "type": "text",
        "text": "Hello world",
        "translations": {},
        "data":
        {
            "customField": "customData"
        },
        "reactions": {
            "happy": "user123"
        },
        "createdAt": 1583921400
    },
    "reaction": "happy"
}

reaction_deleted

{
    "event": "reaction_deleted",
    "appId": "YOUR_APP_ID",
    "channel":
    {
        "id": "YOUR_CHANNEL_ID",
        "name": "YOUR_CHANNEL_NAME",
        "ownerId": "user123",
        "type": "public",
        "invitationCode": "",
        "isFrozen": false,
        "hideMessagesBeforeJoin": false,
        "category": "",
        "subcategory": "",
        "memberCount": 1,
        "maxMemberCount": 100,
        "data": {
            "someMetaKey1": "someMetaValue1",
            "someMetaKey2": "someMetaValue2"
        },
        "members":
        [
            {
                "id": "user123",
                "username": "user123",
                "profileImageUrl": "http://cnd.test.com/123.jpg",
                "updatedAt": 1603184094285,
                "createdAt": 1603184094285,
                "lastReadAt": 0,
                "lastSentAt": 1603244275376
            }
        ],
        "mutedUsers": [],
        "bannedUsers": [],
        "updatedAt": 0,
        "createdAt": 0,
        "unreadCount": 0,
        "lastReadAt": 0,
        "lastMessage":
        {
            "id": "sdf2l5s9j",
            "channelId": "YOUR_CHANNEL_ID",
            "userId": "user123",
            "username": "user123",
            "profileImageUrl": "http://cdn.test.com/123.jpg",
            "type": "text",
            "text": "Hello world",
            "translations": {},
            "data":
            {
                "customField": "customData"
            },
            "createdAt": 1583921400
        }
    },
    "user":
    {
        "id": "user123",
        "username": "user123",
        "profileImageUrl": "http://cnd.test.com/123.jpg",
        "updatedAt": 1583924400,
        "createdAt": 1583921400
    },
    "message":
    {
        "id": "sdf2l5s9j",
        "channelId": "YOUR_CHANNEL_ID",
        "userId": "user123",
        "username": "user123",
        "profileImageUrl": "http://cdn.test.com/123.jpg",
        "type": "text",
        "text": "Hello world",
        "translations": {},
        "data":
        {
            "customField": "customData"
        },
        "reactions": {
            "happy": "user123"
        },
        "createdAt": 1583921400
    },
    "reaction": "sad"
}

channel_added

{
  "event": "channel_added",
  "appId": "YOUR_APP_ID",
  "channel": {
    "id": "YOUR_CHANNEL_ID",
    "name": "YOUR_CHANNEL_NAME",
    "ownerId": "user123",
    "type": "public",
    "invitationCode": "",
    "isFrozen": false,
    "hideMessagesBeforeJoin": false,
    "category": "",
    "subcategory": "",
    "memberCount": 1,
    "maxMemberCount": 100,
    "data": {
      "someMetaKey1": "someMetaValue1",
      "someMetaKey2": "someMetaValue2"
    },
    "members": [
      {
        "id": "user123",
        "username": "user123",
        "profileImageUrl": "http://cnd.test.com/123.jpg",
        "updatedAt": 1603184094285,
        "createdAt": 1603184094285,
        "lastReadAt": 0,
        "lastSentAt": 1603244275376
      }
    ],
    "mutedUsers": [],
    "bannedUsers": [],
    "updatedAt": 0,
    "createdAt": 0,
    "unreadCount": 0,
    "lastReadAt": 0,
    "lastMessage": null
  }
}

channel_changed

{
  "event": "channel_changed",
  "appId": "YOUR_APP_ID",
  "channel": {
    "id": "YOUR_CHANNEL_ID",
    "name": "YOUR_CHANNEL_NAME",
    "ownerId": "user123",
    "type": "public",
    "invitationCode": "",
    "isFrozen": false,
    "hideMessagesBeforeJoin": false,
    "category": "",
    "subcategory": "",
    "memberCount": 1,
    "maxMemberCount": 100,
    "data": {
      "someMetaKey1": "someMetaValue1",
      "someMetaKey2": "someMetaValue2"
    },
    "members": [
      {
        "id": "user123",
        "username": "user123",
        "profileImageUrl": "http://cnd.test.com/123.jpg",
        "updatedAt": 1603184094285,
        "createdAt": 1603184094285,
        "lastReadAt": 0,
        "lastSentAt": 1603244275376
      }
    ],
    "mutedUsers": [],
    "bannedUsers": [],
    "updatedAt": 0,
    "createdAt": 0,
    "unreadCount": 0,
    "lastReadAt": 0,
    "lastMessage": null // null if there's no message in channel
  }
}

channel_removed

{
  "event": "channel_removed",
  "appId": "YOUR_APP_ID",
  "channel": {
    "id": "YOUR_CHANNEL_ID",
    "name": "YOUR_CHANNEL_NAME",
    "ownerId": "user123",
    "type": "public",
    "isFrozen": false,
    "hideMessagesBeforeJoin": false,
    "category": "",
    "subcategory": "",
    "memberCount": 1,
    "maxMemberCount": 100,
    "data": {
      "someMetaKey1": "someMetaValue1",
      "someMetaKey2": "someMetaValue2"
    },
    "members": [
      {
        "id": "user123",
        "username": "user123",
        "profileImageUrl": "http://cnd.test.com/123.jpg",
        "updatedAt": 1603184094285,
        "createdAt": 1603184094285,
        "lastReadAt": 0,
        "lastSentAt": 1603244275376
      }
    ],
    "mutedUsers": [],
    "bannedUsers": [],
    "updatedAt": 0,
    "createdAt": 0,
    "unreadCount": 0,
    "lastReadAt": 0,
    "lastMessage": null // null if there's no message in channel
  }
}

member_added

{
  "event": "member_added",
  "appId": "YOUR_APP_ID",
  "channel": {
    "id": "YOUR_CHANNEL_ID",
    "name": "YOUR_CHANNEL_NAME",
    "ownerId": "user123",
    "type": "public",
    "invitationCode": "",
    "isFrozen": false,
    "hideMessagesBeforeJoin": false,
    "category": "",
    "subcategory": "",
    "memberCount": 1,
    "maxMemberCount": 100,
    "data": {
      "someMetaKey1": "someMetaValue1",
      "someMetaKey2": "someMetaValue2"
    },
    "members": [
      {
        "id": "user123",
        "username": "user123",
        "profileImageUrl": "http://cnd.test.com/123.jpg",
        "updatedAt": 1603184094285,
        "createdAt": 1603184094285,
        "lastReadAt": 0,
        "lastSentAt": 1603244275376
      }
    ],
    "mutedUsers": [],
    "bannedUsers": [],
    "updatedAt": 0,
    "createdAt": 0,
    "unreadCount": 0,
    "lastReadAt": 0,
    "lastMessage": null // null if there's no message in channel
  },
  "users": [
    {
      "id": "user123",
      "username": "user123",
      "profileImageUrl": "http://cnd.test.com/123.jpg",
      "updatedAt": 1583924400,
      "createdAt": 1583921400
    }
  ]
}

member_left

{
  "event": "member_left",
  "appId": "YOUR_APP_ID",
  "channel": {
    "id": "YOUR_CHANNEL_ID",
    "name": "YOUR_CHANNEL_NAME",
    "ownerId": "user123",
    "type": "public",
    "invitationCode": "",
    "isFrozen": false,
    "hideMessagesBeforeJoin": false,
    "category": "",
    "subcategory": "",
    "memberCount": 1,
    "maxMemberCount": 100,
    "data": {
      "someMetaKey1": "someMetaValue1",
      "someMetaKey2": "someMetaValue2"
    },
    "members": [
      {
        "id": "user123",
        "username": "user123",
        "profileImageUrl": "http://cnd.test.com/123.jpg",
        "updatedAt": 1603184094285,
        "createdAt": 1603184094285,
        "lastReadAt": 0,
        "lastSentAt": 1603244275376
      }
    ],
    "mutedUsers": [],
    "bannedUsers": [],
    "updatedAt": 0,
    "createdAt": 0,
    "unreadCount": 0,
    "lastReadAt": 0,
    "lastMessage": null // null if there's no message in channel
  },
  "users": [
    {
      "id": "user456",
      "username": "user456",
      "profileImageUrl": "http://cnd.test.com/123.jpg",
      "updatedAt": 1583924400,
      "createdAt": 1583921400
    }
  ]
}

member_banned

{
  "event": "member_banned",
  "appId": "YOUR_APP_ID",
  "channel": {
    "id": "YOUR_CHANNEL_ID",
    "name": "YOUR_CHANNEL_NAME",
    "ownerId": "user123",
    "type": "public",
    "invitationCode": "",
    "isFrozen": false,
    "hideMessagesBeforeJoin": false,
    "category": "",
    "subcategory": "",
    "memberCount": 1,
    "maxMemberCount": 100,
    "data": {
      "someMetaKey1": "someMetaValue1",
      "someMetaKey2": "someMetaValue2"
    },
    "members": [
      {
        "id": "user123",
        "username": "user123",
        "profileImageUrl": "http://cnd.test.com/123.jpg",
        "updatedAt": 1603184094285,
        "createdAt": 1603184094285,
        "lastReadAt": 0,
        "lastSentAt": 1603244275376
      }
    ],
    "mutedUsers": [],
    "bannedUsers": [],
    "updatedAt": 0,
    "createdAt": 0,
    "unreadCount": 0,
    "lastReadAt": 0,
    "lastMessage": null // null if there's no message in channel
  },
  "users": [
    {
      "id": "user456",
      "username": "user456",
      "profileImageUrl": "http://cnd.test.com/123.jpg",
      "updatedAt": 1583924400,
      "createdAt": 1583921400
    }
  ]
}

member_unbanned

{
  "event": "member_unbanned",
  "appId": "YOUR_APP_ID",
  "channel": {
    "id": "YOUR_CHANNEL_ID",
    "name": "YOUR_CHANNEL_NAME",
    "ownerId": "user123",
    "type": "public",
    "invitationCode": "",
    "isFrozen": false,
    "hideMessagesBeforeJoin": false,
    "category": "",
    "subcategory": "",
    "memberCount": 1,
    "maxMemberCount": 100,
    "data": {
      "someMetaKey1": "someMetaValue1",
      "someMetaKey2": "someMetaValue2"
    },
    "members": [
      {
        "id": "user123",
        "username": "user123",
        "profileImageUrl": "http://cnd.test.com/123.jpg",
        "updatedAt": 1603184094285,
        "createdAt": 1603184094285,
        "lastReadAt": 0,
        "lastSentAt": 1603244275376
      }
    ],
    "mutedUsers": [],
    "bannedUsers": [],
    "updatedAt": 0,
    "createdAt": 0,
    "unreadCount": 0,
    "lastReadAt": 0,
    "lastMessage": null // null if there's no message in channel
  },
  "users": [
    {
      "id": "user456",
      "username": "user456",
      "profileImageUrl": "http://cnd.test.com/123.jpg",
      "updatedAt": 1583924400,
      "createdAt": 1583921400
    }
  ]
}

user_blocked

{
  "event": "user_blocked",
  "appId": "YOUR_APP_ID",
  "user": {
    "id": "user123",
    "username": "user123",
    "profileImageUrl": "http://cnd.test.com/123.jpg",
    "updatedAt": 1583924400,
    "createdAt": 1583921400
  },
  "blockedUser": {
    "id": "user456",
    "username": "user456",
    "profileImageUrl": "http://cnd.test.com/456.jpg",
    "updatedAt": 1583924400,
    "createdAt": 1583921400
  }
}

user_unblocked

{
  "event": "user_unblocked",
  "appId": "YOUR_APP_ID",
  "user": {
    "id": "user123",
    "username": "user123",
    "profileImageUrl": "http://cnd.test.com/123.jpg",
    "updatedAt": 1583924400,
    "createdAt": 1583921400
  },
  "blockedUser": {
    "id": "user456",
    "username": "user456",
    "profileImageUrl": "http://cnd.test.com/456.jpg",
    "updatedAt": 1583924400,
    "createdAt": 1583921400
  }
}

Last updated