Bot Framework C#的Azure函数

问题描述:

我已经使用BotFramework制作了一个机器人,并且希望每5分钟触发一次azure函数.并且当它被触发时,我的机器人必须被通知.

I've made a bot using BotFramework, and I want to have an azure function triggered every 5 minutes (for example). And when it's triggered my bot must be notified.

但是我不知道该怎么做,我阅读了

But I have no idea how to do this, I read this https://docs.botframework.com/en-us/azure-bot-service/templates/proactive/ but the thing is he didn't use a Timmer Trigger Azure Function but a 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,Timer等),请确保已在启动代码中调用了扩展的注册方法(例如config.UseServiceBus(),config.UseTimers()等). ).

2017-03-02T14:49:40.460 Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.TimerTriggerCSharp1'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'message' to type BotMessage&. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

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

Plus, to indicate which bot has to be notified where the event is triggered is added a output with the direct line key :

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

but as u can see there is the same error than above ...

有人为此提供一些文档或示例吗?

Does someone have some docs or example for that.

谢谢你读我.

您的绑定配置设置为使用函数的返回值(在这种情况下,也与绑定支持的任何类型都不匹配) )

Your binding configuration is set to use the return value of your function (also, in this case, that doesn't match any of the types supported by the binding)

您有两种选择:

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

  1. 将函数的返回类型更改为BotMessageRun方法返回消息实例并删除out BotMessage message参数.
  1. Change the return type of your function to BotMessage return the message instance from your Run method and remove the out BotMessage message parameter.

任何一种方法都可以解决此问题.

Either option should fix this problem.