【问题标题】:how to Send proactive notifications to users with Microsoft bot framework in python?如何在 python 中使用 Microsoft bot 框架向用户发送主动通知?
【发布时间】:2020-02-26 08:21:20
【问题描述】:

Microsoft 使用以下方式发送主动通知(https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-howto-proactive-message?view=azure-bot-service-4.0&tabs=python)

async def notify(req: Request) -> Response:  
    await _send_proactive_message()
    return Response(status=201, text="Proactive messages have been sent")

APP = web.Application(middlewares=[aiohttp_error_middleware])
APP.router.add_post("/api/messages", messages)
APP.router.add_get("/api/notify", notify)

但我想要的是在特定时间发送通知。我认为用 asyncio 创建任务可能是解决这个问题的方法。这是最好的方法还是我可以使用机器人框架的一些库来解决这个问题?

【问题讨论】:

    标签: python asynchronous botframework python-asyncio aiohttp


    【解决方案1】:

    Bot Framework 没有用于安排通知的内置功能。您可以像您提到的那样在您的机器人内部创建一个异步任务,或者您可以让一个外部调度程序访问您的机器人中的一个特殊端点。如何公开这样的端点可以在主动消息示例中看到:https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/python/16.proactive-messages

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-07
    • 2018-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-26
    相关资源
    最近更新 更多