Send Message
Request
You need to send a POST request to:
https://yoai.yophone.com/api/pub/sendMessage
Request body params format (JSON)
-
to(required):
The unique identifier for the target chat or the username of the target channel. -
text(required):
The text of the message to be sent. -
generation(optional):
Sends the message as a loader for an image that is still being generated. See Image Generation Placeholders.
Request example (POST):
Expecting Message format
{
"to": "123456789",
"text": "Hello, this is a message from my YoAI!"
}
Request example
curl -X POST https://yoai.yophone.com/api/pub/sendMessage \
-H "Content-Type: application/json" \
-H "X-YoAI-API-Key: your YoAI api token" \
-d '{
"to": "123456789",
"text": "I love YoAI"
}'
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"
}
}
messageId:
The unique identifier of the sent message. Store it if you want to edit the message later.
Failure response format
Errors are also returned with HTTP status 200. The code field holds the actual error code:
{
"success": false,
"code": 404,
"text": "user: user not found"
}
Bot Sharing
When sharing your bot's link in the following format:
https://join.yophone.com/yoai/someBot?start=someMessage
YoAI will automatically send the following message to your bot when a user opens the link:
/start someMessage
This allows you to handle dynamic onboarding or deep linking into your bot using the start command with custom arguments.