-
Notifications
You must be signed in to change notification settings - Fork 45
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
[#1798] fix not rendered content messages in facebook render library #1818
[#1798] fix not rendered content messages in facebook render library #1818
Conversation
buttons: attachment.payload.elements[0].buttons, | ||
}; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added Media Template: https://developers.facebook.com/docs/messenger-platform/reference/templates/media/
title: attachment.payload.title, | ||
url: attachment.payload.url, | ||
title: attachment.payload?.title ?? attachment.title, | ||
url: attachment.payload?.url ?? attachment.url, | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback attachment does not always include the title
and url
in the payload
:
|
||
if (messageJson.attachment || messageJson.attachments) { | ||
return parseAttachment(messageJson.attachment || messageJson.attachments[0]); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message with fallback attachment can include a text (unlike other attachments)
})} | ||
</> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FB templates all include a buttons
array so I created a reusable Buttons
component
{buttons && <Buttons buttons={buttons} mediaTemplate={true} />} | ||
</div> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Media Template component
- media templates only accept FB URLs or FB ids so we cannot embed them
https://developers.facebook.com/docs/messenger-platform/send-messages/template/media
payload?: string; | ||
game_metadata?: { | ||
player_id?: string; | ||
context_id?: string; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored the typings of the Buttons + added more types
@@ -14,7 +50,7 @@ export interface ButtonAttachment extends Attachment { | |||
payload: { | |||
text: string; | |||
template_type: 'button'; | |||
buttons: Button[]; | |||
buttons: (URLButton | PostbackButton | CallButton | LoginButton | LogoutButton | GamePlayButton)[]; | |||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the typing here: the messages templates include a buttons
array that can accept different buttons (and not only web_url
buttons)
https://developers.facebook.com/docs/messenger-platform/reference/buttons
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
closes #1798
Changes
Screenshots
![Screenshot 2021-05-21 at 11 40 03](https://user-images.githubusercontent.com/38159391/119117204-4b055c00-ba29-11eb-858f-ac3336ab5c58.png)
Media Template: includes video or image (accepts only FB URLs so cannot be embedded) + buttons