작업 요청 처리
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
작업 선언에 설명된 대로 사용자가 인앱 작업과 상호작용하면 Google은 작업에 선언된 URL로 HTTP 요청을 보냅니다.
다음 예에서는 비용 보고서에 관한 이메일에 ConfirmAction
버튼을 추가합니다.
JSON-LD
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ConfirmAction",
"name": "Approve Expense",
"handler": {
"@type": "HttpActionHandler",
"url": "https://myexpenses.com/approve?expenseId=abc123"
}
},
"description": "Approval request for John's $10.13 expense for office supplies"
}
</script>
마이크로데이터
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="potentialAction" itemscope itemtype="http://schema.org/ConfirmAction">
<meta itemprop="name" content="Approve Expense"/>
<div itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
<link itemprop="url" href="https://myexpenses.com/approve?expenseId=abc123"/>
</div>
</div>
<meta itemprop="description" content="Approval request for John's $10.13 expense for office supplies"/>
</div>
사용자가 버튼을 클릭하면 Google에서 서비스로 HTTP 요청을 발행하여 확인을 기록합니다. 서비스가 Google로부터 다음 HTTP 요청을 수신합니다.
POST /approve?expenseId=abc123 HTTP/1.1
Host: your-domain.com
Authorization: Bearer AbCdEf123456
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/1.0 (KHTML, like Gecko; Gmail Actions)
confirmed=Approved
이 페이지의 나머지 부분에서는 https://your-domain.com/approve?expenseId=abc123
의 서비스가 작업을 적절하게 처리하기 위해 해야 하는 작업을 설명합니다. 여기에는 다음이 포함됩니다.
1단계: 요청 확인
https://your-domain.com/approve?expenseId=abc123
의 서비스는 다음을 확인하는 것이 좋습니다.
모든 작업 요청의 사용자 에이전트는 Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/1.0 (KHTML, like Gecko; Gmail Actions)
입니다.
모든 검사를 통과하면 서비스가 다음 단계로 진행될 수 있습니다.
2단계: 작업 처리
서비스는 URL 매개변수에 지정된 작업과 사용자로부터 수집된 추가 정보를 처리해야 합니다.
사용자의 추가 정보는 요청의 본문에 있으며 x-www-form-urlecoded 인코딩을 사용하여 인코딩됩니다. 이 정보는 이름이 작업의 속성과 일치하는 속성에 설정됩니다. 예를 들어 ConfirmAction에는 confirmed
속성이 있습니다.
3단계: 응답 코드 반환
서비스가 작업을 처리하고 기록하는 데 성공하면 응답 코드 200 (OK)
를 반환해야 합니다. 오류 상황에서는 다음 응답 코드를 사용할 수 있습니다.
응답 코드 |
실험군 |
400 (Bad Request) |
Google에서 작업을 실패합니다. |
401 (Unauthorized) |
Google에서 작업을 실패합니다. |
404(찾을 수 없음) |
Google에서 작업을 실패합니다. |
408 (요청 시간 초과) |
Google에서 나중에 다시 시도합니다. |
영구적으로 실패하는 경우 Google은 사용자에게 작업이 실패했으며 이메일 내의 대체 안내를 따라야 한다고 알립니다.
추가 자료
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-29(UTC)
[null,null,["최종 업데이트: 2025-08-29(UTC)"],[],[],null,["# Handle Action Requests\n\nAs described in [Declaring Actions](/workspace/gmail/markup/actions/declaring-actions), when a user interacts with an In-App Action, Google sends an HTTP request to a URL declared in the action.\n\nThe following example adds a `ConfirmAction` button to an email about an expense report: \n\n### JSON-LD\n\n \u003cscript type=\"application/ld+json\"\u003e\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"EmailMessage\",\n \"potentialAction\": {\n \"@type\": \"ConfirmAction\",\n \"name\": \"Approve Expense\",\n \"handler\": {\n \"@type\": \"HttpActionHandler\",\n \"url\": \"https://myexpenses.com/approve?expenseId=abc123\"\n }\n },\n \"description\": \"Approval request for John's $10.13 expense for office supplies\"\n }\n \u003c/script\u003e\n\n### Microdata\n\n \u003cdiv itemscope itemtype=\"http://schema.org/EmailMessage\"\u003e\n \u003cdiv itemprop=\"potentialAction\" itemscope itemtype=\"http://schema.org/ConfirmAction\"\u003e\n \u003cmeta itemprop=\"name\" content=\"Approve Expense\"/\u003e\n \u003cdiv itemprop=\"handler\" itemscope itemtype=\"http://schema.org/HttpActionHandler\"\u003e\n \u003clink itemprop=\"url\" href=\"https://myexpenses.com/approve?expenseId=abc123\"/\u003e\n \u003c/div\u003e\n \u003c/div\u003e\n \u003cmeta itemprop=\"description\" content=\"Approval request for John's $10.13 expense for office supplies\"/\u003e\n \u003c/div\u003e\n\nWhen the user clicks on the button, an HTTP request will be issued from Google to your service, recording the confirmation. Your service receives the following HTTP request from Google: \n\n POST /approve?expenseId=abc123 HTTP/1.1\n Host: your-domain.com\n Authorization: Bearer AbCdEf123456\n Content-Type: application/x-www-form-urlencoded\n User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/1.0 (KHTML, like Gecko; Gmail Actions)\n\n confirmed=Approved\n\nThe rest of this page describes what the service at `https://your-domain.com/approve?expenseId=abc123` needs to do to handle the action properly. This includes:\n\n- Verifying the request\n- Processing the payload\n- Returning a response code\n\nStep 1: Verify the Request\n--------------------------\n\nThe service at `https://your-domain.com/approve?expenseId=abc123` is encouraged to check:\n\n- [Limited Use Access Token](/workspace/gmail/markup/actions/limited-use-access-tokens) - To protect against replay attacks.\n- [User Agent](http://en.wikipedia.org/wiki/User_agent) - To make sure the request comes from Google.\n- [Bearer Token](/workspace/gmail/markup/actions/verifying-bearer-tokens) - To guarantee the request coming from Google is intended to the service.\n\nThe User Agent for all Action requests is `Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/1.0 (KHTML, like Gecko; Gmail Actions)`.\n\nIf all checks pass, the service can proceed to the next step.\n\nStep 2: Process the Action\n--------------------------\n\nThe service should process the action as specified in the URL parameters as well as additional information collected from the user.\n\nAdditional information from the user resides in the request's body, and is encoded using the [x-www-form-urlecoded](https://en.wikipedia.org/wiki/Percent-encoding#The_application.2Fx-www-form-urlencoded_type) encoding. The information is set in properties whose names correspond with the properties of Action. For example, [ConfirmAction](/workspace/gmail/markup/reference/types/ConfirmAction) has the property `confirmed`.\n\nStep 3: Return a Response Code\n------------------------------\n\nOnce the service processed and recorded the action successfully, it should return a response code `200 (OK)`. The following response codes can be used in error situations:\n\n| Response Code | Treatment |\n|-----------------------|--------------------------------|\n| 400 (Bad Request) | Google will fail the action. |\n| 401 (Unauthorized) | Google will fail the action. |\n| 404 (Not Found) | Google will fail the action. |\n| 408 (Request Timeout) | Google will retry again later. |\n\nIn case of permanent failure, Google will tell the user that action has failed and that the user should follow alternative instructions inside the email.\n\nFurther Reading\n---------------\n\n- [Securing Actions](/workspace/gmail/markup/actions/securing-actions)\n\n| **Note:** Some of the schemas used by Google are still going through the standardization process of [schema.org](http://schema.org), and therefore, may change in the future. [Learn More](/workspace/gmail/markup/reference/schema-org-proposals)."]]