Public API

When instantiating ConversationalForm a reference to the instance will be available in window scope.

window.ConversationalForm

Be aware that if you create mutiple Conversational Forms within one page then the reference will be overwritten with latest created. Use windo.ConversationalForm[form["cf-create-id"]]?` or just manually instantiate the form and user the returned instance.

Method Description Code
addTags Add tags to the form, see examples/formless.html for how this can be achived.
window.ConversationalForm.addTags(
	tagsData/*: Array*/, 
	addAfterCurrentStep/*: boolean = true*/, 
	atIndex/*: number = -1*/);
focus Sets focus on Conversational Form.
window.ConversationalForm.focus();
focus Sets focus on Conversational Form.
window.ConversationalForm.focus();
addRobotChatResponse add a robot reponse, this you would usually do at the end of a process.
window.ConversationalForm.addRobotChatResponse(
	"You have reached the end of the form!"
);
addUserChatResponse add a user reponse. The opposite of the above.
window.ConversationalForm.addUserChatResponse(
	"Hello from user."
);
remove remove the ConversationalForm by calling:
window.ConversationalForm.remove();
getFormData get the FormData object of mapped form element, pass in true to get a serialized object back (JSON).
window.ConversationalForm.getFormData(serialized);
remapTagsAndStartFrom remap registered tags and start flow from {index} possible to ignore existing tags, to allow for the flow to just "happen".
window.ConversationalForm.remapTagsAndStartFrom(
	index, 
	setCurrentTagValue, 
	ignoreExistingTags
);