andy
andy

Reputation: 2161

how to Send proactive notifications to users with Microsoft bot framework in python?

Microsoft uses the following ways to Send proactive notifications(https://learn.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)

But what I want is to send notifications at the specific time. I thought creating task with asyncio may be the way to solve that. Is this the best way or I can use bot framework's some library to solve this problem?

Upvotes: 1

Views: 873

Answers (1)

Kyle Delaney
Kyle Delaney

Reputation: 12274

The Bot Framework does not have builtin functionality to schedule notifications. You can create an asynchronous task inside your bot like you mentioned, or you can have an external scheduler access a special endpoint in your bot. How to expose such an endpoint can be seen in the proactive messaging sample: https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/python/16.proactive-messages

Upvotes: 2

Related Questions