在一般的 Actions on Google 互動情境中,使用者會說出一個詞組來叫用動作。為提供回應,Actions on Google 會尋找與使用者叫用的動作相符的執行要求,然後傳送要求。
Actions on Google 確定執行要求符合使用者叫用的適當項目後,就會傳送包含使用者要求資訊的 JSON 酬載至執行要求端點,啟動對話工作階段。執行要求會剖析要求,並傳回包含 JSON 酬載的回應。接著,Actions on Google 會將酬載轉換成為使用者轉譯的語音和多媒體輸出。
圖 1. Actions on Google 透過 Actions SDK 叫用執行要求。
如要進一步瞭解 Actions on Google 透過 Actions SDK 叫用執行要求時,JSON 酬載的格式,請參閱「對話 Webhook 格式」。
Dialogflow 要求與回應
建立動作時,您可以選擇使用 Dialogflow 簡化建構對話介面的工作。在此情況下,Dialogflow 會做為 Actions on Google 和執行要求之間的 Proxy。Actions on Google 不會直接將 HTTP/JSON 要求傳送至執行要求端點,而是會將其傳送至 Dialogflow。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2023-12-02 (世界標準時間)。"],[[["Actions on Google communicates with your fulfillment service through webhooks, sending JSON payloads that describe user requests."],["Your fulfillment service needs to process these requests, generate appropriate JSON responses, and send them back to the Assistant."],["There are two main webhook formats: Dialogflow webhook format and Conversation webhook format, depending on whether you use Dialogflow or Actions SDK."],["Webhooks can handle different request types like invocation requests, conversation requests, and helper results, each with specific JSON structures."],["Dialogflow can act as a proxy between Actions on Google and your fulfillment, handling the communication and format conversions."]]],["Actions on Google uses webhooks to communicate with fulfillment services, sending HTTP POST requests with JSON payloads. Fulfillment services must parse these requests and respond with appropriately formatted JSON. There are two main webhook formats: Dialogflow and Conversation, corresponding to whether Dialogflow acts as a proxy. Webhook requests can be invocations, conversation turns, or helper results. The fulfillment reads parameters from the request payload and sends a reply back to the Assistant.\n"]]