How to: Send HTML emails with the Intercom Conversations API šŸ“®

A short tutorial

Cathal Horan
3 min readOct 20, 2017

A common use case for our Conversations API is to send emails ā€” often with HTML formatting ā€” via the API. In this quick tutorial weā€™ll show you how to send a message using the Conversations API, and which HTML formats can be used.

Weā€™re using the Node SDK for our examples, but you can use any of our SDKs in the same way šŸ‘Œ

First: Messages vs. Conversations endpoints

You might notice that there are two endpoints that you can use to talk to customers: https://api.intercom.io/messages and https://api.intercom.io/conversations

Letā€™s quickly cover the differences:

  • If youā€™re initiating contact with a new message ā€” for example, sending out an announcement email ā€” then youā€™ll use the ā€˜messagesā€™ endpoint.
  • Once the initial message is sent and you want to send a reply or take an action on the conversation (like closing it), youā€™ll use the ā€˜conversationsā€™ endpoint.

Each part or reply within a conversation is a message, so essentially messages make up conversations.

So, now that weā€™ve got that covered, letā€™s get on with sending an email message to a lead.

Sending a message

Weā€™re starting a new conversation, so we need to use the ā€˜messagesā€™ endpoint. In most cases, you will send messages to customers as an admin.

Hereā€™s the Node code for sending an HTML email message to a lead via the API:

Sending an email to a lead, from an admin

Alternatively, we could have chosen to send this as an in-app message. Which you choose will depend on your own use case, but just be aware of some differences in the POST body for each type ā€” for example, you donā€™t need a ā€˜subjectā€™ attribute when sending an in-app message.

What HTML can be used?

Weā€™ve included some basic HTML formats in the example above. Whilst we donā€™t support the HTML Style attribute, you can include some basic HTML as weā€™ve shown.

Those include:

  • Headers and paragraphs
  • Ordered and unordered Lists
  • Bold/italics/highlighted/underscored
  • Tables
  • Images

Hereā€™s what the message example above looks like:

An example of supported HTML

Next time: Retrieving conversations

This should give you a good idea of how to send HTML emails.

Next, you may want to retrieve the messages youā€™ve sent, for example to see who you sent them to or whoā€™s responded. Weā€™ll cover how to do that in our next post, coming soon!

If thereā€™s anything else youā€™d like to see or you have any question,s let us know in the comments or tweet us at @intercomdevs šŸ‘

And in the meantime, you can check out our docs to discover many more features of the Conversations API.

--

--

Cathal Horan

Developer Support Engineer at Intercom. Marathon running, existentialist techie. Twitter @cathalhoran