How to pass customData via webSDK?

(Subrahmanyam Donepudi) #1

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:

If the user signup on a website, will he have to login again in the chatbot (if it requires authentication) and vice versa?
Standard Responses - Can I use context variables in standard response?
How to use context session in Welcome Message
(Siva L) #2

Can i pass multiple custom values in customData?

(Subrahmanyam Donepudi) #3

@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.