使用Chain时获取发送给Bot的第一条消息

时间:2017-03-21 12:44:21

标签: c# botframework

在控制器中  public async Task<HttpResponseMessage> Post([FromBody] Activity activity) 我执行  await Conversation.SendAsync(activity, ()=> MakeJsonRootDialog()); 然后在实现中如何将第一条消息发送到BOT? 完成的对象仅包含对话期间询问的字段:

public static IDialog<JObject> MakeJsonRootDialog(string strDirPath)
    {
        return Chain.From(() => FormDialog.FromForm(preChatInquery.BuildJsonForm))
            .Do(async (context, order) =>
            {
                try
                {
                    var completed = await order;

                    await context.PostAsync("Processed your order!");
                }
                catch (FormCanceledException<JObject> e)
                {
                    string reply;
                    if (e.InnerException == null)
                    {
                        reply = $"You quit on {e.Last}--maybe you can finish next time!";
                    }
                    else
                    {
                        reply = "Sorry, I've had a short circuit.  Please try again.";
                    }
                    await context.PostAsync(reply);
                }
            });  

`

1 个答案:

答案 0 :(得分:0)

使用Chain时,您需要做的第一件事就是使用PostToChain()方法将消息发布到链中。

以下是EchoChainDialog示例中的示例。

public static readonly IDialog<string> dialog = Chain.PostToChain()
            .Select(msg => msg.Text)