用于在 Bot Framework 上启动主动对话的 TimerTrigger Azure 函数
TimerTrigger Azure Function to start proactive dialog on Bot Framework
简而言之,我想我想要 in combination with this Github Bot Framework example.
的 Nodejs 等价物
我想使用 Azure 函数(我想是 TimerTrigger 函数或可能是 QueueTrigger 函数),它会主动向 people/addresses 的给定 子集发送消息,这些子集具有 ( naturally) 已经在特定平台上向机器人发送了消息。
我的猜测是我需要使用一个 TimerTrigger 并将其绑定到一个存储类型的触发器(queueStorage?blogStorage?),它将维护要发送消息的 address/people 列表,然后通过直线。虽然我对 Azure Functions 完全陌生。
首先,我使用 Proactive 模板在 Azure 上创建了一个机器人服务。在模板中,他们使用 QueueTrigger。我猜 TimerTrigger 的 function.json 看起来像这样:
{
"bindings": [
{
"name": "myQueuedAddresses",
"type": "timerTrigger",
"direction": "in",
"queueName": "bot-queue",
"schedule": "0 0 */1 * * *"
},
{
"type": "bot",
"name": "$return",
"direction": "out",
"botId": "botId"
},
{
"type": "http",
"name": "res",
"direction": "out"
}
]
}
要摄取触发器可能很简单:
bot.on('trigger', function (addresses) {
addresses.forEach(sendToAddress);
function sendToAddress(item) {
var queuedMessage = item.value;
var reply = new builder.Message()
.address(queuedMessage.address)
.text('This is coming from the trigger: ' + queuedMessage.text);
bot.send(reply);
}
});
但是 Javascript 将数据发送到触发器会是什么样子?或者我应该使用什么触发器?
当使用 TimerTrigger Azure 函数时,您不会向触发器函数发送任何数据,它会根据设置的时间表自动执行("schedule" 中的 cron 作业设置:"0 0 */ 1 * * *”)。
在主动机器人模板中:机器人通过队列消息触发功能,一旦触发;该函数通过直线触发机器人。
所以如果你想每天发送一条消息给用户(从Bot),那么你可以使用主动bot模板,只需将触发功能端修改为TimeTrigger,然后尝试发送一些东西在响应中,以便您的机器人知道这是来自 TimerTrigger。 (如果机器人端不再需要写入队列,您也可以将其删除)。
简而言之,我想我想要
我想使用 Azure 函数(我想是 TimerTrigger 函数或可能是 QueueTrigger 函数),它会主动向 people/addresses 的给定 子集发送消息,这些子集具有 ( naturally) 已经在特定平台上向机器人发送了消息。
我的猜测是我需要使用一个 TimerTrigger 并将其绑定到一个存储类型的触发器(queueStorage?blogStorage?),它将维护要发送消息的 address/people 列表,然后通过直线。虽然我对 Azure Functions 完全陌生。
首先,我使用 Proactive 模板在 Azure 上创建了一个机器人服务。在模板中,他们使用 QueueTrigger。我猜 TimerTrigger 的 function.json 看起来像这样:
{
"bindings": [
{
"name": "myQueuedAddresses",
"type": "timerTrigger",
"direction": "in",
"queueName": "bot-queue",
"schedule": "0 0 */1 * * *"
},
{
"type": "bot",
"name": "$return",
"direction": "out",
"botId": "botId"
},
{
"type": "http",
"name": "res",
"direction": "out"
}
]
}
要摄取触发器可能很简单:
bot.on('trigger', function (addresses) {
addresses.forEach(sendToAddress);
function sendToAddress(item) {
var queuedMessage = item.value;
var reply = new builder.Message()
.address(queuedMessage.address)
.text('This is coming from the trigger: ' + queuedMessage.text);
bot.send(reply);
}
});
但是 Javascript 将数据发送到触发器会是什么样子?或者我应该使用什么触发器?
当使用 TimerTrigger Azure 函数时,您不会向触发器函数发送任何数据,它会根据设置的时间表自动执行("schedule" 中的 cron 作业设置:"0 0 */ 1 * * *”)。 在主动机器人模板中:机器人通过队列消息触发功能,一旦触发;该函数通过直线触发机器人。
所以如果你想每天发送一条消息给用户(从Bot),那么你可以使用主动bot模板,只需将触发功能端修改为TimeTrigger,然后尝试发送一些东西在响应中,以便您的机器人知道这是来自 TimerTrigger。 (如果机器人端不再需要写入队列,您也可以将其删除)。