Hi, I have a use case where some user can make forms on a web frontend, and others can fill the form by specifying the code, so there’s a database of forms. I need to retrieve the questions and ask for the inputs. Is there any way I can do that?
As of now, my code looks like this, this only prints out the questions :
# actions.py
class ActionMonitIsi(Action):
def name(self) -> Text:
return "action_monit_isi"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
form_code = tracker.get_slot('form_code')
uname = tracker.sender_id
answer = []
r = requests.get(url = 'http://localhost:8080/monit/code/' + form_code + '/questions')
if (r.status_code == 200):
questions = r.json()['data'][0]
if (questions):
for question in questions:
dispatcher.utter_message(text=question['question'])
# NEED TO LISTEN TO USER INPUT HERE
answer.append({
'q_id': question['q_id'],
'answer' : # FROM USER INPUT
})
# SAVE TO RECORDS DATABASE HERE
else :
dispatcher.utter_message(text='The owner of this form haven't set any question field.')
else:
dispatcher.utter_message(text='Server error.')
return [AllSlotsReset()]
I also found this from stackoverflow but I can’t seem to get it to work.