How to connect Twitter with a human-agent service
Solve queries of Twitter users by building a journey in Quickwork. Integrate Twitter and Conversation Management with business logic to achieve this multichannel capability.
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 Conversation Management. Let's drill through this document and understand the usage of the multichannel feature using Twitter as a messaging channel.
Communicate with a user, who messaged you on Twitter, using Conversation Management by Quickwork 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.Conversation Management account
- 2.A dedicated multichannel account to be connected in the journeys.
- 3.Twitter account to be connected in the journeys
Log in to your Conversation Management 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.
Let’s create the first journey that will fetch new messages sent by the user from Twitter and will forward those to an agent of Conversation Management.
- 1.Create a new journey named New message from a Twitter user.
- 2.Under the Event 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 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 1: Configuring the Twitter-New message trigger
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 the message recipient 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 Conversation Management.
- 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. 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 Idkey from the Twitter | New message Trigger on the right-hand side of the screen.
- 2.Select the
Equalscondition from the drop-down in the Condition field.
- 3.Drag and drop
Sender IDkey in the Right Value field from the Twitter | New message Trigger:
Figure 3: Configuring the If Condition
Now, delete the action that is pre-indented beneath the If Condition as we need to add 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 4: Indenting the Stop Journey
To do this, perform the following steps:
- 1.Again, click the + icon and click on the Simple Action button.
- 2.Choose the Conversation Management by Quickwork 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 Conversation Management by Quickwork 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 5: Conversation Management by Quickwork connection 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
Text Messagedata 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 6: Forward message to agent action
The complete journey structure will look like this:
Figure 7: The complete journey
Click the Save changes button and start the execution by clicking the Save & Start button.
Let’s configure the second journey which will allow an agent to reply to the user on Twitter via the Conversation Management portal.
Follow the steps as given below:
- 1.Create a new journey named Reply from QC agent to the Twitter user.
- 2.Under the Event section, choose the Conversation Management by Quickwork app from the drop-down menu in the Apps list 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 8: The webhook URL
6. Now copy this URL and go to Inbox Settings of the Twitter Multichannel inbox in your Conversation Management account. Then go to the Webhook tab and paste this URL in the Agent Response Webhook field:
Figure 9: Twitter Multichannel inbox
7. Click the Save Changes button. 8. Your successfully configured trigger shall now look like this:
Figure 10: New agent message
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 Identifierdata pill from the Data Tree Output and drop it in the recipient ID field.
- 6.Similarly, drag the
Contentdata pill from the Data Tree Output and drop it into the Text field.
- 7.Your action should now look like this:
Figure 11: Twitter action
9. Now click the Save changes button and then the Start Journey button to push it in execution.
Now, consider Daniel has sent the message. Hello. I need some assistance for Conversation Management on Twitter to John:
Figure 12: Message from a user on Twitter
As John is a human agent with an active Conversation Management portal, he will receive the same message on the Twitter Multichannel inbox conversation window under Mine, Resolved, Latest First filter:
Figure 12: Message received in the 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 Conversation Management by Quickwork as Twitter trigger APIs have a default delay policy and is polling in nature.
The human agent, John, now can reply to the user through this portal:
Figure 14: Reply from the human agent
The same reply message can be seen as sent from the Twitter account of John:
Figure 15: Reply from an agent
Until here, the second journey, Reply from QC agent to the Twitter user, got executed by forwarding the reply message sent by a human agent on Conversation Management to the user on Twitter.
Hence, this is how a human agent can connect with a user on Twitter with the help of Conversation Management and Quickwork.