node.js - api.ai looping the same intent with different input -


i using api.ai implement assistant app, found it's hard looping on same intent collect different user input (correct me if expression wrong, explain in details.) problem is, have list of elements, , each time want assign exact 1 element 1 person (collected via use input assistant.getargument()), however, want speaks user every time 'who want assign element x to?' (x refers name of element in list). current implementation is, creating separate function, make ask question , collect input/assignment in other function using while loop, @ end of while body call ask function, doesn't work api.ai gives not available in response. ideas on how this? let me know if there unclear.

here brief code snippet showing what's issue & want achieve. want make asks 4 times in api.ai, user input, , store them in output string.

var output = '';      function do_sth(assistant){         let get_name_input = assistant.getargument('name');         output = output + get_name_input + '.';     }      function test_repeat(assistant){         for(let = 0; < 4; i++){             assistant.ask('what name?');             do_sth(assistant);         }     } 

without going complications, let me offer simple solution if understand correctly trying achieve.

the user presented option of 3 pets , dog, cat , rabbit . , asked name them differently. want achieve 1 intent , let's pet_name. name of action pet.name.

the solution pretty simple. create 3 parameters in intent (and make of them "required", checking box). 3 parameters dog_name , cat_name, rabbit_name.

now enable fulfillment intent, , parameters in web hook. can use them directly in out put text. : outputtext = $dog_name." great name puppy. tell me more"; (you can activate when action=="pet.name" ).


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -