Skip to main content

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!"  }}