Hello 👋 How can we help?

Set a pre-chat form for your chat widget

A pre-chat form will help you know more about users to give them a perfect consultation.
Written by Andrew
Updated 2 weeks ago

If you want to ask users for their name / email / phone / company or any other custom attributes, use a pre-chat form, which is available in the HelpCrunch SDK.

To enable it, you need to create an array of HCSUserAttribute and set them to HCSConfiguration’s userAttributes property.

You can either use one of the four predefined attributes or create a custom one. If you set an attribute as Required, we will show a Welcome screen up until users enter their data. If you have just optional attributes, we will show a Welcome screen only once.

ObjC:

configuration.userAttributes = 
@[
    // Predefined attributes
    [HCSUserAttribute nameAttributeAsRequired:true],
    [HCSUserAttribute companyAttributeAsRequired:true],
    [HCSUserAttribute emailAttributeAsRequired:true],
    [HCSUserAttribute phoneAttributeAsRequired:false],

    // Custom attributes
    [[HCSUserAttribute alloc] initWithAttributeName:@"Custom"
                                        placeholder:@"My custom"
                                           required:true],
    [[HCSUserAttribute alloc] initWithAttributeName:@"Custom2"
                                        placeholder:@"Please enter something"
                                           required:false]
];

Swift:

configuration.userAttributes =
  [HCSUserAttribute.nameAttribute(asRequired: true),
   HCSUserAttribute.companyAttribute(asRequired: true),
   HCSUserAttribute.emailAttribute(asRequired: false),
   HCSUserAttribute.phoneAttribute(asRequired: true),
   HCSUserAttribute(attributeName: "Custom", placeholder: "Custom placeholder", required: true),
   HCSUserAttribute(attributeName: "Custom2", placeholder: "Please enter something", required: false)]

Did this answer your question?