dueros / bot-sdk-node.js Goto Github PK
View Code? Open in Web Editor NEW开发度秘BOT的bot-sdk
License: Apache License 2.0
开发度秘BOT的bot-sdk
License: Apache License 2.0
UnhandledPromiseRejectionWarning: TypeError: defaultEventHandler is not a function
at Bot._run (/node_modules/bot-sdk/lib/Bot.js:420:23)
at /node_modules/bot-sdk/lib/Bot.js:386:30
at
我想在我的技能里调用摇控关闭已经对频的设备,可以吗?
Sent from PPHub
hi,目前 Bot 里使用的 session
,数据是存储在 进程的内存 里么?如果我们服务是个集群,部署在多台机器,每台机器多起多个进程,怎么将 session
数据存储在外部呢,比如使用 redis
来存储?
没看到有相关文档呢
官方提供的demo,可以完成技能功能,最近本人采用koa配合bot-sdk,返回数据没问题,但请求技能失败。
TypeError: BodyTemplate5 is not a constructor
at _intentHandler.set (/zl/msites/zl/node_modules/bot-sdk/lib/Bot.js:128:28)
at Bot._intentDispatch (/node_modules/bot-sdk/lib/Bot.js:454:56)
at Bot._run (/node_modules/bot-sdk/lib/Bot.js:424:24)
at /zl/msites/zl/node_modules/bot-sdk/lib/Bot.js:386:30
at
addEventListener('AudioPlayer.PlaybackFinished') with return {outputSpeech: 'Let's go'}, it will trigger device entering into infinite loop playing audio.
尝试把listtemplate4的示例代码在技能控制平台的模拟测试中使用,展示的效果不正常,只有序号,没有文字显示。是SDK的问题吗?
新建立一个智能家居技能选项,用模拟测试 发送 “发现设备” 即可出现如下崩溃信息。
错误信息:
~/duer-node/node_modules/bot-sdk/lib/Session.js:35
let attributes = data.attributes;
^
TypeError: Cannot read property 'attributes' of undefined
at new Session (/home/live/duer-node/node_modules/bot-sdk/lib/Session.js:35:30)
at new Request (/home/live/duer-node/node_modules/bot-sdk/lib/Request.js:40:25)
at Bot (/home/live/duer-node/node_modules/bot-sdk/lib/Bot.js:54:24)
at Bot (/home/live/duer-node/bot.js:10:9)
at IncomingMessage. (/home/live/duer-node/app.js:24:17)
at emitNone (events.js:86:13)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
SDK版本:
"bot-sdk": "^1.1.1"
BaseCard.js
代码片段:
/**
* 生成set函数,比如setTitle
*
* @param {Array} fields 字段名列表
* @private
**/
_extendFunction (fields) {
for (let name of fields) {
this[`set${name}`] = (value) => {
this[name] = value;
}
}
}
ListCard.js
代码片段
/**
* @class ListCardItem 多图片文本列表项
* @extends {BaseCard}
*/
class ListCardItem extends BaseCard {
constructor() {
super(['title', 'content', 'url', 'image']);
}
}
ListCardItem实际生成的set方法是settitle()
setcontent()
seturl()
setimage()
,不是文档描述中的setTitle()
setContent()
setUrl()
setImage()
官方文档ListCard Example
let listCardItem = new ListCardItem();
listCardItem.setTitle('标题');
listCardItem.setContent('内容');
listCardItem.setUrl('http://wwww.');
listCardItem.setImage('http://wwww.image');
let listCard = new ListCard();
listCard.addItem(listCardItem);
SDK里 /lib/Request.js 部分代码:
class Request {
/**
* @param {Object} data request body
**/
constructor (data) {
if (!data) {
throw new Error('data is undefined');
}
this._data = data;
if (data && data.request) {
this._requestType = data.request.type;
}
console.log(data);
this._session = new Session(data.session);
if (this._requestType == 'IntentRequest' && data.request) {
this._nlu = new Nlu(data.request.intents);
}
}
智能家居技能协议文档:
{
"header": {
"namespace": "DuerOS.ConnectedHome.Discovery",
"name": "DiscoverAppliancesRequest",
"messageId": "6d6d6e14-8aee-473e-8c24-0d31ff9c17a2",
"payloadVersion": "1"
},
"payload": {
"accessToken": "*OAuth Token here*",
"openUid": "27a7d83c2d3cfbad5d387cd35f3ca17b"
}
}
data里面并没有 session这个字段???
nodejs版本是不做协议兼容的, 由开发者自行实现智能家居的协议对接么?
部署node.js的服务器,必须是支持https的?
BeagleBone Black嵌入式开发板原生支持node.js,想问问bot-sdk支持它吗?https://blog.csdn.net/yaked/article/details/76284287?utm_source=blogxgwz5
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.