Shiglet
Shiglet

Reputation: 111

Azure Function for Bot Framework C#

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 :

enter image description here

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.

Upvotes: 0

Views: 1422

Answers (1)

Fabio Cavalcante
Fabio Cavalcante

Reputation: 12538

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.

Upvotes: 3

Related Questions