用于 Bot Framework C# 的 Azure 函数

Azure Function for Bot Framework C#

我使用 BotFramework 制作了一个机器人,我希望每 5 分钟触发一个 azure 函数(例如)。当它被触发时,我的机器人必须得到通知。

但我不知道该怎么做,我读了这个 https://docs.botframework.com/en-us/azure-bot-service/templates/proactive/ 但问题是他没有使用 Timmer Trigger Azure Function,而是使用了 Queue Trigger。

我试过那样做:

using System;
using System.Net;
using System.Net.Http;
using Microsoft.Azure.WebJobs.Host;

public class BotMessage
{
    public string Source { get; set; } 
    public string Message { get; set; }
}


public static HttpResponseMessage  Run(TimerInfo myTimer,out BotMessage message ,TraceWriter log)
{
    message = new BotMessage()
    {
        Source = "AzureFunction",
        Message = "Testing"
    };
    return new HttpResponseMessage(HttpStatusCode.OK);   

}

但是我有这个错误:

2017-03-02T14:49:40.460 Microsoft.Azure.WebJobs.Host:错误索引方法 'Functions.TimerTriggerCSharp1'。 Microsoft.Azure.WebJobs.Host:无法将参数 'message' 绑定到类型 BotMessage&。确保绑定支持参数类型。如果您正在使用绑定扩展(例如 ServiceBus、定时器等),请确保您已在启动代码中调用了扩展的注册方法(例如 config.UseServiceBus()、config.UseTimers (), 等等).

此外,为了指示必须在触发事件的位置通知哪个机器人,添加了带有直线键的输出:

但是正如您所见,存在与上述相同的错误...

有人有相关的文档或示例吗?

感谢您阅读我。

您的绑定配置设置为使用函数的 return 值(同样,在本例中,该值与绑定支持的任何类型都不匹配)

您有两个选择:

  1. 取消选中该框以使用函数的 return 值并将参数命名为 message

或者

  1. 将函数的 return 类型更改为 BotMessage return 来自 Run 方法的消息实例,并删除 out BotMessage message 参数。

任一选项都可以解决此问题。