The dotdigital Engagement Cloud developer hub

Official dotdigital Engagement Cloud APIs documentation

Twitter DM

How to setup Twitter so that you can use it to deliver Direct Messages to your customers

You can use Twitter DM (Direct Messages) to send messages to your customers, or engage with them in two way conversations, this guide will show you how to set this up and get started.

How can I use Twitter DM?

What types of messages can I send?

Twitter DM's are ideal for:

  • Sending customised messages using rich display features such as quick replies, images, location request and more
  • Converse with your customers to provide outstanding customer service
  • Deliver your transactional messages through Twitter and keep customers in the loop
  • Take public Tweet conversations private to resolve customer issues
  • Automate replies with chatbots so you can reach more people with less overhead

Please ensure you have reviewed and comply with Twitters policies which can be found here.

Gaining permission

In order for you to contact your customers via Twitter DM you will need to gain permission from them. This can be achieved in a variety of ways as detailed below, and we can work with any of them:

They Follow You

If a Twitter user is following you, then you can send a DM to them, but as per Twitters policies these messages should not be unsolicited.

They have allow DM's from anyone enabled

If the Twitter user has enabled the option to allow DM’s from anyone enabled, then you will be able to send them a DM.

They have already DM'ed you

You may DM any Twitter user that has already DM'ed you in order to allow you to reply. To encourage a Twitter user to initiate the conversation Twitter provides two ways of doing this easily:

The Twitter "Message" button web control

The Twitter Message Button (shown below) is a web widget that allows a user to start a DM conversation with the Twitter User Id specified in the button upon clicking on it. This is good to embed on websites to encourage customers to communicate with you via Twitter.

The Twitter Message Button for web pages

Find out more about how to use the Twitter Message Button here.

Welcome message deep links

You can get a user to start a conversation with you by clicking on a deep link that can be embedded in HTML, emails, SMS or any other channel that supports URL embedding. The deep link basically triggers the specified Twitter welcome message to be sent to the clicking user. An example of a Twitter deep link is:

https://twitter.com/messages/compose?recipient_id=2244994945&welcome_message_id=12345

These links are ideal for using in Tweets to encourage a user who is publically Tweeting to start a private conversation with you instead. The link will be automatically detected and rendered as a neat invite to take the conversation private, shown below:

Taking a public conversation private using Twitter DM deep links.

More information of this scenario can be found here.

Information on how to create a deep link to a welcome message can be found here.

Setting Up Twitter

Register your corporate Twitter account

If you don't already have one, you should register a corporate Twitter account which will be used to send and receive your Twitter DM's. Go to twitter.com and register your account, and then configure your business profile as described here.

Sign up for the Twitter Account Activity API

Next step is to create a Twitter app, which is required to programmatically send or receive Twitter DM's from your corporate Twitter user. To do this you will need to follow the steps here to sign up for webhooks and the Twitter Account Activity API; Standard access will be sufficient for using with us.

🚧

You need an approved Twitter development account

You will need to have completed the steps above and received confirmation that your application to become a Twitter developer has been approved before continuing with the setup steps below.

Create a Twitter app

Create a Twitter app with your approved Twitter developer account in the Twitter developer portal. If you are creating the app on behalf of your company, it is recommended you create the app with a corporate Twitter account.
Next perform the following:

  • Enable Read, Write and Access direct messages on the Permissions tab of your app page.

Configuring your Twitter apps permissions

  • On the Keys and Access Tokens tab of your app page, take note of your app's Consumer Key (API Key) and Consumer Token (API Secret).
  • On the same tab, generate your app's Access Token and Access Token Secret, take a note of these as you'll need them later.

Noting your keys and tokens

  • Take note of your app's numeric ID, to do this open the App details tab of your app page, and your numeric Twitter app id will be the last number shown in the URL for the page (see below for an example with the numeric id highlighted in green)

Getting your Twitter numeric app id from the URL

Create a Twitter Dev Environment

Login and navigate to the Dev Environments page.

Click Set up dev environment in the Account Activity API / Sandbox section, name your environment, and specify a Twitter app ID for the environment. Note the name of your dev environment as you'll need this later.

Creating your dev environment in Twitter

Configuring your Twitter channel

Now you have finished setting up your Twitter development account and environment, we need to configure your Twitter DM channel prior to using it. To do this please [contact support]([email protected]?subject=Please help me setup my TwitterDM channel) with the details you noted down during the creation of your Twitter app (see above for details) You should include:

  • Consumer Key - The Consumer Key (API Key)
  • Consumer Secret - The Consumer Token (API Secret)
  • Access Token - The Access Token you created
  • Access Token Secret - The Access Token Secret you used during the creation of the Access Token
  • Environment - The Twitter environment name you created in the Create a Twitter Dev Environment section above

👍

You're done

Now that you have setup your Twitter DM channel you are ready to start engaging your audience using the "One" API please check out the docs here

Updated 6 months ago

Twitter DM


How to setup Twitter so that you can use it to deliver Direct Messages to your customers

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.