如果我发送普通消息,我可以将 ChannelData 添加到消息中:
IMessageActivity message = Activity.CreateMessageActivity();
message.ChannelData = JObject.Parse("{'messaging_type':'RESPONSE'}");
但是如果我使用 FormBuilder,
return new FormBuilder<SandwichOrder>()
.Message("Welcome to the sandwich order bot!")
.
...
.Build();
我不知道如何添加 ChannelData。
以下信息是在 Facebook 开发文档中找到的,这也是我提出此问题的原因。
Breaking Change Notice Beginning May 7, 2018 the messaging_type property will be required and all messages sent without it will not be delivered.
最佳答案
您可以通过在 OnCompletion 委托(delegate)中实现它来实现这一点。当表单完成时触发。
return new FormBuilder<SandwichOrder>()
.Message("Welcome to the simple sandwich order bot!")
.OnCompletion((context, state) => context.Activity.ChannelData = JObject.Parse("{'messaging_type':'RESPONSE'}"))
.Build();
关于c# - 使用FormBuilder时如何设置Facebook的ChannelData?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48154033/