.net 当有人使用你的机器人时获取通知
我正在开发一个机器人,它将取代一家公司的联系方式。当有人使用bot时,开发人员或公司是否有一种简单的方式获得通知?我正在使用Microsoft Bot Framework和cosmosDB来存储状态数据。有几种方法可以做到这一点。不经意间: 您可以将电子邮件设置为bot的一个通道,但这仅仅意味着用户将通过电子邮件与您的bot通信。但您可以通过此电子邮件跟踪客户联系人 否则,正如上面所说的,您可以嵌入一些简单的逻辑,以便在bot逻辑中命中某个进程时立即发送通知。例如,我嵌入了一个快速功能,可以在点击“conversationUpdate”活动时将电子邮件从一个电子邮件地址发送到另一个电子邮件地址(在本例中是从我的outlook电子邮件发送到我的gmail),因为这意味着新用户已连接到我的机器人。它不会向我发送整个历史记录,只是一个ping作为提醒,用于跟踪:.net 当有人使用你的机器人时获取通知,.net,azure,botframework,.net,Azure,Botframework,我正在开发一个机器人,它将取代一家公司的联系方式。当有人使用bot时,开发人员或公司是否有一种简单的方式获得通知?我正在使用Microsoft Bot Framework和cosmosDB来存储状态数据。有几种方法可以做到这一点。不经意间: 您可以将电子邮件设置为bot的一个通道,但这仅仅意味着用户将通过电子邮件与您的bot通信。但您可以通过此电子邮件跟踪客户联系人 否则,正如上面所说的,您可以嵌入一些简单的逻辑,以便在bot逻辑中命中某个进程时立即发送通知。例如,我嵌入了一个快速功能,可以在点
else if (turnContext.Activity.Type == ActivityTypes.ConversationUpdate)
{
if (turnContext.Activity.MembersAdded != null)
{
// Iterate over all new members added to the conversation
foreach (var member in turnContext.Activity.MembersAdded)
{
// Greet anyone that was not the target (recipient) of this message
// the 'bot' is the recipient for events from the channel,
// turnContext.Activity.MembersAdded == turnContext.Activity.Recipient.Id
// indicates the bot was added to the conversation.
if (member.Id != turnContext.Activity.Recipient.Id)
{
await turnContext.SendActivityAsync($"Hi there - {member.Name}. {WelcomeMessage}", cancellationToken: cancellationToken);
await turnContext.SendActivityAsync(InfoMessage, cancellationToken: cancellationToken);
await turnContext.SendActivityAsync(PatternMessage, cancellationToken: cancellationToken);
}
EmailPingFunction();
}
}
}
然后我构建了emailping函数,如下所示:
private static void EmailPingFunction()
{
// setup strings
string sender = "BotsyJohnson@outlook.com";
string password = "********"; // put your email's password here ^_^
string recipient = "BotsyJohnson@gmail.com";
// set the client:
SmtpClient outlookSmtp = new SmtpClient("smtp-mail.outlook.com");
// use the 587 TLS port
outlookSmtp.Port = 587;
// set the delivery method
outlookSmtp.DeliveryMethod = SmtpDeliveryMethod.Network;
// set the credentials
outlookSmtp.UseDefaultCredentials = false;
System.Net.NetworkCredential credentials =
new System.Net.NetworkCredential(sender, password);
outlookSmtp.Credentials = credentials;
// enable SS1
outlookSmtp.EnableSsl = true;
// set up and send the MailMessage
try
{
Console.WriteLine("start to send email over TLS...");
MailMessage message = new MailMessage(sender, recipient);
message.Subject = "This is a test of the not-emergency alert system";
message.Body = "Someone just pinged your bot. Please go into your set storage account to review";
outlookSmtp.Send(message);
Console.WriteLine("email was sent successfully!");
}
catch (Exception ex)
{
Console.WriteLine("failed to send email with the following error:");
Console.WriteLine(ex.Message);
}
}
我只是想强调一下Nicholas R.所说的,因为他是绝对正确的:这是一种习惯,而且只是一种解决方法。这是一种你可以创建某种通知的方法。在你的代码中,当bot处理消息时,你可以向端点发送一些东西来执行某种程序来通知你。有很多方法,因为这是自定义代码部分。因此,我认为你不会收到关于这个问题的明确和独特的答复