How to: Send HTML emails with the Intercom Conversations API š®
A short tutorial
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:
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:
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.