이 페이지에서는 나만의 홈페이지를 만드는 방법을 Google Chat 앱 앱 홈은 맞춤설정이 가능한 카드 인터페이스입니다. 사용자가 채팅 앱을 열 때 채팅 앱에서 사용자에게 보내는 채팅 앱으로 메시지를 주고받을 수 있습니다.
예를 들어 다음을 사용하는 채팅 앱 슬래시 명령어 최종 사용자의 경우 앱 홈은 다음과 같은 경우 채팅 앱의 채팅 메시지에서만 사용할 수 있습니다. 앱 개발자가 기능을 사용 설정해야 합니다.
카드 빌더를 사용하여 채팅 앱용 JSON 카드 메시지를 디자인하고 미리 봅니다.
카드 빌더 열기 <ph type="x-smartling-placeholder"></ph>
기본 요건
Python
- Google Workspace 액세스 권한이 있는 계정 Google Chat
- 게시된 채팅 앱 새로운 채팅 앱, 다음을 참고하세요. 빠른 시작:
- 상호작용을 위해 구성된 Google Chat 앱 자세한 내용은 자세한 내용은 상호작용 이벤트를 수신하도록 Google Chat 앱을 구성합니다.
Apps Script
- Google Workspace 액세스 권한이 있는 계정 Google Chat
- 게시된 채팅 앱 새로운 채팅 앱, 팔로우하기 빠른 시작:
- 상호작용을 위해 구성된 Google Chat 앱 자세한 내용은 자세한 내용은 상호작용 이벤트를 수신하도록 Google Chat 앱을 구성합니다.
Google Cloud 콘솔에서 구성
Python
Google Cloud 콘솔에서 메뉴로 이동합니다. <ph type="x-smartling-placeholder">> 제품 더보기 > Google Workspace > 제품 라이브러리 > Google Chat API.
</ph>관리를 클릭한 다음 구성 탭을 클릭합니다.
지원 앱 홈을 사용 설정합니다.
Support App Home 체크박스를 선택합니다.
App Home URL(앱 홈 URL) 입력란에 URL을 추가합니다. 이 값은 일반적으로 동일합니다. URL을 앱 URL로 사용합니다. 이 URL은
APP_HOME
이벤트.저장을 클릭합니다.
Apps Script
Google Cloud 콘솔에서 메뉴로 이동합니다. <ph type="x-smartling-placeholder">> 제품 더보기 > Google Workspace > 제품 라이브러리 > Google Chat API.
</ph>관리를 클릭한 다음 구성 탭을 클릭합니다.
Support App Home 체크박스를 선택합니다.
저장을 클릭합니다.
Chat 앱 구성
앱 홈용 채팅 앱을 구성합니다.
Python
사용자가 채팅 앱에서 채팅 메시지를 열면
APP_HOME
이벤트가 채팅 앱으로 전송됩니다. 사용자가
채팅 앱은
RenderActions
pushCard
탐색과 함께 반환됩니다.
@app.route('/', methods=['POST'])
def on_event():
event = request.get_json()
chat = event.get('chat')
if chat is not None:
return handle_chat_event(event)
def handle_chat_event(event):
if event['chat'].get('type') == 'APP_HOME':
return get_app_home_card()
def get_app_home_card():
return {
"action": {
"navigations": [
{
"pushCard": {
"sections": [
{
"widgets": [
{
"buttonList": {
"buttons": [
{
"text": "Open documentation",
"onClick": {
"openLink": {
"url": "https://developers.google.com/chat"
}
}
}
]
}
}
]
}
]
}
}
]
}
}
Apps Script
이 예시에서는 카드 JSON과 함께 사용합니다. 또한 Apps Script 카드 서비스.
onAppHome
함수를 구현하여
RenderActions
pushCard
탐색:
// "onAppHome" is the pre-defined name of the callback that the Chat servers
// execute.
function onAppHome() {
return {
action: {
navigations: [
{
pushCard: getCard()
}
]
}
};
}
function getCard() {
return {
sections: [
{
widgets: [
{
buttonList: {
buttons: [
{
text: "Open documentation",
onClick: {
openLink: {
url: "https://developers.google.com/chat"
}
}
}
]
}
}
]
}
]
};
}
앱 홈 카드 업데이트
사용자가 정보를 제출하거나 앱을 종료할 때 앱 홈 카드를 업데이트할 수 있습니다.
대화상자 예를 들어 초기 앱 홈 카드에는
사용자에게 정보로 양식을 작성하도록 요청합니다. 사용자가
양식에서 앱 홈 카드가 업데이트됩니다. 업데이트가 인스턴스와 함께 반환되어야 합니다.
/RenderActions
updateCard
탐색이 포함된 클래스
Python
HTTP 앱의 경우 앱 홈 카드를 업데이트하는 방법은 다음과 비슷합니다.
사용자가 입력한 정보를 처리합니다.
하지만 RenderActions
를 반환해야 합니다. invokedFunction
는
Card
위젯과 연결된 호출된 함수입니다. 자세한 내용은
보기
CommonEventObject
다음 예에서
submitForm
드림
사용자가 양식을 제출했음을 보여줍니다.
데이터:
@app.route('/', methods=['POST'])
def on_event():
event = request.get_json()
chat = event.get('chat')
if chat is not None:
return handle_chat_event(event)
def handle_chat_event(event):
if event['chat'].get('type') == 'SUBMIT_FORM':
event_object = event.get('commonEventObject')
if event_object is not None:
// Forms
if 'submitForm' == event_object.get('invokedFunction'):
return {
'render_actions': {
'action': {
'navigations': [{
'updateCard': get_update_card()
}]
}
}
}
def get_update_card():
return {
"action": {
"navigations": [{
"pushCard": {
"sections": [{
"widgets": [{
"buttonList": {
"buttons": [{
"text": "Open documentation",
"onClick": {
"openLink": {
"url": "https://developers.google.com/chat"
}
},
}]
}
}]
}]
}
}]
}
}
Apps Script
이 예시에서는 카드 JSON과 함께 사용합니다. 또한 Apps Script 카드 서비스.
// Called from elsewhere (i.e. on button press).
function updateAppHomeCard(event) {
return {
render_actions: {
action: {
navigations: [
{
updateCard: getCard()
}
]
}
}
}
}
function getCard() {
return {
sections: [
{
widgets: [
{
buttonList: {
buttons: [
{
text: "Open documentation",
onClick: {
openLink: {
url: "https://developers.google.com/chat"
}
}
}
]
}
}
]
}
]
};
}
제한사항
일반적으로
navigation
:
채팅 앱에서는 사용할 수 없습니다. 여러 장의 카드를 반환할 수 없습니다.
pushCard
(초기 응답용) 및 updateCard
(업데이트용)만
채팅 앱에서 사용할 수 있습니다.
관련 주제
대화상자를 열려면
OPEN_DIALOG
상호작용을 사용합니다. 자세한 내용은 보기 앱 홈 카드에 대한 응답으로 대화상자를 엽니다.대화상자를 닫으려면
CLOSE_DIALOG
상호작용을 사용하여 대화상자를 닫으세요. 그런 다음 앱 홈 카드로 돌아가거나CLOSE_DIALOG_EXECUTE
카드를 사용합니다. 대화상자를 닫고 앱 홈 카드를 새로고침합니다. 대상 자세한 내용은 앱 홈 카드의 대화상자에 응답앱 홈을 사용하는 방법의 예는 Codelab의 문제 관리 채팅 앱 Gemini로 Google Chat용 앱 빌드하기