Edit Message
Use the editMessage method to change a message your YoAI sent earlier, in a private chat or in a channel. You can change the text, markups, buttons and options. Editing attachments is not supported yet.
The edit replaces the content of the original message for everyone in the chat. A YoAI can only edit messages it sent itself.
Request
You need to send a POST request to:
https://yoai.yophone.com/api/pub/editMessage
Request body params format (JSON)
-
to(required):
The unique identifier of the chat or channel the original message was sent to. -
messageId(required):
The identifier of the message to edit. It is returned asdata.messageIdby sendMessage. -
text(required):
The new text of the message. It can not be empty. -
markups(optional):
A list of markup objects for the new text. -
buttons(optional):
The new button configuration, in the same format as in Send Message With Buttons. -
options(optional):
A list of up to 20 {label:"label","value":"value"} objects, as in Send Message With Options.
The edit replaces the whole message content. Send every part you want to keep: if the original message had buttons and the edit has none, the edited message has no buttons.
Request example (POST):
Expecting Message format
{
"to": "123456789",
"messageId": "6f1d2c3e-8f00-11ef-8000-000000000001",
"text": "Order #42 is shipped",
"buttons": {
"grid": 1,
"inline_buttons": [
{
"label": "Track order",
"url": "https://example.com/track/42"
}
]
}
}
Request example
curl -X POST https://yoai.yophone.com/api/pub/editMessage \
-H "Content-Type: application/json" \
-H "X-YoAI-API-Key: your YoAI api token" \
-d '{
"to": "123456789",
"messageId": "6f1d2c3e-8f00-11ef-8000-000000000001",
"text": "Order #42 is shipped"
}'
Response Example:
The response is JSON data with status code 200
Message response format
{
"success": true,
"code": 200,
"data": {
"messageId": "6f1d2c3e-8f00-11ef-8000-000000000001",
"editId": "6f1d2c3e-8f00-11ef-8000-000000000002"
}
}
-
messageId:
The identifier of the edited message. Use the same value to edit the message again. -
editId:
The identifier of this edit.
Failure response format
Errors are also returned with HTTP status 200. The code field holds the actual error code.
{
"success": false,
"code": 404,
"text": "message not found"
}
code | text | Reason |
|---|---|---|
| 400 | not allowed | Your YoAI is not allowed to post in this chat. |
| 403 | message can not be edited | The message was not sent by your YoAI. |
| 404 | message not found | There is no message with this messageId in the chat given in to. |
| 422 | Error validating edit message data | A parameter is missing or invalid. The errors field lists the parameters. |