【发布时间】:2018-12-11 22:05:38
【问题描述】:
我正在尝试让机器人回复 Bot Framework V3 中的电子邮件。但是我很难理解如何从对话框中调用对象,甚至如何创建 JSON 对象。 这些示例已被微软删除,因此几乎没有关于如何执行此操作的示例或文档。 有没有人有我可以使用的对话框回复电子邮件的示例?
提前致谢。
这是我当前的代码,但它不起作用:
对话框: 感谢你的回复。 这个对话框就够了吗?收件人等呢? 文档很吓人,只告诉你 Json 的外观。
这是我的代码:
消息控制器:
else if (activity.ChannelId == "email")
{
await Conversation.SendAsync(activity, () => new EmailDialogDante());
}
对话框:
public async Task StartAsync(IDialogContext context)
{
var message = context.Activity as IMessageActivity;
var reply = context.MakeMessage();
reply.ChannelData = new BotchannelData();
{
ChannelData channelData = new ChannelData();
ChannelDataInter channelDataInter = new ChannelDataInter();
}
await context.PostAsync(reply);
// await fetchOrderDetails(context, query);
}
这些是我的 Json 对象:
public class BotchannelData
{
[JsonProperty("channelData")]
public ChannelData ChannelData
{
get;
internal set;
}
}
}
namespace SimpleEchoBot.EmailJson
{
public class ChannelData
{
public ChannelData()
{
this.Type = "message";
this.Locale = "en-Us";
this.ChannelID = "email";
}
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("locale")]
public dynamic Locale { get; set; }
[JsonProperty("channelID")]
public dynamic ChannelID { get; set; }
[JsonProperty("from")]
public From From { get; internal set; }
[JsonProperty("recipient")]
public Recipient Recipient { get; internal set; }
[JsonProperty("conversation")]
public Conversation Conversation { get; internal set; }
[JsonProperty("channelData")]
public ChannelDataInter ChannelDataInter { get; internal set; }
}
}
namespace SimpleEchoBot.EmailJson
{
public class ChannelDataInter
{
public ChannelDataInter()
{
this.HTML = "test";
this.Subject = "testing";
this.Importance = "high";
}
[JsonProperty("html")]
public string HTML { get; set; }
[JsonProperty("subject")]
public dynamic Subject { get; set; }
[JsonProperty("importance")]
public dynamic Importance { get; set; }
}
}
【问题讨论】:
标签: c# json azure botframework