Chat.SendCustomer
Send a customer message using the same channels as the dashboard composer. Default (from omitted or send_notes) stores an internal note in the Mongo messenger timeline (same as the dashboard). All from values call the dashboard send_message path (notes, WhatsApp, email, Biz1 chat, SMS, messagebox, custom channels). Channel access matches the dashboard: module_sidebarmenu_chat plus account Chat settings (chat_settings_whatsapp / sms / email / quick_email / biz1) and active chat_channel_settings for custom channels. Disabled channels return permission_denied. from=send_email uses the dashboard EMAIL composer path (email_template + {message} replace). from=send_email_quick uses QUICK EMAIL auto-template send.
Permissions
- User must be allowed to write this customer.
- User must have module_sidebarmenu_chat (same as opening customer chat). Missing role key is allowed; explicit 0 is denied.
- Built-in channels must be enabled in account Chat settings (user_detail_2.chat_settings), same defaults as the dashboard composer.
- from=send_email (aliases email/mail) requires chat_settings_email (EMAIL toggle). from=send_email_quick requires chat_settings_quick_email (QUICK EMAIL toggle).
- Custom channels must exist in chat_channel_settings for the owner with active=1.
- send_notes and send_messagebox are always allowed when chat module access is allowed.
Action
- Creates a Chat record or sends the requested data after validation.
Push Service
Pushes event message.created to users who should see this change.
Automation
No automation is run for this function.
Special Instructions
- Send the bearer token on protected calls with Authorization: Bearer YOUR TOKEN.
- Send parameters as POST body fields exactly as documented.
Required Parameters
| Name | Type | Sample | Explanation |
|---|---|---|---|
customer_idpost | int | 123 | Customer id. You may also send cust_id or contactus_id. |
messagepost | string | Called customer and left a note. | Message text. You may also send msg. For from=send_email this fills the {message} placeholder inside the email template (same as dashboard). |
Optional Parameters
| Name | Type | Sample | What it gives |
|---|---|---|---|
frompost | string | send_notes | Channel, same as dashboard: send_notes (default internal note), send_whatsapp, send_email (EMAIL toggle + email_template), send_email_quick (QUICK EMAIL toggle), biz1_chat_message, send_messagebox, send_sms, send_chat_channel, a custom chat_channel_settings channel_type, or auto. Aliases: whatsapp, email/mail→send_email, inboard, notes. |
chart_selected_phone_nopost | string | 972501234567 | Optional phone override for WhatsApp/SMS. Aliases: phone, mobile. |
chart_selected_emailpost | string | [email protected] | Optional email override for send_email / send_email_quick. Aliases: to_email, or email when it contains @. |
template_idpost | int | 42 | For from=send_email: email_template.id (alias email_template_id). If omitted, App picks the same default as the dashboard EMAIL button (source match → user email_template → default_quick_email). Pass 0 for plain body without a template. For from=send_whatsapp: WhatsApp template id. |
email_template_idpost | int | 42 | Alias of template_id when from=send_email. List ids via EmailTemplates.List. |
subject_emailpost | string | Hello from Biz1 | Optional subject override for from=send_email (same as dashboard subject_email). Alias: subject. |
channel_typepost | string | airbnb | Used with from=send_chat_channel for a configured custom channel. |
Authentication
Send the bearer token returned by Login in the request header.
Authorization: Bearer YOUR TOKEN
Sample Request
{
"url": "\/app\/Chat.SendCustomer",
"method": "POST",
"headers": {
"Authorization": "Bearer YOUR TOKEN"
},
"body": {
"customer_id": "123",
"message": "Called customer and left a note.",
"from": "send_notes"
},
"url_user": "https:\/\/{user}.bull36.com\/app\/Chat.SendCustomer",
"url_domain": "https:\/\/{domain}\/app\/Chat.SendCustomer"
}Endpoint
POST /app/Chat.SendCustomer
POST https://{user}.bull36.com/app/Chat.SendCustomer
POST https://{domain}/app/Chat.SendCustomerSample Output
{
"success": 1,
"message": "Note send successfully",
"from": "send_notes",
"customer_id": 123,
"messenger_id": "65f1a2b3c4d5e6f7a8b9c0d1",
"socket_event": "message.created"
}JavaScript Example
const token = 'YOUR TOKEN';
const body = new URLSearchParams();
body.set('customer_id', '123');
body.set('message', 'Hello from WhatsApp');
body.set('from', 'send_whatsapp');
const res = await fetch('/app/Chat.SendCustomer', { method: 'POST', headers: { Authorization: 'Bearer ' + token }, body });
const data = await res.json();
console.log(data);Error Example
{
"success": 0,
"error": "permission_denied",
"message": "Permission denied for channel: send_whatsapp"
}