如果您的動作每天都帶給使用者價值,就要提醒使用者: 即可。使用者每天訂閱時 當你執行動作有更新時,他們就會收到推播通知 輕觸一下即可叫用動作的其中一項意圖。
使用者體驗更新如下:
- 使用者叫用您設為使用者的其中一項動作意圖 每日更新
- 使用者按照提示訂閱每日最新動態。這則提示是 會在對話中途顯示,或對話結束時顯示的建議方塊。
- 使用者排定每天要接收每日快訊的時段 更新,正在向 Google 助理註冊更新。
- 使用者每天在排定的時間收到 Google 助理 行動裝置通知。
- 使用者開啟這則通知時,會叫用您的意圖 並設為每日更新,然後與您的動作互動
根據預設,系統會以建議方塊的形式顯示每日更新註冊提示 使用者成功結束動作時。也可以新增對話進行中 註冊提示或個人化使用者的更新
用途
每日更新是相當實用的參與度工具 整合到每個「動作」中判斷是否要新增 改成訂閱動作
- 確保每天的更新內容都會帶給使用者不同、實用的體驗 資訊。如果輕觸每日更新,系統還是會在同一提示中顯示 使用者可能都會在幾天後取消訂閱
- 請確保使用者直接跳到 以及每日更新意圖的意圖使用者不一定會從頭開始 因此他們不應提供太多來龍去脈。
- 提示使用者註冊前,先呈現動作的優點 每日更新。使用者應思考: 天」讀者可以選擇訂閱
- 別以重複的建議來讓使用者不知所措,提供 每日更新訂閱項目 向使用者顯示訂閱的內容 ,避免在其他情況下重複使用優惠
- 觸發更新意圖後,對話應保持簡短。每天最多 更新應只包含一則回應,且在沒有說明的情況下將其關閉 需要使用者輸入內容
設定每日最新動態
在 Dialogflow 中探索
按一下 [繼續],在 Dialogflow 中匯入每日更新範例。接著,請按照 部署及測試範例的步驟:
- 輸入虛擬服務專員名稱,並為範例建立新的 Dialogflow 代理程式。
- 代理程式匯入完畢後,按一下「Go to agent」。
- 在主要導覽選單中,前往「Fulfillment」(執行要求)。
- 啟用「Inline Editor」(內嵌編輯器),然後按一下 [Deploy] (部署)。編輯器包含範例 再也不是件繁重乏味的工作
- 在主要導覽選單中,前往「Integrations」(整合),然後按一下「Google」 Google 助理。
- 在出現的互動視窗中,啟用「自動預覽變更」,然後按一下「測試」 以開啟動作模擬工具
- 在模擬工具中輸入
Talk to my test app
即可測試範例!
如要設定動作的其中一個意圖供每日更新,請按照這些操作操作 說明:
1. 準備更新意圖
請將動作的其中一項意圖設為觸發意圖。這項意圖 允許向使用者傳送每日更新。使用者開啟每日更新時 系統會觸發意圖 然後繼續往前走
如要在 Dialogflow 中定義觸發意圖,請按照下列步驟操作:
- 在 Dialogflow 主控台中 整合:
- 在「Google 助理」部分下方,按一下「整合設定」。
- 前往「探索 >」隱含叫用,按一下新增意圖 並選取觸發意圖 (如果尚未選取的話)。
- 開啟「自動預覽」變更 (如果尚未啟用)。
- 按一下「關閉」。
在 Actions SDK 中,將更新意圖定義為在 動作套件。
2. 啟用更新功能
如要為觸發意圖開啟每日更新,請按照下列步驟操作:
- 在 Actions 主控台中 前往 [開發] >動作:
- 選取您的觸發意圖。如果您的意圖沒有顯示在清單中 請確認已將設定設為觸發意圖和 Dialogflow 的 Google 助理 但已經設為自動預覽變更
- 向下捲動至「使用者參與度」部分並開啟 您可以向使用者提供每日最新資訊。
- 輸入內容標題。
- 按一下 [儲存]。
您現在已完成設定,為 意圖。你現在可以在自己的行動裝置上測試每日更新。
自訂更新註冊 (選用)
除了建議方塊,以及 Google 助理處理的每日更新 註冊流程,即可讓使用者訂閱每日最新消息, 顯示的對話方塊和註冊提示
如需會處理選用每日更新功能的動作完整範例, 查看 Actions on Google 使用者參與度範例 (Node.js)。 和 Java)。
如要在對話中加入自訂每日更新註冊提示,請按照下列步驟操作: 操作說明:
1. 新增註冊提示
根據對話提示加入對話和建議方塊 使用者訂閱每日最新動態在使用者互動後提供這些提示 更新意圖,讓對方瞭解你每天的 更新。
下列範例程式碼會提示使用者訂閱每日最新動態 提供每天最低的預期溫度:
app.intent('Daily Lowest Temperature', (conv, params) => {
const today = DAYS[new Date().getDay()];
const lowestTemperature = lowestTemperatures[today];
conv.ask(`The lowest temperature for today is ${lowestTemperature}`);
conv.ask('I can send you daily updates with the lowest temperature' +
' of the day. Would you like that?');
conv.ask(new Suggestions('Send daily updates'));
});
@ForIntent("Daily Lowest Temperature")
public ActionResponse dailyLowestTemperature(ActionRequest request) {
ResponseBuilder responseBuilder = getResponseBuilder(request);
Integer lowestTemperature =
LOWEST_TEMPERATURES.get(LocalDate.now().getDayOfWeek());
responseBuilder
.add("The lowest temperature for today is " + lowestTemperature + " degrees Fahrenheit.")
.add("I can send you daily updates with the lowest temperature of " +
"the day. Would you like that?")
.addSuggestions(new String[] {
"Send daily updates"
});
return responseBuilder.build();
}
請注意,下列 JSON 會說明 Webhook 回應。
{
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "The lowest temperature for today is 75 degrees Fahrenheit"
}
},
{
"simpleResponse": {
"textToSpeech": "I can send you daily updates with the lowest temperature of the day. Would you like that?"
}
}
],
"suggestions": [
{
"title": "Send daily updates"
}
]
}
}
}
}
請注意,下列 JSON 會說明 Webhook 回應。
{
"expectUserResponse": true,
"expectedInputs": [
{
"possibleIntents": [
{
"intent": "actions.intent.TEXT"
}
],
"inputPrompt": {
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": "The lowest temperature for today is 75 degrees Fahrenheit"
}
},
{
"simpleResponse": {
"textToSpeech": "I can send you daily updates with the lowest temperature of the day. Would you like that?"
}
}
],
"suggestions": [
{
"title": "Send daily updates"
}
]
}
}
}
]
}
2. 處理更新註冊作業
設定新的意圖,在使用者追蹤註冊資訊時觸發
提示。在這項新意圖的執行要求中,觸發 actions_intent_CONFIGURE_UPDATES
內建意圖,且包含
參數
intent
:設為您設定的更新意圖。frequency
- 設為「DAILY」。
下方程式碼會註冊「每日最低溫度」的每日更新 意圖:
app.intent('Subscribe to Daily Updates', (conv) => {
conv.ask(new RegisterUpdate({
intent: 'Daily Lowest Temperature',
frequency: 'DAILY',
}));
});
conv.ask(new RegisterUpdate({
intent: 'Daily Lowest Temperature',
frequency: 'DAILY',
}));
@ForIntent("Subscribe to Daily Updates")
public ActionResponse subscribeToDailyUpdates(ActionRequest request) {
ResponseBuilder responseBuilder = getResponseBuilder(request);
return responseBuilder.add(new RegisterUpdate()
.setIntent("Daily Lowest Temperature")
.setFrequency("DAILY"))
.build();
}
ResponseBuilder responseBuilder = getResponseBuilder(request);
return responseBuilder.add(new RegisterUpdate()
.setIntent("Daily Lowest Temperature")
.setFrequency("DAILY"))
.build();
{
"payload": {
"google": {
"expectUserResponse": true,
"systemIntent": {
"intent": "actions.intent.REGISTER_UPDATE",
"data": {
"@type": "type.googleapis.com/google.actions.v2.RegisterUpdateValueSpec",
"intent": "Daily Lowest Temperature",
"triggerContext": {
"timeContext": {
"frequency": "DAILY"
}
}
}
}
}
}
}
{
"expectUserResponse": true,
"expectedInputs": [
{
"possibleIntents": [
{
"intent": "actions.intent.REGISTER_UPDATE",
"inputValueData": {
"@type": "type.googleapis.com/google.actions.v2.RegisterUpdateValueSpec",
"intent": "Daily Lowest Temperature",
"triggerContext": {
"timeContext": {
"frequency": "DAILY"
}
}
}
}
]
}
]
}
3. 處理結果
Google 助理接管您的對話,並引導使用者完成 其餘的每日更新配置。註冊完成後 Google 助理會使用參數來觸發意圖,此參數會指出 註冊是否成功
這個步驟的操作說明會因您是否使用 或是使用 Dialogflow 或 Actions SDK 進行開發。
如要建立用於處理註冊結果的意圖,請按照下列步驟操作:
- 在 Dialogflow 控制台中 建立新的意圖
- 新增
actions_intent_REGISTER_UPDATE
事件。 - 為意圖啟用 Webhook 執行要求。
- 按一下 [儲存]。
registered
參數,並據此調整對話方向。
app.intent('Confirm Daily Updates Subscription', (conv, params, registered) => {
if (registered && registered.status === 'OK') {
conv.close(`Ok, I'll start giving you daily updates.`);
} else {
conv.close(`Ok, I won't give you daily updates.`);
}
});
@ForIntent("Confirm Daily Updates Subscription")
public ActionResponse confirmDailyUpdatesSubscription(ActionRequest request) {
ResponseBuilder responseBuilder = getResponseBuilder(request);
if (request.isUpdateRegistered()) {
responseBuilder.add("Ok, I'll start giving you daily updates.");
} else {
responseBuilder.add("Ok, I won't give you daily updates.");
}
return responseBuilder.endConversation().build();
}
{
"payload": {
"google": {
"expectUserResponse": false,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Ok, I'll start giving you daily updates."
}
}
]
}
}
}
}
在執行要求程式碼中,為 actions.intent.REGISTER.UPDATE
新增處理方式
內建意圖檢查結果的 registered
參數。
並據此引導對話方向
app.intent('actions.intent.REGISTER_UPDATE', (conv, params, registered) => {
if (registered && registered.status === 'OK') {
conv.close(`Ok, I'll start giving you daily updates.`);
} else {
conv.close(`Ok, I won't give you daily updates.`);
}
});
@ForIntent("actions.intent.REGISTER_UPDATE")
public ActionResponse confirmDailyUpdatesSubscription(ActionRequest request) {
ResponseBuilder responseBuilder = getResponseBuilder(request);
if (request.isUpdateRegistered()) {
responseBuilder.add("Ok, I'll start giving you daily updates.");
} else {
responseBuilder.add("Ok, I won't give you daily updates.");
}
return responseBuilder.endConversation().build();
}
{
"expectUserResponse": false,
"finalResponse": {
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Ok, I'll start giving you daily updates."
}
}
]
}
}
}
個人化更新 (選用)
如要個人化更新意圖,請在使用者註冊時加入自訂參數 以及每日更新執行更新意圖時,請參照這些參數 自訂該使用者的每日更新。
這項功能的操作說明會根據您是否使用 或是使用 Dialogflow 或 Actions SDK 進行開發。
定義 Dialogflow 實體來處理更新作業的自訂參數,然後 把參數值做為更新意圖的引數。 如要在 Dialogflow 中設定個人化更新,請按照下列步驟操作:
- 在 Dialogflow 控制台中建立新實體。
- 新增一些與參數相關的項目和同義詞。
- 按一下「Save」(儲存),然後開啟更新意圖。
- 在「動作和參數」部分中設定
actions.intent.CONFIGURE_UPDATES
做為事件在同一個部分中,新增與新實體類型相同的參數。 - 開啟「更新註冊」處理
CONFIGURE_UPDATES
內建意圖的意圖。 - 在「Actions and parameters」(動作和參數) 部分中新增必要參數,並將其類型設為先前建立的實體。
- 更新註冊意圖的執行要求程式碼,加入含有
arguments
物件的 包含下列內容:name
- Dialogflow 中設定的參數名稱。textValue
- 參數的值。
下列程式碼會讀取並使用該參數的值 更新:
app.intent('setup_update', (conv) => {
conv.ask(new RegisterUpdate({
intent: 'update_of_the_day',
arguments: [
{
name: 'category',
textValue: 'Daily_lowest_temperature',
},
],
frequency: 'DAILY',
}));
});
@ForIntent("setup_update")
public ActionResponse setupUpdate2(ActionRequest request) {
List<Argument> args =
Arrays.asList(
new Argument()
.setName("category")
.setTextValue(request.getParameter("category").toString()));
return getResponseBuilder(request)
.add(new RegisterUpdate().setIntent("intent_name").setArguments(args).setFrequency("DAILY"))
.build();
}
{
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "PLACEHOLDER"
}
}
]
},
"userStorage": "{\"data\":{}}",
"systemIntent": {
"intent": "actions.intent.REGISTER_UPDATE",
"data": {
"@type": "type.googleapis.com/google.actions.v2.RegisterUpdateValueSpec",
"intent": "update_of_the_day",
"arguments": [
{
"name": "category",
"textValue": "Daily_lowest_temperature"
}
],
"triggerContext": {
"timeContext": {
"frequency": "DAILY"
}
}
}
}
}
},
"outputContexts": [
{
"name": "/contexts/_actions_on_google",
"lifespanCount": 99,
"parameters": {
"data": "{}"
}
}
]
}
在意圖執行要求中,要求使用者提供其他資訊。 然後將資訊做為更新意圖的引數。 如要在 Actions SDK 中設定個人化更新功能,請按照下列步驟操作:
- 提示使用者提供您想用於提供的資訊 個人化。
- 在「更新註冊資訊」的出貨代碼中意圖
處理
CONFIGURE UPDATES
包括arguments
物件,其中包含 包含下列內容:name
- 引數的名稱。textValue
- 要做為引數傳遞的使用者資訊。
下列程式碼會傳送引數與更新註冊要求:
app.intent('actions.intent.TEXT', (conv) => {
if (conv.input.raw === 'Send daily') {
conv.ask(new RegisterUpdate({
intent: 'update_of_the_day',
arguments: [
{
name: 'category',
textValue: 'Daily_lowest_temperature',
},
],
frequency: 'DAILY',
}));
}
});
@ForIntent("actions.intent.CONFIGURE_UPDATES")
public ActionResponse configureUpdatesActionsSdk(ActionRequest request) {
List<Argument> args =
Arrays.asList(
new Argument()
.setName("category")
.setTextValue(request.getParameter("category").toString()));
return getResponseBuilder(request)
.add(new RegisterUpdate().setIntent("intent_name").setArguments(args).setFrequency("DAILY"))
.build();
}
@ForIntent("actions.intent.TEXT")
public ActionResponse text(ActionRequest request) {
ResponseBuilder rb = getResponseBuilder(request);
String input = request.getRawInput().getQuery();
if (input.equals("DAILY_NOTIFICATION_SUGGESTION")) {
rb.add("For which category do you want to receive daily updates?");
} else {
rb.add("Sorry, I didn't get that. Please try again later").endConversation();
}
return rb.build();
}
{
"expectUserResponse": true,
"expectedInputs": [
{
"inputPrompt": {
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": "PLACEHOLDER"
}
}
]
}
},
"possibleIntents": [
{
"intent": "actions.intent.REGISTER_UPDATE",
"inputValueData": {
"@type": "type.googleapis.com/google.actions.v2.RegisterUpdateValueSpec",
"intent": "update_of_the_day",
"arguments": [
{
"name": "category",
"textValue": "Daily_lowest_temperature"
}
],
"triggerContext": {
"timeContext": {
"frequency": "DAILY"
}
}
}
}
]
}
],
"conversationToken": "{\"data\":{}}",
"userStorage": "{\"data\":{}}"
}
當使用者叫用您的每日更新時,您的更新意圖現在包含 含有使用者在註冊期間提供的值的引數。使用這些 值,建立每位使用者的個人化更新。
測試每日最新動態
在行動裝置上使用 Google 助理,透過以下方式測試每日最新動態: 也就是你用於建立動作的 Google 帳戶。叫用動作 並訂閱每日最新動態,然後查看裝置通知 更新時間。