Azure 函数不通知我的机器人(机器人框架) [英] Azure function doesn't notify my bot (Bot Framework)

查看:38
本文介绍了Azure 函数不通知我的机器人(机器人框架)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

我有一个输出 Bot Framework:

I have for that an output Bot Framework :

这是我的 JSON 文件:

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
}

而我的功能是:

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:缺少名为消息"的绑定参数.不匹配的绑定参数名称可能会导致函数索引错误.

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.

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

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)

感谢您的阅读.

推荐答案

您需要将机器人输出绑定名称从 "message" 更改为 "$return",因为您已经对函数进行了编码,以将消息作为函数返回值而不是作为输出参数返回.这就是警告试图告诉你的.

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.

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

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.

这篇关于Azure 函数不通知我的机器人(机器人框架)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆