How to Retrieve the IP Address of a User in a Chat Session - WebSDK

Question:
Is there a way to find the IP address of a user during a chat session? I assume it might require passing data through the WebSDK custom data using botOptions.botInfo. Is that the correct approach?

Answer:
To retrieve the IP address of a user in a chat session, you can access it from the session context on the backend. The IP address is typically available in one of the following properties:

  • context.session.UserSession.userRemoteAddress
  • context.session.BotUserSession.channels.botInfo.remoteAddress

Passing the IP address through the WebSDK custom data (botOptions.botInfo) is generally unnecessary if your bot platform captures and provides this information in the session context.

Note:
Access to these properties depends on your bot framework and platform configuration. Be sure to verify permissions and privacy considerations when handling user IP addresses.

Content by @martin.bonardi