Admin Initiated Conversation
Email From Admin
$ curl https://api.intercom.io/messages \\\n-XPOST \\\n-H 'Authorization:Bearer <Your access token>' \\\n-H 'Accept: application/json' \\\n-H 'Content-Type: application/json' -d'\n{\n \"message_type\": \"email\",\n \"subject\": \"Hey\",\n \"body\": \"Ponies, cute small horses or something more sinister?\",\n \"template\": \"plain\",\n \"from\": {\n \"type\": \"admin\",\n \"id\": \"394051\"\n },\n \"to\": {\n \"type\": \"user\",\n \"id\": \"536e564f316c83104c000020\"\n }\n}'
HTTP/1.1 200 OK\n\n{\n \"type\": \"admin_message\",\n \"id\": \"2001\",\n \"created_at\": 1401916877,\n \"message_type\": \"email\",\n \"subject\" : \"Hey\",\n \"body\" : \"Ponies, cute small horses or something more sinister?\",\n \"template\": \"plain\",\n \"owner\": {\n \"email\": \"email@example.com\",\n \"id\": \"394051\",\n \"name\": \"Wash\",\n \"type\": \"admin\"\n }\n}
You can create a new admin initiated message by submitting a POST
to https://api.intercom.io/messages
along with JSON message.
An admin initiated message can be delivered to a user as an In-App conversation or as an Email. The message_type
field is used to determine which, with a value of either inapp
or email
. For admin initiated In-App messages, they will not trigger push notifications.
Receiving Users are identified by a user_id
, id
, or email
field in the to
object.
Receiving Contacts are identified by a user_id
or id
field in the to
object.
The type
field for the to
object is then set to either contact
or user
.
The subject
field is only used for email
type messages and will not be used for inapp
message types.
A sending admin must be added using the from
field, along with a type
field value of admin
and the corresponding Intercom id
for that admin. The admin's Intercom id
value may be obtained from the List Admins resource.
Note that since creating an admin-initiated conversation hits the /messages
endpoint, the response contains a message object rather than a conversation object. As a result you will not see the conversation ID in the returned message object. You may, however, retrieve the customers's conversations and iterate over them looking for the message_id value.
Attributes
Attribute | Type | Description |
---|---|---|
message_type | string | The kind of message being created. Values: inapp or email |
subject | string | Optional unless message_type is email. The title of the email. |
body | string | The content of the message. HTML or plaintext. Details of HTML support |
template | string | The style of the outgoing message. Only valid for email messages. Possible values plain or personal . |
from | object | Required. An admin object containing the admin's id . The type field must have a value of admin . |
to | object | Required. A user object containing the user's id , email or user_id . The type field must have a value of user or of contact . |
Returns
The created message object.
If the from
type was supplied with an admin's details, the owner
field in the response will represent the admin in question.
As the id
returned is the message_id
, you'd need to make an additional call to the API afterwards to find the latest open conversation for the user you sent the message to.
Getting the full conversation object
last_convo = @intercom.conversations.find_all(:type => 'user', :intercom_user_id => \"ID OF THE USER\", :open => true).first\n last_convo.id