User Variables

User Variables

User Variables are fetched from your API and secured by User Authentication.

Fetch User Variables

To fetch User Variables you need to configure User Authentication for your Chatbot. As part of the configuration you can specify a User Data API URL.

data Api

Whenever a user is authenticated, the Chatbot will make a REST call to the User Data API to fetch the user data. The call includes the user JWT as Authorization header.

You can test your User Data API with this call:

USER-JWT-TOKEN="..."

curl -H "Authorization: Bearer ${USER-JWT-TOKEN}" \
     -X GET \
     https://your-endpoint/user/data

Setup in Solvemate Web App and prerequisites

Prerequisites to use UserVariables:

  • Provide User Data API endpoint that can handle jwt
  • Inject jwt and userId (user Authentication) from your website

To make User Variables available in the Chatbot:

  • Variable name needs to be declared in Workspace -> Variables -> User Variable,
  • Variable value is fetched from User Data endpoint specified in User Authentication integration,
  • User Data endpoint can handle jwt and return information about the user,
  • Variable is used accordingly in texts, forms or function code.

Notes for developers

  • nested variables are not supported,
  • variable values are cached for 30 seconds in the Chatbot,
  • variables should be passed in as a string (integers and booleans currently not supported),
  • User Data API must be able to handle volume of calls: User Data API is fetched on every load and throughout the conversation for logged in users,
  • Variable name in the Solvemate Web App matches the API response key by default, but can also be manually mapped in the Variable configuration
Mapping Api