Appearance
MyChatBot Webhooks API Integration
Overview
The MyChatBot Webhooks API allows you to integrate any external chat or messaging system with your MyChatBot agent. This enables your AI assistant to communicate with users from any chat platform or custom application that can send HTTP requests.
Setting Up Webhooks
Required Fields
To connect the Webhooks API, you'll need to provide the following fields:
- API Token - A unique token to authenticate your requests
- Unique Page ID - A unique identifier for your integration page
- Reply Webhook URL - The URL where MyChatBot will send responses back
Connection Steps
- Navigate to the Integrations tab in your MyChatBot dashboard
- Select the agent you want to connect to the Webhooks API
- Scroll down to find Webhooks API in the integrations list
- Click the Connect button
- Fill in the required fields:
- API Token: Your unique authentication token that will be used to verify webhook requests
- Unique Page ID: A unique identifier for this integration channel
- Reply Webhook URL: The URL where MyChatBot will send responses back to your system
- Toggle Connect assistant to this channel to enable the integration
- Set the desired Reply Delay (in seconds) using the slider - this controls how quickly your assistant responds
- Click Connect Webhooks API button to save your integration
Sending Messages to MyChatBot
To send messages from your system to MyChatBot, make a POST request to the MyChatBot webhook endpoint:
POST https://api.mychatbot.app/webhook/mychatbot
Request Format
The request should include the following JSON payload:
json
{
"client_id": "UNIQUE_CLIENT_IDENTIFIER",
"page_id": "YOUR_PAGE_ID",
"client_name": "User Name",
"client_avatar": "https://example.com/avatar.jpg",
"platform": "YOUR_PLATFORM_NAME",
"text": "Hello, I have a question",
"attachments": ["https://example.com/image.jpg"]
}
Required Fields:
- client_id: A unique identifier for the end user
- page_id: The unique Page ID you configured in MyChatBot
- platform: A name identifying your platform (e.g., "CustomApp")
- text: The message text from the user
Optional Fields:
- client_name: The end user's display name
- client_avatar: URL to the end user's avatar image
- audio: URL to an audio file (for voice messages)
- attachments: Array of URLs to attached files or images
Receiving MyChatBot Responses
MyChatBot will send responses to the Reply Webhook URL you provided during setup. The response will be sent as a form-encoded POST request with the following parameters:
- text: The response message text
- images: URLs to any images included in the response (if applicable)
- file: URL to any file attachments (if applicable)
- audio: URL to audio files for voice responses (if applicable)
Voice Message Support
The Webhooks API supports voice messages in both directions:
Sending Voice Messages to MyChatBot
Include an audio URL in your webhook request:
json
{
"client_id": "UNIQUE_CLIENT_IDENTIFIER",
"page_id": "YOUR_PAGE_ID",
"client_name": "User Name",
"platform": "YOUR_PLATFORM_NAME",
"audio": "https://example.com/audio.mp3"
}
MyChatBot will automatically transcribe the audio and process it as text.
Receiving Voice Responses
If you've enabled voice responses in your MyChatBot settings, the assistant can respond with voice messages. These will be included in the webhook response as an audio
parameter.
Technical Details
Message Processing
When a message is received by the MyChatBot webhook endpoint, the following process occurs:
- The request is decoded and validated
- The system checks if the channel is active for the given Page ID
- A chat record is retrieved or created for the user
- If the message contains audio, it's automatically transcribed
- The message is added to the conversation history
- The AI assistant processes the message and generates a response
- The response is sent back to the specified Reply Webhook URL
Audio Transcription
If an audio URL is provided in the request, MyChatBot will:
- Download the audio file
- Transcribe the content using speech-to-text capabilities
- Process the transcribed text as a regular message
- Add a prefix indicating it was originally a voice message
Response Generation
After processing the message:
- The AI assistant generates a response based on the conversation context
- Any links or media in the response are extracted
- The text is split into manageable chunks if needed
- Each part of the response is sent to your Reply Webhook URL
- If voice replies are enabled, the text is also converted to speech
Error Handling
MyChatBot will return standard HTTP status codes:
- 200 OK: Request was successful
- 400 Bad Request: Malformed request or missing required fields
- 401 Unauthorized: Invalid API token
- 500 Internal Server Error: Server-side error processing the request
Advanced Features
Multi-part Messages
If your MyChatBot assistant sends a response that exceeds the maximum message length, it will automatically split the message into multiple parts and send them sequentially to your webhook endpoint.
Media Support
The Webhooks API supports various media types:
- Images: Sent as URL references in the
images
parameter - Files: Sent as URL references in the
file
parameter - Audio: Sent as URL references in the
audio
parameter
Response Delay
You can configure the response delay in the MyChatBot dashboard. This sets how long the assistant waits before responding, which can create a more natural conversation flow.
Use Cases
The Webhooks API is perfect for:
- Custom chat applications
- Integration with existing customer support systems
- Mobile app chat functionality
- IoT devices with messaging capabilities
- Custom business applications requiring AI chat support
- Third-party platform integrations not directly supported by MyChatBot