|
Post by account_disabled on Jan 30, 2024 3:36:11 GMT
如果您热衷于了解有关 AI 的更多信息,请观看我们的截屏视频Microsoft 认知服务和文本分析 API,了解您的机器人中的 AI 情绪。 Play Next Unmute Current Time Duration 2:00 Fullscreen Backward Skip 10s Play Video Forward Skip 10s 如何将 Api.ai 助手连接到物联网 当个人助理能够通过物联网访问个人数据和现实世界时,它的潜力就会变得令人兴奋。新的可能性出现了——从要求你的助手打开你的灯到询问你睡得怎么样。作为示例,我们将把您的 Api.ai 助手连接到 Jawbone Up API。 注意:本文于 2017 年更新,以反映 Api.ai 的最新更改。 你需要什么 本文基于我们在 SitePoint 之前的文章中已经介绍过的各种概念。为了轻松地学习本教程,您需要具备以下条件。 Learn to Code with JavaScript 连接到简单 HTML Web 应用程序的 Api.ai 代理。 如果您想了解此过程,请参阅本文。否则,您也可以从本指南下载代码并使用它。 一个被教导了“睡眠”实体的特工。我们在使用实体为您的 Api.ai 助手提供支持中创建了此内容。它应该理解诸如“我昨晚睡了多少觉?”之类的概念。以及“我的快速眼动睡眠时间是多少?” 如果您 WhatsApp 号码数据 希望使其适应您自己的 IoT 设备,您需要创建自己的自定义实体来了解您的 IoT 功能。 Node.js 和运行 Node 服务器的一般知识。没有它,您将无法运行服务器! 了解如何使用 Jawbone UP API(或您打算使用的其他 API)。我们之前在使用 Node.js 连接到 Jawbone Up API 中介绍了 Jawbone Up API,我将在全文中引用该文章中的部分。 用于在 HTTPS 上运行您的网站的 SSL 证书。如果使用 Jawbone Up API,您将需要它。正如本系列开头所提到的,总体而言,在 HTTPS 上执行许多操作要容易一些。 如果您有兴趣,我们将在 Jawbone Up API 文章中介绍如何设置自签名证书,但这并不是当今最简单的选择。您可以使用本系列第一篇文章中提到的 Let's Encrypt 轻松完成此操作。还提供了一个很棒的原型环境,默认情况下带有 HTTPS。 代码 该演示的所有代码都可供您下载和使用!您可以在 GitHub 上找到所有内容。 这是如何运作的 您的 Api.ai 助手已连接到一个简单的 Web 应用程序,该应用程序通过 HTML5 语音识别 API 接受语句。从这里开始,您需要添加一些新的功能来侦听来自 Api.ai 代理的特定操作。在你的例子中,这是“sleephours”的动作。 每当您的 JavaScript 检测到此操作时,它都会触发对 Node.js 应用程序的单独您的项目结构 我已将应用程序从最初的纯 HTML 结构调整为使用 EJS 视图的结构,以便您在通过 OAuth 登录 Jawbone Up API 时可以在 Web 应用程序中切换页面。
|
|