Heidi widget
Custom templates

Custom Templates

Heidi allows you to provide custom templates for your users. When providing custom templates as params to Heidi.open(), you should follow this format:

Template

AttributeType
contentstring
responsesTemplateQuestion[]
summaryRequiredboolean

TemplateQuestion

AttributeTypeRequiredComment
questionIdstringtrue
questionstringtrue
answerstring[]falseNo need for input request, the answer will be returned in structured data response
answerTypeAnswerTypetruePlease refer to the enum below
answerOptionsstring[]trueIf AnswerType is TextArea or DateResponse, should be empty array;
If AnswerType is SingleResponse or MultipleResponse, should be provided.
dateFormatstringfalseIf AnswerType is DateResponse, this field is required. Please provide the date format you want. E.G. YYYY/MM/DD

AnswerType Enum

Attribute
'SingleResponse'
'MultipleResponse'
'TextArea'
'DateResponse'

TypeScript Interface

interface Template {
  content: string;
  responses: TemplateQuestion[];
  summaryRequired: boolean;
}
 
interface TemplateQuestion {
  questionId: string;
  question: string;
  answer: string[];
  answerType: AnswerType;
  answerOptions: string[];
  dateFormat: string;
}
 
type AnswerType = 'SingleResponse' | 'MultipleResponse' | 'TextArea' | 'DateResponse';