Embeddable Web Form APIs in BoldDesk
The Embeddable Web Form APIs allow you to pre-fill all the fields in the Contact Us form. The Embeddable Web Form APIs allow developers to:
- Pre-fill form fields dynamically.
- Open articles programmatically.
- Customize form behavior during page load.
Prefill Form Fields
To fill out the form, simply use the Prefill API. For dropdown type (single or multi-select), assign the id as the value. For other fields, simply assign a string value.
Purpose
Use the Prefill API to populate fields in the Contact Us form before rendering.
Usage
- For dropdown fields (single or multi-select): assign the ID as the value.
- For text fields: assign a string value.
Example
BolddeskWidget('fill', 'form', {
name: 'Daniel',
emailId: '[email protected]',
categoryId: 12,
cf_country: 21,
cf_state: 17
});
Open an Article
You can use this API to open an article when your customers click on a link on your website. When using this API, you need to provide the article ID.
Purpose
Open a specific article when a user clicks a link on your website.
Usage
Provide the article ID in the API call.
Example
BolddeskWidget('open', 'article', {
id: 123 // article ID
});
Onload Customization
Add the following script above the embedded code to pre-fill the form fields when the page loads.
Purpose
Pre-fill form fields automatically when the page loads.
Usage
Add the following script above the embedded code:
Example
<script>
window.BolddeskWidgetConfig = {
form: {
fill: { name: "Daniel", emailId: "[email protected]", categoryId: 12 }
},
created: (args) => {
// When the web form is rendered, the created event will be triggered.
}
}
</script>
Created Event Details
When a Web Form is rendered, the created event will be triggered. The following properties can be found in the created event argument.
{
type: 'form',
id: 'Web form Id',
name: 'Web form Name'
}
FAQs
Q1: How do I find the dropdown field IDs?
A: Check your BoldDesk admin panel for field configurations. Each dropdown option has a unique ID.
Q2: Can I pre-fill multiple custom fields?
A: Yes, include all custom fields in the fill object using their respective keys.
Q3: Is the created event mandatory?
A: No, it’s optional but useful for tracking form rendering.