如何通过直线从 Bot 向客户端应用程序发送带有负载的自定义消息?

How to send a custom message with payload from Bot to Client application via directline?

这是我的代码,我试图通过 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);

更多信息请访问微软官方文档:Create Messages