POST graph.user.messages ✎ Edit on GitHub
Create new messages, modify chats, dialogs and their participants
Content-Type: application/json;charset=utf-8 header should be specified for all Graph API POST requests
This method allows you to do following actions:
- create new chat messages;
- modify chat / dialog state;
- chat participants management;
- notify other chat participants about your actions and state.
Actions over chat state
You can edit following chat data:
- chat title;
- chat logo.
Example request to edit chat title:
Example request to edit chat icon:
Following actions can be done with / or by chat participants:
- add new chat participant;
- remove chat participant;
- leave chat by current user
Example request to add new chat participant:
Example request to remove chat participant:
Example request to leave chat by user:
New message creation
This is a key feature of this method.
To create a new message you need to send a POST-payload data with a message object which is similar to an object that you can get with me/messages/get method.
Text message example:
A message with an IMAGE attachment can be sent:
Support for other attachment types (VIDEO, SHARE, AUDIO) will be added in future.
Current user state
Current user can inform other chat participant about some of his actions or his state:
- mark all messages as seen - mark_seen;
- user us typing a new message - typing_on;
- user is sending new file (video, audio, image) - sending_photo.
Direct user messages
It is possible to send a message from group to a single or multiple users at once.
User must allow to receive group messages before it can be sent to him.
Following message syntax is used for this purpose:
Each user from the list will get a message in his own group-to-user chat.
API will respond with two corresponding list of values: * boolean type values list that indicate if message was or was not successfully sent; * list of user-to-group chat ids in which messages where sent.
To send a message directly to one user you can use a simplified message syntax: