Azure function doesn't notify my bot (Bot Framework)

走远了吗. 提交于 2019-12-01 05:46:06

问题


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 :

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:


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.



来源:https://stackoverflow.com/questions/42579703/azure-function-doesnt-notify-my-bot-bot-framework

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