5
如何连接你的 Watson assistant 到一个网页应用 再上面我们已经创建了一个聊天机器人服务,那么接下来我们就看一下如何将你的聊天机 器人绑定到一个网页应用中 l 前期条件 a) 请到 Node.js 的官网安装 node.js 的安装环境: b) 点击下载并安装 IBM Cloud CLI 工具: l 现在我们已经有了必要的环境接下来我们就开始搭建属于自己的聊天机器人的网页应 1. 首先我们通过 github 下载一段 sample app 的代码(https://github.com/watson- developer-cloud/assistant-simple) 2. 接下来我们将.env.example 重命名为.env 并将 Watson Assistant 得连接信息填入到文 件中 3. 接下来我们通过一下命令本地运行一下来确保我们的应用可以连接到 Watson

使用 Watson Assistant(2)Note: Ensure that you Cloud Foundry version is up to date Installing locally If you want to modify the app or use it as a basis for building your own app,

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 使用 Watson Assistant(2)Note: Ensure that you Cloud Foundry version is up to date Installing locally If you want to modify the app or use it as a basis for building your own app,

如何连接你的 Watson assistant 到一个网页应用

再上面我们已经创建了一个聊天机器人服务,那么接下来我们就看一下如何将你的聊天机

器人绑定到一个网页应用中

l 前期条件

a) 请到 Node.js 的官网安装 node.js 的安装环境:

b) 点击下载并安装 IBM Cloud CLI 工具:

l 现在我们已经有了必要的环境接下来我们就开始搭建属于自己的聊天机器人的网页应

1. 首先我们通过 github 下载一段 sample app 的代码(https://github.com/watson-

developer-cloud/assistant-simple)

2. 接下来我们将.env.example 重命名为.env 并将 Watson Assistant 得连接信息填入到文

件中

3. 接下来我们通过一下命令本地运行一下来确保我们的应用可以连接到 Watson

Page 2: 使用 Watson Assistant(2)Note: Ensure that you Cloud Foundry version is up to date Installing locally If you want to modify the app or use it as a basis for building your own app,

Assistant >npm install

>npm start

如果你得程序配置正确你应该看到类似如下的界面

4. 访问 localhost:3000 来测试你得应用

5. 现在我们来尝试如何通过 IBM Cloud Foundry APP 来部署你得应用

6. 如果你安装了 IBM CLI 工具那么你可以通过下面命令来登陆你得 IBM Cloud 账户

Page 3: 使用 Watson Assistant(2)Note: Ensure that you Cloud Foundry version is up to date Installing locally If you want to modify the app or use it as a basis for building your own app,

7. 通过 bx target 设置你得组织和空间。可以通过你 Watson Assistant 服务得首页获得

8. 找到 app 中得 manifest.xml 修改相应得连接信息

Page 4: 使用 Watson Assistant(2)Note: Ensure that you Cloud Foundry version is up to date Installing locally If you want to modify the app or use it as a basis for building your own app,

示例中 Smartchattest 是想要部署得 Cloud Foundry App 得名字 smartchat 是

Watson Assistant 服务得名字

9. 通过 bx cf push 来部署你得应用

10. 如果部署时出现无法连接 Watson Assistant 得错误请到服务主页 创建连接

11. 如果出现防火墙得问题无法启动可以直接到 Cloud Foundry App 的首页来手动启动应

12. 现在如果你的应用启动争取的话 你就可以看到如下界面 并通过点击 visit url 来访问你

的应用了

Page 5: 使用 Watson Assistant(2)Note: Ensure that you Cloud Foundry version is up to date Installing locally If you want to modify the app or use it as a basis for building your own app,

note:

1. 除了 sample app 你还可以登陆 github。来获取其他的应用例如天气机器人。发挥

你的想象力结合 IBM Cloud 其他服务来搭建一个属于你的独特的应用吧。