2

We have developed a watson assistant chatbot and integrated with client application. Now we want know how many times each user calling watson service from client application and its billing details per person.

I have enabled the user metrics option using below approach and Active users graph is updated with user count. But I want to know the per user api calls details, I have checked in viewLogs(IMPROVE TAB) and Usage tab in billing section and its not showing the per user api calls and billing details. Please let me know where i can get the details of each user api calls details.

https://console.bluemix.net/docs/services/conversation/logs.html#user_id

 "context" : {
  "metadata" : {
   "user_id": "{UserID}"
   }
   }
user2319726
  • 143
  • 1
  • 1
  • 10

1 Answers1

1

There is no UI to show chats from a specific user. Instead, as described here you must use the REST API via curl to retrieve logs.

However when using user_id you cannot filter for a specific user. I have tried actually doing this but I am not able to retrieve logs for a specific user_id.

You can retrieve logs filtered for a customer_id and therefore I recommend you set both user_id and customer_id to the same value, and filter using customer_id.

To set customer_id do as the SDK docs say and add a 'headers' object to the payload sent to Assistant with X-Watson-Metadata with value customer_id. For example in NodeJS:

payload.headers = {'X-Watson-Metadata': `customer_id=CUSTOMER_ID`}
assistant.message(payload, (err, data) => {

Then you can retrieve logs for a specific customer from Assistant by filtering by customer_id:

curl -X GET -u "apikey:KEY" 'https://gateway.watsonplatform.net/assistant/api/v1/workspaces/WORKSPACE/logs?version=2018-09-20&filter=customer_id::CUSTOMER_ID'
DSeager
  • 217
  • 1
  • 4
  • thanks @DSeager for your answer, I will try with above options. – user2319726 Dec 21 '18 at 09:46
  • hi @dseager, I have tried with the above steps and got below result, its showing empty array for the customer.{"logs":[],"pagination":{}} curl -X GET -u "apikey:key" "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/workspaceid/logs?version=2018-09-20&filter=customer_id=customer5" tried below 1 got same curl -X GET -u "apikey:key" "https://gateway.watsonplatform.net/assistant/api/v1/user_data?customer_id=customer5&version=2018-09-20" var payload = { workspace_id: workspace,headers: {'X-Watson-Metadata': 'customer_id=customer5'},context: {metadata :{}},input: {}}; – user2319726 Dec 27 '18 at 09:54
  • any one have idea about this ? – user2319726 Dec 28 '18 at 10:26