Reply in a conversation

This method allows you to reply in a conversation and add internal notes.

URL

POST https://api.dashly.app/conversations/{id}/reply

The ID of the conversation should be used as {id}.

Parameters

Authentification parameters. id_as_string parameter. Parameters, enabling ConversationPart optional fields.

Parameter Type Description
body Optional[string] Message text. Can be empty in case message contains only an attachment (for example, an image). Empty string by default
body_json Optional[Dict] json with optional message data, depending on created message type
attachment Optional[File] File attached to the message
attachment_file_name Optional[string] Name of attached file. String from 1 to 255 symbols.
from_user Optional[ID] Set default_user or specific user ID in case you're sending as a visitor
from_admin Optional[ID/default_admin] ID of admin who replies into the conversation or default_admin to reply as default admin
type Optional[string] Message type. Available types: reply_admin, note, article. Parameter is ignored when from_user is set. Default: reply_admin
external_id Optional[string] External message Id
random_id Optional[integer] random integer to validate created message with RTS message. Default: 0
auto_assign Optional[ID] Admin ID. Automatically assign set admin to this conversation
auto_assign_random_id Optional[integer] Random ConversationPart assignment ID for sending control. Default: 0
referrer Optional[string] Page URL, from which the message was received. Default: undefined
actions Optional[Array[Dict]] Actions the user can perform with this replica. See description below.

Note

Use from_admin and from_user to control the admin/user who replies into the conversation. Use type to specify message type (reply_admin - regular reply, note - only visible in admin panel, article - knowledge base article)

Specify admin ID in auto_assign to automatically assign this admin to the conversation. This will create 2 messages instead of one: assignment system message and the message itself.

random_id and auto_assign_random_id are used to validate the message, received through Realtime services. random_id is used to validate created message with Realtime services. You can use 32-bit integer, which will be returned as one of ConversationPart fields, created by tour request. You can't use conversation part ID because Realtime services is asynchronous and may receive the new message before(or after. It happens randomly as order is not set) you get response to message part creation.

Actions

The actions field allows you to add actions that can be performed on this replica. It is used when the replica has some kind of interaction:

  1. Buttons
  2. Input field
  3. Link follow

Currently, the API only allows you to send one type of action: quick_reply.

Quick reply

This action allows you to show a button with the text specified in the body field of the button along with the reply. When the user clicks on the button, a reply with the corresponding content is sent to the chat.

Parameters

Parameter Type Description
type string Action type. quick_reply
body string, up to 300 characters Button text. Note that too long text may not look good on a button.
meta_data Optional[Dict] Additional data added to the meta_data field.

The optional meta_data field allows you to add data from the meta_data field to the created user replica when the button is clicked, which can be received when receiving the replica via Web API, Realtime Services API and Webhook. This allows you to identify which button was clicked and take the appropriate automatic action using the API.

Example

[
  {"type":  "quick_reply", "body": "Accept", "meta_data":  {"external_id": 1}},
  {"type":  "quick_reply", "body": "Decline", "meta_data":  {"external_id": 2}}
]

Response

data contains created ConversationPart objects:

  • the main message will be returned as main data content
  • assignment message will be returned in data.assign_part (in case auto_assign is set)

Example:

{
  "data": {
    "id": "1453279698921457472",
    "created": 1685352440,
    "conversation": "1447294760057308402",
    "body": "What's your choice, Neo?",
    "body_json": {},
    "direction": "u2a",
    "type": "reply_user",
    "sent_via": "api",
    "attachments": [
      {
        "type": "file",
        "id": "1453279691052943108",
        "filename": "test_import.csv",
        "mime_type": "text/csv",
        "size": 156,
        "url": "https://files.dashly.app/attachments/2782/2e7cac55-dff0-4142-9460-14d64ff08623/test_import.csv",
        "created": 1685352439
      }
    ],
     "meta_data": {
      "some_extra_reply_information": 123
    },
    "reply_type": "no",
    "actions": [{"type": "quick_reply", "body": "Red", "meta_data": {"id":  1}}, {"type": "quick_reply", "body": "Blue", "meta_data": {"id":  2}}],
    "edited": null,
    "removed": null,
    "external_id": null,
    "part_group": "1447294760216691955",
    "from": "1447294708215711734",
    "assign_part": {
      "id": "1453281238935668443",
      "created": 1685352624,
      "conversation": "1447294760057308402",
      "body": "",
      "body_json": {},
      "direction": "a2u",
      "type": "assigned",
      "sent_via": "api",
      "meta_data": {},
      "reply_type": "no",
      "actions": null,
      "edited": null,
      "removed": null,
      "external_id": null,
      "part_group": "1447294760216691955",
      "assignee": {
        "id": "30542",
        "name": "Test",
        "avatar": "https://files.dashly.app/avatars/default-v4.png",
        "type": "admin"
      },
      "from": {
        "id": "30542",
        "name": "Test",
        "avatar": "https://files.dashly.app/avatars/default-v4.png",
        "type": "admin"
      }
    }
  },
  "meta": {
    "status": 200
  }
}

Exceptions

Standart Web API exceptions

This method specific exceptions

Exception Code Description
ReplyTooBig 400 Message text too long (body)

Example

Reply from admin and assign this admin to conversation (admin ID - 8164):

curl -X POST \
  --data-urlencode "body=Some Admin Message" \
  --data-urlencode "from_admin=8164" \
  --data-urlencode "auto_assign=8164" \
  -H "Authorization: Token XXX" \
  https://api.dashly.app/conversations/1789152/reply

Reply as visitor to the site:

curl -X POST \
  --data-urlencode "body=Some User Message" \
  --data-urlencode "from_user=default_user" \
  -H "Authorization: Token XXX" \
  https://api.dashly.app/conversations/1789152/reply

Add a note as admin (admin ID - 8164):

curl -X POST \
  --data-urlencode "body=Some Admin Message" \
  --data-urlencode "from_admin=8164" \
  --data-urlencode "type=note" \
  -H "Authorization: Token XXX" \
  https://api.dashly.app/conversations/1789152/reply