Introduction

In this article we will learn how to create the TruCHAT integration with Twitter. It allows us to create a Twitter bot with natural language processing based on TruCHAT technology. Let’s do the following: 

Setting Up Twitter

To set up the Twitter integration for your agent, you need a Twitter developer account. Let’s create it together.

Creating a Twitter Developer Account

Log in to your Twitter account and navigate to this page. Choose a reason for creating a Twitter developer account. As an example, let’s check “Exploring the API”. Click “Next”.

nullFigure 1. Choosing a Reason for Creating a Twitter Developer Account

On the next page, enter your country and name, then click “Next”.

null

Figure 2. Entering a Country and a Name

If you haven’t added your phone number to your Twitter account yet, you will see this notification (see Figure 3). Now it’s time to add the phone number to your Twitter account to move on.

null

Figure 3. Notification about Adding a Phone Number

On the next page, you will need to describe how to use the Twitter API or Twitter data. The first field is required while the following four are optional. To simplify the application process, choose the “No” option for each one.

null

Figure 4. Choosing the “No” Options

Now let’s fill in the first field and click “Next”.

null

Figure 5. Answering the Question How Are You Going to Use Twitter Data

Good to know. You can find the examples of answers on the internet or create your own. Before completion, look through Twitter’s Developer Policies to avoid formulations that may be regarded as policy violation. 

Now have one more look at your answers on the next page, click the “Looks Good!” button.

null

Figure 6. The Filled-in Information Checking

On the following page, review the Developer Agreement and check the box to accept it. Click the “Submit Application” button.

nullFigure 7. Submitting Application

Once the application process is almost finished, you need to confirm your email. Check your email and click the confirmation link to complete the application process.

null

Figure 8. Email Confirmation Page

After clicking the confirmation link you will be forwarded to this page (see Figure 9). Now your request for API access is in the process of reviewing. You will most likely get the response within 24 hours.

null

Figure 9. Application Processing Page

Once your application is accepted, it’s time to start setting up TruCHAT.

Setting Up TruCHAT

In TruCHAT, go to the “Connections” section and click the “Add” button.

nullFigure 10. Adding the Twitter Connection

Choose “Twitter” in the list. Click “Next”.

null

Figure 11. Choosing a Connection Type

Enter the name of your connection and choose a time zone from the dropdown list. Click “Next”.

null

Figure 12. Entering the Connection Name and Choosing a Time Zone

Now you are on the page with these six fields: Bot Username, Consumer Key, Consumer Secret, Access Token, Access Token Secret, Dev Environment Label. To fill them in, you need to create a Twitter app.

nullFigure 13. The Six Fields to Fill in

Stay logged in to your Twitter developer account and navigate to this page. Click the “Create App” button. 

nullFigure 14. Creating an App in the Twitter Developer Account

Enter a name for your app and click “Complete”.

null

Figure 15. Entering an App Name

This is what your app page looks like. There are two tabs: “Settings” and “Keys and Tokens”.

nullFigure 16. Your App Page

Click the “Edit” button in the App permissions box. Choose the “Read + Write + Direct Messages” option and click “Save”.

null

Figure 17. Setting up App Permissions

null

Figure 18. Setting up App Permissions

Now let’s start filling in the fields. Enter your app name in the Bot Username field.

null

Figure 19. Filling in the Bot Username Field

To get Consumer Key and Consumer Secret, go to the “Keys and Tokens” tab in your app. Click the “Regenerate” button in the API key & secret box. Then click “Yes, regenerate”.

 

nullFigure 20. Getting the Consumer Key and the Consumer Secret

Here are the API Key and the API Key Secret. Copy them and paste into the Consumer Key and the Consumer Secret fields respectively.

null

Figure 21. Getting the Consumer Key and the Consumer Secret

To get Access Token and Access Token Secret, go back to the “Keys and Tokens” tab and click the “Generate” button in the Access token & secret box.

nullFigure 22. Getting the Access Token and the Access Token Secret

Here are the Access Token and the Access Token Secret. Copy them and paste into the Access Token and the Access Token Secret fields respectively.

null

Figure 23. Getting the Access Token and the Access Token Secret

Now it is needed to fill in the “Dev Environment Label” field. To do this, navigate to the Dev Environments page and click “Set up Dev Environment”. Choose the “Account Activity API / Sandbox” option.

 

nullFigure 24. Setting up the Dev Environment Label

Now choose the Dev Environment Label e.g. prod, dev, staging, or development, etc. Then select your app from the dropdown list and click “Complete Setup”. Paste the chosen label into the Dev Environment Label field.

null

Figure 25. Setting up the Dev Environment Label

Once all the fields are completed, click “Finish Setup”.
 
null

Figure 26. Finishing Setup

Now the connection is created. You can find it in the “Connections” section.

nullFigure 27. Your Twitter Connection
   
Now you can test the bot. Send any message to your Twitter developer account as if you are the client. You will see a notification in the Chats section in the left sidebar (see Figure 28).

null

Figure 28. Notifications in TruCHAT

In the Chats section you can see your message. Start chatting by clicking the “Take Chat” or the “Start Chat” button (see Figure 29).

nullFigure 29. Chatting with the Bot in TruCHAT

Conclusion

Now you know how to integrate TruCHAT with Twitter. The created bot is an efficient marketing tool that will help you lead an up-to-date business.