Send Message
Use the /api/chat
endpoint to send messages to a bot and receive responses, supporting text and audio inputs.
Endpoint Details
- Route:
/api/chat
- Method: POST
Request Payload
Multipart Form Data Fields
- audio: Audio file in
.wav
format (optional) - data: JSON object containing message details
Example data
Object
{
"bot_id": "bc38325df27a79f0e53f46c1a151cfd7",
"api_key": "da9e35478221a0ccbe28a5598bf24e78",
"message": "Hi, Charles Sears",
"username": "John Doe",
"user_id": "5ere3e3f32vf342r2f",
"is_voice": true,
"image_request": false
}
- bot_id: ID of the bot receiving the messages.
- api_key: Your API key for authentication.
- message: Text message to send to the bot.
- username: User's name sending the message.
- user_id: Unique identifier for the user.
- is_voice: Boolean indicating if the response should be in audio. (true for audio, false for text only).
- image_request: Boolean indicating if an image is requested in response (true or false).
Response
{
"tokens": "No of credits left in the owner's account",
"message": "Bot response",
"voice_path": "Path for audio if is_voice is true else null",
"image_path": "Path for image if image_request is true and user has requested for an image else null"
}
Note
- If voice_path is not null, the message field contains the text version of the audio file associated with the voice_path.
- If image_path is not null, the message field contains the text about the image file associated with the image_path.
Example usage
curl -X POST "https://api.botworx.io/api/chat" \
-F "audio=@/path/to/your/audiofile.wav" \
-F "data={\"bot_id\":\"bc38325df27a79f0e53f46c1a151cfd7\",\"api_key\":\"da9e35478221a0ccbe28a5598bf24e78\",\"message\":\"Hi, Charles Sears\",\"username\":\"John Doe\",\"user_id\":\"5ere3e3f32vf342r2f\",\"is_voice\":true,\"image_request\":false}"