How to connect Twitter with a human-agent service

Understanding Quickwork Chat. Quickwork provides a no-code, API-based SaaS platform with pre-integrated apps for automation of business workflows and messaging.

In the previous document, we used the multichannel feature and configured journeys allowing an agent to interact with the user on Facebook Messenger. This document is a resemblance that features Twitter as a communication channel integrating with Quickwork Chat. Let's drill through this document and understand the usage of the multichannel feature using Twitter as a messaging channel.

Use-case

Communicate with a user, who messaged you on Twitter, using Quickwork Chat as a messaging platform.

To implement this use-case, we need to build two journeys with the following two adapters. The journeys will execute in synchronization thus facilitating the flow of messages in real-time:

  1. Quickwork Chat account

  2. A dedicated multichannel account to be connected in both journeys.

  3. Twitter account to be connected in both journeys

Creating a multichannel inbox

Log in to your Quickwork Chat dashboard and click the gear icon located on the left to open the Settings section. Click on Inbox Settings from the navigation menu on the left and then click on the Add New Inbox button to start creating a new inbox. Select the Multichannel option to proceed:

Figure 1: The Multichannel option

Enter a name for the inbox, for example, Twitter Multichannel, and click Continue. Add any agents if you want to assign specific agents for this inbox or else assign it to yourself and then click Continue. Your inbox is now ready. Scroll down and click on the Go To Dashboard button to redirect to the conversations dashboard of the respective inbox which will be blank as of now.

Creating the first multichannel journey

Let’s create the first journey that will fetch new messages sent by users from Twitter and will forward those to a Quickwork Chat agent.

Configuring the trigger

  1. Create a new journey named New message from a Twitter user.

  2. Under the Trigger section, choose the Twitter app from the drop-down menu in the Apps field present right below the New Trigger button.

  3. Select the trigger event as New text message from the drop-down menu in the Triggers field.

  4. To authorize and connect your Twitter account, click on the Link an account button. Simply allow the permissions in the Twitter account you have logged in

  5. Once the authorization has been completed, the new window that had opened for Messenger’s authorization will automatically close and you will get a notification message in the journey stating Your connection has been successfully established. Your trigger should then look like this:

Figure 2: Configuring Twitter-New message trigger

Using If Condtion with a Stop Journey

The reason to configure the If condition with a Stop Journey is to terminate the automation if the sender and recipient are the same. This journey will execute only if the message sender and message recipeint are two different entities. For simplification, let's understand Daniel as a message sender on Twitter and John as a message receiver. John is also a human agent, will eventually reply to Daniel's messages using Quickwork Chat.

Configuring the If Condition

  1. Under the Steps section, click the Business Logic option and select If Condition:

Figure 2: If condition

2. The Setup If condition block will appear with a pre-indented action bar as illustrated here:

Figure 3: If condition structure

You will get the following fields to which input is to be specified:

  1. Specify a value in the Left Value field by placing the Recipient Id key from the Twitter | New message Trigger-Data Tree Output on the right-hand side of the screen.

  2. Select the Equals condition from the drop-down in the Condition field.

  3. Drag and dropSender ID key in the Right Value field from the Twitter | New message Trigger-Data Tree Output:

Figure 4: Configuring the If condition

Now, delete the action that is pre-indented beneath the If Condition as we need to add Stop Journey.

Indenting the Stop Journey

Click the + icon. Click the Business Logic button and select Stop Journey. Drag the Stop Journey bar and drop it below If Condition in such a way that it gets indented and appears as a part of If Condition:

Figure 5: Indenting Stop Journey

If the Stop Journey is not indented properly, the journey execution will keep on terminating even if the condition is not satistied. Click here to know more about If Condition.

Configuring the action

To do this, perform the following steps:

  1. Again, click the + icon and click on the Simple Action button.

  2. Choose the Quickwork Chat app from the drop-down menu present in the Apps field.

  3. Select the Forward message to agent action in the Actions field.

  4. Create a new connection with the Twitter Multichannel inbox that you had just created. To do so, click the + Create new connection option if you have existing Quickwork Chat connections, and then click on the Link an account button and specify the API key and Inbox ID of this inbox. You’ll get these in the Toolkits window of the Twitter Multichannel inbox present in the Inbox Settings option on the Settings page. After entering the required data, click the Link account button:

Figure 6: Quickwork Chat connecting window

Note: The API key is common for all the inboxes of an account whereas the Inbox ID is unique for each inbox.

5. Once the connection has been successfully created, the input fields will open up automatically. Drag the Sender ID and Text Message data pills from the Data Tree Output and drop them into the Multichannel Identifier and Message fields, respectively. Select Twitter as the Multichannel type from the drop-down given. Your action should now look like this:

Figure 7: Quickwork Chat action configuration

The complete journey structure will look like this:

Figure 8: New message for a Twitter user journey

Click the Save changes button and start the execution by clicking the Start Journey button.

Creating the second multichannel journey

Let’s configure the second journey which will allow an agent to reply to the user on Twitter via the Quickwork Chat portal.

Configuring the trigger

Follow the steps as given below:

  1. Create a new journey named Reply from QC agent to the Twitter user.

  2. Under the Trigger section, choose the Quickwork Chat app from the drop-down menu in the Apps field present right below the New Trigger button.

  3. Select the trigger event, New agent message, from the drop-down menu present in the Triggers field.

  4. From the drop-down menu of selecting existing connections use the same connection that you had created in the previous journey with the inbox named Twitter Multichannel.

  5. In the event field, enter the text demo. The journey builder will return a webhook URL as shown below:

Figure 9: Webhook URL

6. Now copy this URL and go to Inbox Settings of the Twitter Multichannel inbox in your Quickwork Chat account. Then go to the Webhook tab and paste this URL in the Agent Response Webhook field:

Figure 10: Twitter Multichannel inbox

7. Click the Save Changes button. 8. Your successfully configured trigger shall now look like this:

Figure 11: Quickwork Chat trigger

Configuring the action

To do this, follow the given steps:

  1. Under the Steps section, click on the Simple Action button and choose the Twitter app from the drop-down menu in the Apps list.

  2. Select the Send message action from the drop-down menu present in the Actions field.

  3. Select the same existing connection which was created in the previous journey for the Twitter account in the drop-down menu with the title Existing connections of Twitter and then click on the Link Account button.

  4. Once the connection has been successfully created, all the input fields will get loaded.

  5. Now drag the MultiChannel Identifier data pill from the Data Tree Output and drop it in the recipient ID field.

  6. Similarly, drag the Content data pill from the Data Tree Output and drop it into the Text field.

  7. Your action should now look like this:

Figure 12: Twitter action

9. Now click the Save changes button and then the Start Journey button to push it in execution. Both the configured journeys shall now look like this:

Figure 13: Configured journeys

Executing the multichannel functionality

Now, consider Daniel has sent the message. Hello. I need some assistance for Quickwork Chat on Twitter to John:

Figure 14: Message from a user on twitter

As John is a human-agent with an active Quickwork Chat portal, he will receive the same message on the Twitter Multichannel inbox conversation window under Mine, Resolved, Latest First filter:

Figure 15: Message seen on conversation window

Until here, the first journey New message from a Twitter user got executed successfully. You might face some delay for the message reflected in Quickwork Chat as Twitter trigger APIs have default delay policy and is polling in nature.

The human agent, John, now can reply to the user through this portal:

Figure 16: Reply from the human-agent

The same reply message can be seen as sent from the Twitter account of John:

Figure 17: Message sent automatically from John's Twitter account

Until here, the second journey, Reply from QC agent to the Twitter user, got executed by forwarding the reply message sent by human agent on Quickwork Chat to the user on Twitter.

Hence, this is how a human-agent can connect with a user on Twitter with the help of Quickwork Chat and Quickwork Journey Builder.