who can tell me how to do with linebot event with Azure Durable Function?

胡 海云 0 Reputation points
2024-02-08T06:44:36.6+00:00

Azure Durable Function with linebot event trouble

I have Azure Durable Function with linebot event trouble, under the event did not work. Who can tell me what should I do? thank you in advance.

@myApp.activity_trigger(MessageEvent, input_name="response")
@handler.add(MessageEvent, message=TextMessage)
def message_text(event,response):
    line_bot_api.reply_message(
        event.reply_token,
        TextSendMessage(text=response, quick_reply=quick_reply),
        timeout=None
    )
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,363 questions
Azure Event Grid
Azure Event Grid
An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
322 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JananiRamesh-MSFT 22,121 Reputation points
    2024-02-16T03:17:51.17+00:00

    @胡 海云 Thanks for reaching out. I would probably break the linebot stuff outside the durable framework and into its own activity. By separating the Linebot event handling from the Azure Durable Function, you can isolate the responsibilities of each component and make your code more modular and easier to manage.

    Linebot event handler

    @handler.add(MessageEvent, message=TextMessage)
    def handle_message(event):
        # Process the message here
        response = process_message(event.message.text)
    
        # Reply to the Linebot message
        line_bot_api.reply_message(
            event.reply_token,
            TextSendMessage(text=response),
            timeout=None
        )
    

    Azure Durable Function

    @func.durable_activity_function
    def process_message(message_text):
        # Perform some processing on the message text
        processed_message = "Processed message: " + message_text
        return processed_message
    

    In this example, the Linebot event handler handle_message is responsible for receiving the message event, calling the Azure Durable Function process_message to process the message text, and then sending a reply. Adjust this example according to your specific needs and ensure that your function has the necessary permissions to perform its tasks.

    do let me know incase of further queries.

    0 comments No comments