[英]Have a Microsoft Azure web app chatbot proactively contact a user using e-mail or Twilio from a table/list of preset users
我有一个使用Azure制作的简单Web应用聊天机器人。 这非常简单,它将向用户询问3个问题,将答案记录到存储表中,然后将答案重复返回给用户。
我已经使用azure门户中的“通道”选项卡将其连接到Twilio和电子邮件。 我想知道,是否可能有一个表格或数据库,其中包含该机器人将要联系的电子邮件地址或电话号码,最好是如果某个联系地址的变量从false切换为true,则最好联系该地址。
这是我找到的最接近的示例,但是它使用的是Skype。 不是电子邮件或Twilio。 https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/core-CreateNewConversation
我想要这样的东西
// Every 5 seconds, check for new registered users and start a new dialog
setInterval(function() {
var newAddresses = userStore.splice(0);
newAddresses.forEach(function(address) {
console.log('Starting survey for address:', address);
// new conversation address, copy without conversationId
var newConversationAddress = Object.assign({}, address);
delete newConversationAddress.conversation;
// start survey dialog
bot.beginDialog(newConversationAddress, 'survey', null, function(err) {
if (err) {
// error ocurred while starting new conversation. Channel not supported?
bot.send(new builder.Message()
.text('This channel does not support this operation: ' + err.message)
.address(address));
}
});
});
扫描表,如果切换了变量,它将从表中提取地址并将其设置为address
变量。
我相信我能弄清楚,但是我需要帮助来学习如何使漫游器与用户联系,而无需用户先联系漫游器,而是使用预设用户列表。
如果找不到我无法找到的有关Web应用程序机器人的电子邮件渠道的文档,我想知道如何让该机器人向用户发送电子邮件,以及是否有任何JavaScript类我可以在我的机器人app.js
代码中使用电子邮件渠道。
我希望自己能理解,非常感谢您的帮助
关于在没有首先联系Email和Twilio渠道上的漫游器的情况下联系用户,您可以执行以下操作。
像这样设置每个地址:
电子邮件
var emailAddress =
{
channelId: 'email',
user: { id: <userEmail> },
bot: { id: <botEmail>, name: <botName> },
serviceUrl: 'https://email.botframework.com/'
};
短信
var sms =
{
user: { id: '<userphone>' },
bot: { id: '<botphone>' },
conversation: {id: '<userphone>'},
channelId: 'sms',
serviceUrl: 'https://sms.botframework.com'
};
请注意,SMS不适用于试用的twilio号码,但适用于购买的号码。
设置地址后,您可以通过以下代码来路由每个地址。
var message = new builder.Message()
.address(address)
.text(<messageText>);
try {
console.log(message);
bot.send(message);
} catch (error) {
console.log(error);
}
如有需要,将对其进行编辑以包括加载用户列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.