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.
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": {
"id": 45,
"chatId": "{senders id}",
"sender": {
"id": "sender id",
"isBot": true,
"firstName": "MyBot",
"userName": "my_bot"
},
"text": "Hello, this is a message from my bot!"
}
}
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.