Search code examples
ibm-watsonwatson-conversation

What is the Customer ID to delete logs from a Watson Assistant Workspace?


In WA workspace in the improve section (watsonplatform.net/eu-de/WA_INSTANCE_ID/workspaces/WA_WORKSPACE_ID/improve/userdata) I can see all the conversations users had with our chatbot.

I would like to try to delete these utilising the delete labeled data api - https://cloud.ibm.com/apidocs/assistant?curl=#delete-labeled-data

The api call:

deletes all data associated with a specified customer ID. The method has no effect if no data is associated with the customer ID.

Where can I find the Customer ID?


Solution

  • As documented here in the docs you have to set a header on your /message POST requests, which associates that message with the customer ID sent.

    The example is

    curl -X POST -u "apikey:3Df... ...Y7Pc9"
     --header
       'Content-Type: application/json'
       'X-Watson-Metadata: customer_id=abc'
     --data
       '{"input":{"text":"hello"}}'
      'https://gateway-eu-de.watsonplatform.net/assistant/api/v1/workspaces/{workspaceID}/message?version=2018-09-20'
    

    You have to create and set the customer ID, which could be a user ID, UUID session ID or some other unique identifier to a user of your bot.

    If you have been sending messages in without a customer ID, then it does not look like these can be deleted.

    If you are using user analytics as described here then I would recommend setting the user_id to the same value as customer ID.

    If using the NodeJS SDK the headers are set in the payload in the call to message:

    var payload = {
      workspace_id: workspace,
      context: req.body.context || {},
      input: req.body.input || {}
    }
    payload.headers = {'X-Watson-Metadata': `customer_id=${req.session.id}`}
    assistant.message(payload, (err, data) => {
    ...