I am trying to pass parameter value from google actions to my fulfillment.
However, I am not able to get only the parameter value. How should I able to get only "Asda" under newName
field from the argument? Do I have to extract it from conv
(like conv.inputs.arguments[1].rawText
)? if like this, then what is the purpose of having a name for the parameter?
Request JSON from Google Actions:
{
"user": {
"userId": "ABwppHEAPgcgb2yFUFURYFEJGg4VdAVcL9UKO9cS7a7rVfAMr9ht67LzgrmMseTvb5mmJjbjj7UV",
"locale": "en-US",
"lastSeen": "2018-05-15T01:08:55Z",
"userStorage": "{"data":{}}"
},
"conversation": {
"conversationId": "1526346570079",
"type": "NEW"
},
"inputs": [
{
"intent": "com.example.test.RENAME",
"rawInputs": [
{
"inputType": "KEYBOARD",
"query": "Talk to GoTestApp to rename Asda"
}
],
"arguments": [
{
"name": "trigger_query",
"rawText": "rename Asda",
"textValue": "rename Asda"
},
{
"name": "newName",
"rawText": "Asda",
"textValue": "Asda"
}
]
}
],
"surface": {
"capabilities": [
{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.WEB_BROWSER"
}
]
},
"isInSandbox": true,
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
}
]
}
]
}
My code of Fulfillment side:
app.intent('com.example.test.RENAME', (conv, input, arg) => {
console.log(input); //print Talk to GoTestApp to rename Asda
console.log(arg); //only print "rename Asda"
console.log(arg[1]) //only print "e"
}
Action Package action:
"name": "RENAME",
"intent": {
"name": "com.example.test.RENAME",
"parameters": [{
"name": "newName",
"type": "SchemaOrg_Text"
}],
"trigger": {
"queryPatterns": [
"rename $SchemaOrg_Text:newName"
]
}
},
"fulfillment": {
"conversationName": "example"
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…