Messaging
Use @pyyupsk/messenger-webhooks library to send text, images, audio, videos, files, and templates on Messenger.
To send messages to a user on Messenger, the conversation must be initiated by
that user. The
@pyyupsk/messenger-webhooks
library provides the sendMessage
method for sending different types of
messages, each with its own content and structure.
Content Types
The sendMessage
method supports several types of content, including:
- Text
- Images
- Audio
- Videos
- Files
- Templates
Sending Messages
All messages are sent using the sendMessage
method in the Bot
class. Here is
an example of how to send a message using a template:
Example: Sending a Generic Template
JSON Representation
The sendMessage
method constructs the following JSON payload for the above
example:
Message Types
Here’s how you can use different types of content with the sendMessage
method:
Text Messages
Images
Audio
Videos
Files
Templates
Templates can include various interactive elements such as buttons. You can create different types of templates like Generic Templates, Button Templates, and more, using the corresponding classes and methods provided by the library.
By using these methods, you can create rich and interactive messages tailored to your needs, ensuring a better user experience on Messenger.
Last updated on