这是我的代码,我正在尝试通过directline
将自定义消息从机器人发送到客户端应用程序。但是通过这个,我能够接收有效载荷或文本。
var msg = new botbuilder.Message(session).sourceEvent({
directline: {
text:'Creating a note named '+note.title+ 'with description as '+ note.text,
payload:{
action: "CREATENOTE"
}
}
});
session.endDialog(msg);
在客户端,我得到Activity
响应:
{ type: 'endOfConversation',
id: '6WYDh0QKiy31ij05UbsQgV|0000006',
timestamp: '2018-04-09T05:18:23.2532985Z',
localTimestamp: '2018-04-09T05:18:23.164+00:00',
channelId: 'directline',
from: { id: 'SarthakNotesBot', name: 'SarthakNotesBot' },
conversation: { id: '6WYDh0JKiy31ij05UasQgV' },
replyToId: '6WYDh0QKiy31ij05UasQgV|0000004',
code: 'unknown' }
Activity
回应说code:unknown
不知道如何在直线上做到这一点。
我像下面这样解决了它:
var msg = new builder.Message(session).entities([
{ action: "CREATENOTE",
payload: "other payload"
}
])
.text('Creating note named '+note.title+ ' with note description as '+ note.text);
session.endDialog(msg);
检查下面我们如何在BOT中创建自定义消息:
var customMessage = new builder.Message(session)
.text("Hello!")
.textFormat("plain")
.textLocale("en-us");
session.send(customMessage);
有关更多信息,请访问官方Microsoft文档:创建消息