Azure 函数不通知我的机器人(Bot Framework)

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

我正在使用每 X 分钟执行一次的 Azure 函数(计时器触发器函数)。我使用 BotFramework 制作了一个机器人,我希望每隔 x 分钟触发一个 azure 函数。当它被触发时,我的机器人必须得到通知。

我有一个输出 Bot 框架:

这是我的 JSON 文件:

{
  "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
}

我的函数是:

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

我仍然有一个警告,我不知道为什么(也许是问题所在)...警告 AF004:缺少名为 'message' 的绑定参数。不匹配的绑定参数名称可能会导致函数索引错误。

有了这些东西,Azure 功能运行良好,但我的机器人似乎没有收到通知。我是不是忘记了什么?

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)

感谢您的阅读。

您需要将机器人输出绑定名称从 "message" 更改为 "$return",因为您已将函数编码为 return 消息作为函数 return 值而不是作为输出参数。这就是警告试图告诉您的内容。

一旦你解决了这个问题,我也相信 "secret" 值应该是一个应用程序设置名称,其值是你的 bot 秘密。您不应该将秘密直接放在 function.json 文件中。