Synology Chat의 사용자 지정 통합 기능을 사용하여 수신 및 발신 Webhook, 봇 및 슬래시 명령을 구성할 수 있습니다. 오른쪽 위에 있는 프로필 사진을 클릭하고 통합을 선택하여 이러한 기능을 활성화하십시오.
수신 Webhook는 외부 소스에서 Chat으로 메시지를 게시합니다. 다른 옵션 설정과 함께 JSON 페이로드로 일반 HTTP 요청을 활용합니다.
다음과 같은 두 가지 방법으로 Webhook URL로 데이터를 전송할 수 있습니다.
payload
매개 변수로 JSON 문자열 보내기JSON 페이로드에는 할당된 채널에 게시되는 text
속성이 포함될 수 있습니다. 예:
payload={"text": "First line of message to post in the channel.\nAlso you can have a second line of message."}
링크를 추가하려면 text
에 링크를 직접 입력하면 됩니다. 예:
payload={"text": "<https://www.synology.com>"}
다른 예:
payload={"text": "Check this!! <https://www.synology.com|Click here> for details!"}
또한 수신 게시물에 파일을 업로드할 수도 있습니다. 파일을 업로드하려면 JSON 페이로드에 file_url
속성과 텍스트 속성(옵션)도 포함되어야 합니다. Synology는 사용자의 URL을 다운로드하여 사용자 파일 업로드 게시물로 처리합니다. 예:
payload={"text": "a fun image", "file_url": "http://imgur.com/xxxxx"}
발신 Webhook는 Chat 메시지의 트리거 단어를 수신 대기합니다. 이러한 트리거 단어는 관련 데이터를 외부 URL로 보냅니다. 발신 Webhook는 아래 두 조건 중 하나 이상이 충족되는 경우에만 트리거될 수 있습니다.
채널이 표시된 경우 트리거 단어는 선택 사항입니다. 채널을 선택하지 않은 경우에는 트리거 단어가 있어야 합니다. 그러나 두 조건이 모두 정의된 경우 두 조건이 동시에 충족하면 발신 Webhook만 발생합니다.
수신된 메시지가 트리거와 일치하는 경우 POST는 할당된 URL로 전달됩니다. 데이터 필드는 다음과 같습니다.
token: bot tokenchannel_idchannel_nameuser_idusernamepost_idtimestamptexttrigger_word: which trigger word is matched
외부 대상이 Chat 채널에서 응답하려면 JSON이 응답 본문에서 반환되어야 합니다. 지원되는 필드는 수신 Webhook JSON과 동일합니다.
텍스트 필드에 "/"를 입력하면 슬래시 명령을 통해 발신 webhook를 간편하게 트리거할 수 있습니다. 회신은 사용자 본인만 볼 수 있으므로, 다른 사용자는 회신과 관련 없는 모든 메시지를 볼 수 없습니다.
통합에서 슬래시 명령을 사용자 지정할 수 있습니다. 오른쪽 상단 구석에 있는 프로필 사진을 클릭하여 통합에 액세스할 수 있습니다.
모든 채널 또는 대화의 텍스트 필드에 슬래시 "/"를 입력합니다. 명령을 선택하기 위한 사용자와 팀에서 작성한 명령 목록이 표시됩니다. 예를 들어 "/"를 입력하고 "/lunch"를 선택하면 Webhook는 식사를 추천합니다.
봇은 사용자와 일대일 대화를 시작하고 외부 소스에서 보낸 메시지를 게시하고 대화에서 사용자가 보낸 메시지를 수신 대기할 수 있습니다.
봇 목록에서 숨기기 옵션을 선택하면 사용자는 봇 목록에서 이 봇을 보거나 추가할 수 없습니다.
봇 구성 필드에서 발신 URL을 입력한 후 사용자가 메시지를 봇으로 보내면 Chat은 URL에 요청을 보냅니다. 데이터 필드는 다음과 같습니다.
token: bot tokenuser_idusernamepost_idtimestamptext
POST 요청에서 페이로드 매개 변수를 통해 받는 사람과 메시지를 할당할 수 있습니다. 예:
payload={"text": "First line of message to post in the channel.\nAlso you can have a second line of message.", "user_ids": [5] }
이는 5의 user_id를 사용하여First line of message to post in the channel.\nAlso you can have a second line of message.>메시지를 사용자에게 전송했다는 의미입니다.
봇과의 대화에서 봇은 텍스트와 파일을 보내고 특수 데이터(첨부) 및 대화형 개체(동작)를 첨부할 수도 있습니다. 버튼은 현재 양방향 개체를 제공합니다. 페이로드의 첨부 필드에 첨부할 메시지를 추가할 수 있습니다. 예:
attachments: array of attachment object
attachment object: { callback_id: string[2], which refers to the string self-defined by the bot service. This will be sent to you when a user triggers an event attached with data. text: string actions: array of action object}
action object: { type: "button" text: string name: string value: string style: string, where green, grey, red, orange, blue, and teal are the feasible values}
예:
payload={"text": "Hello World", "user_ids": [3], "attachments":[{"callback_id": "abc", "text": "attachment", "actions":[{"type": "button", "name": "resp", "value": "ok", "text": "OK", "style": "green"}]}]}
사용자가 대화형 개체를 트리거하면 Chat은 봇의 발신 URL에 요청을 보냅니다. 데이터 필드는 다음과 같습니다.
payload = { "actions": array of action object, which refers to the action triggered by the user "callback_id": string, which refers to the callback_id of the attachment where the action triggered by the user is located "post_id" "token" "user": { "user_id" "username" }}
봇이 요청을 수신한 후 JSON 데이터를 다시 보내 원래 POST를 수정할 수 있습니다. 지원되는 형식은 페이로드 형식과 동일합니다(user_id제외).
예:
{"text": "Got your response!"}
다음 URL로 요청을 보낼 수 있습니다. [Chat URL]/webapi/entry.cgi?api=SYNO.Chat.External&method=channel_list&version=2
그리고 다음 매개 변수를 통합할 수 있습니다. token = bot token
다음 URL로 요청을 보낼 수 있습니다. {Chat URL}/webapi/entry.cgi?api=SYNO.Chat.External&method=user_list&version=2
그리고 다음 매개 변수를 통합할 수 있습니다. token = bot token
다음 URL로 요청을 보낼 수 있습니다. {Chat URL}/webapi/entry.cgi?api=SYNO.Chat.External&method=post_list&version=2
그리고 다음 매개 변수를 통합할 수 있습니다. token = bot tokenchannel_id = channel_id is intended for browsingnext_count = the number of messages that comes after a postprev_count = the number of messages that comes before a post, with 1 as the minimum(optional)post_id = post_id is intended for browsing, the unfilled post_id refers to the newest message
다음 URL로 요청을 보낼 수 있습니다. {Chat URL}/webapi/entry.cgi?api=SYNO.Chat.External&method=post_file_get&version=2&post_id={post id}&token="{bot token}"
그리고 다음 매개 변수를 통합할 수 있습니다. token = bot tokenpost_id = post_id is intended for browsing