简体   繁体   中英

How to export IBM Watson conversation history?

Before running the code, install ibm-watson & ibm-cloud-sdk-core package and also pip instll PyJWT==1.7.1 .

I found in IBM document that "For a Python script you can run to export logs and convert them to CSV format, download the export_logs_py.py file from the Watson Assistant GitHub) repository."

But I don't really know where & how should I modify in order to connect my ibm skill. There is no demo or instruction about where I can find those argument. I only find these information in skill api details but it seems it needs more. Do anyone have an example version about how to use the.py they provided? (I'm a coding beginner, not really understand every lines in the.py)

在此处输入图像描述

The.py shows an error after I run the file without modification:

runfile('C:/export_logs.py', wdir='C:/Users/admin/Downloads')
usage: export_logs.py [-h] [--logtype {ASSISTANT,WORKSPACE,DEPLOYMENT}]
                      [--language LANGUAGE] [--filetype {CSV,TSV,XLSX,JSON}]
                      [--url URL] [--version VERSION]
                      [--totalpages TOTALPAGES] [--pagelimit PAGELIMIT]
                      [--filter FILTER] [--strip STRIP]
                      apikey id filename
export_logs.py: error: the following arguments are required: apikey, id, filename
An exception has occurred, use %tb to see the full traceback.

SystemExit: 2

The conversation I want to download: 在此处输入图像描述

As you can see, the script reported an error and said that you have to provide the apikey , the id and the (presumably output) filename as parameters. It also showed that additional parameters can be specified.

usage: export_logs.py [-h] [--logtype {ASSISTANT,WORKSPACE,DEPLOYMENT}]
                      [--language LANGUAGE] [--filetype {CSV,TSV,XLSX,JSON}]
                      [--url URL] [--version VERSION]
                      [--totalpages TOTALPAGES] [--pagelimit PAGELIMIT]
                      [--filter FILTER] [--strip STRIP]
                      apikey id filename

Your next step could be now to invoke the script again, but provide an API key for Watson Assistant, the skill ID and a filename as additional paramaters. Next, I would try to something like, eg, trying out to specify the output type:

export_logs.py --filetype CSV myapikey skillID output.csv

I am not the author of that script, but that is how I would approach it if I wanted to use it

First of all, Workspaces in IBM Watson Assistant are now called Skills.

To understand what arguments(positional and optional) you need to pass to the Python script, run the below command

python export_logs_py.py -h

Wherever you see workspace, you can replace it with skill.

To export the logs in the .csv file format, run the below command

python export_logs_py.py --filetype CSV --url <URL> <API_KEY> <SKILL_ID> output.csv

Replace placeholders <URL , <API_KEY> and <SKILL_ID> with appropriate values mentioned below.

  • <URL> & <API_KEY> - You can find them under the Manage page of your Watson Assistant service page
  • <SKILL_ID> - The same as the one in the image you uploaded. Check this StackOverflow answer for more info.

For Assistant logs, add --logtype ASSISTANT . The default is WORKSPACE.

You can also find the logs in the UI under Analytics section of your Skill

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM