olark.configure('system.custom_prechat', [
	{ 
		is_required: false, 
		label: 'What can we help with today?', 
		placeholder_text: 'I need help with ...' , 
		type: 'textarea' 
	} 
]);

Notes

Dynamically add questions to your prechat survey with ‘system.custom_prechat’. Pass an array of the questions you’d like to add using the format below:

olark.configure('system.custom_prechat', [
  {
    type: "textarea",
    is_required: false,
    label: 'What can we help with today?',
    placeholder_text: "I need help with..."
  }
]);

The type property refers to the type of question you would like to ask your visitors and is used in form styling and validation. Options include:

  • name,
  • email,
  • phone,
  • website,
  • textarea (good for long response questions)
  • textfield (good for short response questions).

The is_required property will mark a particular question as required or not. Required fields will appear with a * inside the input field.

The label property refers to the text above the input field. This field is only necessary to pass for questions where the type is textarea and textfield.

The placeholder_text property refers to the grey preview text inside of the input field, to help prompt visitors to fill out the form. This property is only required for textarea and textfield type questions.

These questions will be added to your existing prechat survey that you have built on the Text & Forms settings page. Keep in mind you can have a maximum of 6 questions in your prechat survey, any questions that do not fit will not appear.

This requires the pre-chat survey to be enabled first.

This setting can also be enabled on the pre-chat survey section of the Text & Forms settings page.

You can read more about using the pre-chat survey in our Help Center.

To add fields dynamically to an offline form, you can use this same format outlined above but use the system.custom_offline_form configure call.

Note: We’ll do our best to help with any questions you have. However, please keep in mind that the API is intended to be self-serve for web developers, so we’re not able to write or debug your code. If you’re experiencing issues, be sure to have your developer, designer or webmaster review code you’ve written.