JavaScript-Callback
The JavaScript callback function lets you react to events in the Online Assistant and execute your own logic — for example when a flow is completed.
Integration of own functions
The callback function can be used to react to various events in the assistant.
The result object (res) contains the attributes event with the name of the event and the transaction data data.
<script type="text/javascript">
const licenceCode = "LL-XYZ123456789";
const options = {
selector: "#meister1"
}
Lokalleads.init(licenceCode, options, (res) => {
if(res.event === "init") {
console.log("The assistant has been loaded");
// TODO my implementation
}
if(res.event === "flow_completed") {
console.log("A request was generated", res.data.leadId);
// TODO my implementation
}
});
</script>
Events
The following events can be implemented:
| Name | Description |
|---|---|
init | The assistant has been loaded and is ready. |
flow_completed | The results page of the Online Assistant was reached by the user. |
Data
The following data is available:
| Name | Description |
|---|---|
id | ID of this transaction. |
leadId | ID under which this request can be found in the customer portal. |
inputs | Data entered by the user. |
caution
Other data in the data object should not be used and may change at any time.