Azure Function for Bot Framework C#

别说谁变了你拦得住时间么 提交于 2019-12-24 10:16:44

问题


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.

I tryed to do something like that :

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);   

}

but i have this error :

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.

Thank you for reading me.


回答1:


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)

You have a couple of options:

  1. Uncheck the box to use the return value of of your function and name the parameter message

Or

  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.



来源:https://stackoverflow.com/questions/42559322/azure-function-for-bot-framework-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!