2

i'm using an Azure Function (Timer Trigger Function) which is execute every X minutes. I've made a bot using BotFramework, and I want to have an azure function triggered every x minutes. And when it's triggered my bot must be notified.

I have for that an output Bot Framework :

enter image description here

Here is my JSON file :

{
  "bindings": [
    {
      "name": "myTimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 */1 * * * *"
    },
    {
      "type": "bot",
      "name": "message",
      "botId": "Azurefunction",
      "secret": "h3VkHcc_PXU.cwA.XXXXXX.XXXXXXXX-XXX",
      "direction": "out"
    }
  ],
  "disabled": false
}

And my function is :

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 BotMessage  Run(TimerInfo myTimer ,TraceWriter log)
{
    BotMessage message = new BotMessage()
    {
        Source = "AzureFunction",
        Message = "Testing"
    };
    return message;
}

I still have a warning i don't know why (maybe it's the problem) ... warning AF004: Missing binding argument named 'message'. Mismatched binding argument names may lead to function indexing errors.

With this stuff the Azure function is working well but it seems that my bot is not notified. Did i forgot something ?

2017-03-03T13:05:00.001 Function started (Id=a5be778e-da6d-4957-a7b5-d9c8f58bd396)
2017-03-03T13:05:00.001 Function completed (Success, Id=a5be778e-da6d-4957-a7b5-d9c8f58bd396)

Thank you for reading.

1 Answer 1

2

You need to change your bot output binding name from "message" to "$return" since you've coded your function to return the message as a function return value and not as an output parameter. That's what the warning is trying to tell you.

Once you fix that, I also believe that the "secret" value should be an app setting name whose value is your bot secret. You shouldn't put the secret directly in your function.json file.

Sign up to request clarification or add additional context in comments.

2 Comments

btw : don't add the key from the output menu (see my pic above) because it will automatically add it in your function.json . As @mathewc said add it in your app setting by creating a new entry "AzureWebJobsBotFrameworkDirectLineSecret"
Work well for output binding but when added Input binding as Bot Framework I received error \"messsage\": \"Exception while executing function: Functions.<functionname> -> Unable to resolve value for property 'BotAttribute.SecretSetting'.\"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.