简体   繁体   English

IBM Watson Assistant:如何将 Db2 的查询结果作为 CSV 文件下载?

[英]IBM Watson Assistant: How to make query result from Db2 downloadable as CSV file?

I am writing a chatbot program with IBM Watson Assistant in Node.js with Db2 and was wondering if there was a way to add my query results in a CSV file?我正在用 Node.js 和 Db2 在 Node.js 中编写一个聊天机器人程序,我想知道是否有办法将我的查询结果添加到 CSV 文件中?

The csv file will then be downloaded by the user.然后用户将下载 csv 文件。

var data = conn.querySync('SELECT DISTINCT "Commodity" FROM TRADES WHERE "Aggregate_Level"=2');

I did some research and most that i found was codes for the command line interface.我做了一些研究,发现的大部分是命令行界面的代码。

There are libraries to generate all kind of file types, including a CSV file.有一些库可以生成各种文件类型,包括 CSV 文件。 It is done by your app from the query result.它是由您的应用从查询结果中完成的。

In Watson Assistant, you cannot upload or pass through files.在 Watson Assistant 中,您无法上传或传递文件。 But you can respond with a link to where a file is stored.但是您可以使用指向文件存储位置的链接进行响应。 The file could be in Cloud Object Storage (COS) or somewhere else.该文件可能位于 Cloud Object 存储 (COS) 或其他位置。

To get your data from Db2 accessible in the chatbot,要从聊天机器人中访问的 Db2 获取您的数据,

  1. generate a CSV and store it on COS (upload the file to a bucket),生成一个 CSV 并将其存储在 COS 上(将文件上传到存储桶),
  2. generate a download link to the file, there are options to let the link expire within minutes, eg, for security reasons,生成文件的下载链接,有一些选项可以让链接在几分钟内过期,例如,出于安全原因,
  3. pass that link to Watson Assistant and将该链接传递给 Watson Assistant,然后
  4. let the chatbot return the link to the user in a response.让聊天机器人在响应中将链接返回给用户。

The user could then click the link to download the file.然后用户可以单击链接下载文件。

The IBM Cloud solution tutorials have instructions and code for all of the above, but not within a single tutorial. IBM Cloud 解决方案教程包含上述所有内容的说明和代码,但不在一个教程中。 Look for "secure file storage" and for "database-driven chatbot" as a starter.寻找“安全文件存储”和“数据库驱动的聊天机器人”作为入门。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将客户令牌传递到 IBM Watson Assistant - How to passg customer token into IBM Watson Assistant IBM Watson Assistant:如何启用用户指标 - IBM Watson Assistant: How to enable user metrics 如何使IBM Watson Assistant欢迎节点启动与Node.js或Python的对话? - How to make IBM Watson Assistant welcome node starts the conversation with Node.js or Python? IBM Watson Assistant:如何处理来自对话框的上下文变量? - IBM Watson Assistant: How can i handle context variable coming from the dialog? 如何使用Node.js从IBM Watson Assistant V2的响应中获取上下文变量? - How to get context variables from the response of IBM watson assistant V2 using Nodejs? 如何使用nodejs在IBM Db2的LIKE查询中传递参数? - How to pass parameter in LIKE query of IBM Db2 with nodejs? 如何为使用 nodejs 的 Watson Assistant API 查找 ibm-watson 的 api-key 和密码 - How to find api-key and password for ibm-watson for Watson Assistant API working with nodejs IBM Watson Assistant Nodejs中未经授权的问题 - problem of unauthorized in IBM watson assistant Nodejs 如何使用Node.js在IBM Watson Assistant中添加对话框节点的更新多个响应 - how to add update multiple response of a dialog node in IBM watson assistant with Nodejs 如何在Node.js本地开发中集成IBM Watson Assistant服务 - How to integrate IBM Watson Assistant services in Node.js local development
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM