2017-07-25 33 views
3

操作我下面通過以下鏈接行動的示例代碼在谷歌迴應:askWithList對谷歌

https://developers.google.com/actions/assistant/responses

我想,當用戶啓動文本意圖出現在列表響應,但我所得到的只是「您的應用程序現在沒有迴應,請儘快再試一次。」下面是我使用(它的複製和粘貼大部分來自鏈接)代碼:

function textIntent(app) { 
    app.askWithList(app.buildRichResponse() 
     .addSimpleResponse('Alright') 
     .addSuggestions(
      ['Basic Card', 'List', 'Carousel', 'Suggestions']), 
     // Build a list 
     app.buildList('Things to learn about') 
     // Add the first item to the list 
     .addItems(app.buildOptionItem('MATH_AND_PRIME', 
      ['math', 'math and prime', 'prime numbers', 'prime']) 
      .setTitle('Math & prime numbers') 
      .setDescription('42 is an abundant number because the sum of its ' + 
      'proper divisors 54 is greater…') 
     ) 
     // Add the second item to the list 
     .addItems(app.buildOptionItem('EGYPT', 
      ['religion', 'egypt', 'ancient egyptian']) 
      .setTitle('Ancient Egyptian religion') 
      .setDescription('42 gods who ruled on the fate of the dead in the ' + 
      'afterworld. Throughout the under…') 
     ) 
     // Add third item to the list 
     .addItems(app.buildOptionItem('RECIPES', 
      ['recipes', 'recipe', '42 recipes']) 
      .setTitle('42 recipes with 42 ingredients') 
      .setDescription('Here\'s a beautifully simple recipe that\'s full ' + 
      'of flavor! All you need is some ginger and…') 
     ) 
    ); 

} 

let actionMap = new Map(); 
actionMap.set(app.StandardIntents.MAIN, mainIntent); 
actionMap.set(app.StandardIntents.TEXT, textIntent); 

app.handleRequest(actionMap); 

這裏是我的action.json:

{ 
    "actions": [ 
    { 
     "description": "Default Welcome Intent", 
     "name": "MAIN", 
     "fulfillment": { 
      "conversationName": "welcome" 
     }, 
     "intent": { 
      "name": "actions.intent.MAIN" 
     } 
    }, 
    ], 

    "conversations": { 
     "welcome": { 
      "name": "welcome", 
      "url": "https://example.com" 
     }, 
    } 

} 

任何幫助將不勝感激!先謝謝你。

+0

你使用的是api.ai還是gactions?如果有反應,你可以發佈你的actions.json以掩蓋任何敏感信息嗎?你確認你的webhook被調用了嗎? – Prisoner

+0

謝謝,編輯。 –

回答

4

您使用的操作版本2層的功能,但actions.json包不指定版本,所以它默認爲第1版。

actions.json的「對話」欄目應該是這個樣子:

"conversations": { 
    "welcome": { 
     "name": "welcome", 
     "url": "https://example.com", 
     "fulfillmentApiVersion": 2 
    }, 
} 
+0

這解決了它!非常感謝,我甚至不知道那是一件事! –