Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push message with Quick Reply not working #728

Open
wintermute2048 opened this issue Dec 27, 2024 · 1 comment
Open

Push message with Quick Reply not working #728

wintermute2048 opened this issue Dec 27, 2024 · 1 comment
Labels

Comments

@wintermute2048
Copy link

System Informations

  • Python version: 3.12.7
  • SDK version: 3.14.2
  • OS: Windows and Ubuntu

Expected Behavior

I want to send a message and quick-reply buttons should be displayed. I use this code:

qr = QuickReply(items=[
    QuickReplyItem(action=Action(
        label="Accept",
        text="Accept",
        type="message"),),
    QuickReplyItem(action=Action(
        label="Decline",
        text="Decline",
        type="message")),
])
message = TextMessage(
    text="Please accept or decline",
    quick_reply=qr)
pmr = PushMessageRequest(to=LINE_USER_ID, messages=[message])
print("PMR", pmr)
result = await line_bot_api.push_message(pmr)

Current Behavior

I get the following error message and the message is not sent via LINE.

HTTP response body: {"message":"The request body has 2 error(s)","details":[{"message":"must be specified","property":"messages[0].quickReply.items[0].action.text"},{"message":"must be specified","property":"messages[0].quickReply.items[1].action.text"}]}

It seems that the server complains, that the action of the quick-reply-item has no element "text".
The reason for this is that import linebot.v3.messaging.Action does not have this field.

Workaround

With the following monkey-patch, everything works fine:

import linebot.v3.messaging

class PatchedAction(linebot.v3.messaging.Action):
    text: StrictStr

linebot.v3.messaging.Action = PatchedAction

Suggested Change

Add the field text to the class Action, so that it matches to the structure described here: https://developers.line.biz/en/docs/messaging-api/using-quick-reply/#set-quick-reply-buttons

@wintermute2048 wintermute2048 changed the title Push message with Quick Reply Push message with Quick Reply not working Dec 27, 2024
@Yang-33
Copy link
Contributor

Yang-33 commented Dec 28, 2024

Hi, thank you for using line-bot-sdk-python, @wintermute2048!
What happens when your application uses MessageAction instead of Action?

@Yang-33 Yang-33 added question and removed bug labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants