Adding custom data at botInfo inside index.html of webSDK allows developers to pass additional information of the user accessing the channel.
The details like phone number, address or even the access token if in case the webSDK is hosted on the site which needs authorization are examples of data which can be passed inside the customData .
customData can be accessed from lastMessage under the BotUserSession of the context object.
This data will be specific to the user using webSDK and will last for his user session.
More details on configuring web & mobile SDK has been documented at:
@rajinisiva93 Yes, you could. I have added multiple values to the customData in the index.html file as below: botOptions.botInfo = {name:"Onconnect check","_id":"st-c7a32a24-9d8f-XXXX-832e-ca817XXXX",customData:{"name":"John","age":30,"cars": {"car1":"Ford","car2":"BMW","car3":"Fiat"}}};
Below is the snapshot of data available in BotUserSession for your reference.
How can we perform custom reporting through WebSDK .I have created a API extension in bot builder but don’t know how to proceed forward.Could you elaborate with an example.
We pass some access token inside the custom data since we don’t want to ask for authentication again when apis are called in service nodes (user is authenticated on login to our app). Since the custom data is included on every response of the bot, it is possible to clear the access token after the connection to Kore.ai is made?
do we need to add this in our website page or index,html of websdk?
I have created a js file added in all our website pages, when I try to read the customdata getting undefined variable error. Please provide the steps clearly.
content of js file is below:
botOptions.botInfo = {
name: “XXXX”,
_id: “s465464f”,
customData: {
currentPageUrl: window.location.href // Capture the current page URL
}
}