Twitter DM

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

1030

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.

104

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:

633

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.
1264

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.
1264

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)
1264

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.

1277

Creating your dev environment in Twitter

Configuring your Twitter channel

Now you have finished setting up your Twitter development account and environment, you need to configure your Twitter DM channel in the portal prior to using it. To do this follow the simple instructions below:

  1. Open your API Space in the portal and open the Channels menu on the left (highlighted in green below), and select the Setup button from the Twitter section (highlighted in yellow)
1920
  1. In the Twitter configuration channel pop-up enter the details you noted down during the creation of your Twiiter app (see above for details) You should enter:
  • 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
604
  1. Click the Save button

🚧

Possible error message

If when you save you see an error with "Client application is not permitted to access this user's webhook subscriptions", then please ensure you have set Read, Write and Access direct messages on the Permissions tab of your app page, and then regenerate you Access Token.

If you see "Twitter Config wasn't set due to: Unexpected error from twitter (code: 200, message: Forbidden.)", then you still are waiting for Twitter to grant access to your Twitter development account to the Twitter Activity API; please contact Twitter to request this.

👍

You're done

Now that you have setup your Twitter DM channel in the portal you are ready to start engaging your audience using our Chat tool and send invitations to chat using Twitter deep links. See below for details of how to configure the Chat tool to use Twitter DM.

To find out more about sending to Twitter DM using the "One" API please check out the docs here

Configuring Chat to use Twitter DM

Once you have setup your Twitter DM channel as described above you can enable a chat team to receive your inbound Twitter DM conversations. To this follow these simple steps:

  1. Open the Contact -> Chat -> Configure section from the left hand menu (highlighted in green below) and click the Setup button in the Twitter section.
1907
  1. Now in the pop-up click on the activation slider to enable Twitter DM for this team. Note that only one team can be associated with the Twitter DM channel, but this team can transfer conversation to other teams as necessary.

👍

All done

Try starting a Twitter DM conversation with your corporate Twitter account and ensure it arrives in Chat to test the configuration.