# How to connect Twitter with a human-agent service

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. &#x20;

## **Use case**

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.&#x20;
3. Twitter account to be connected in the journeys

## **Creating a multichannel inbox**

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](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkaKTEyRNZrv9mQkuKW%2F-MkaKyNVjI2IyZd_eg9U%2Fimage.png?alt=media\&token=b7654773-f6a3-4343-a511-ccd3515f48e6)

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 the user from Twitter and will forward those to an agent of Conversation Management.

### **Configuring the trigger**

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](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkaL2W9NZFlCXt6UDRY%2F-MkaLqvJKP_yRrgFleS3%2Fimage.png?alt=media\&token=3f5ac1f0-6612-4a5d-978e-c72bc52b6128)

### &#x20;**Using If Condition 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 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.

#### Configuring the If Condition

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

![Figure 2: If Condition](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkaL2W9NZFlCXt6UDRY%2F-MkaMIU2t4Qp-W-0XN-Y%2Fimage.png?alt=media\&token=5430a540-a166-4cf8-b58e-89ada3d32b1d)

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 Id` key from the **Twitter | New message Trigger** on the right-hand side of the screen.
2. Select the `Equals` condition from the drop-down in the **Condition** field.
3. Drag and drop`Sender ID` key in the **Right Value** field from the **Twitter | New message Trigger**:

![Figure 3: Configuring the If Condition](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkaL2W9NZFlCXt6UDRY%2F-MkaO6rOM60DAdjV3zRX%2Fimage.png?alt=media\&token=246fa2ee-d884-4332-b1f3-7fe5a3f8deef)

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 4: Indenting the Stop Journey](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkaL2W9NZFlCXt6UDRY%2F-MkaOQsDvIzT_F6juFtw%2Fimage.png?alt=media\&token=234c606f-d8e1-4426-987b-41018617b25d)

{% hint style="info" %}
If the Stop Journey is not indented properly, the journey execution will keep on terminating even if the condition is not satisfied. Click [here](https://docs.quickwork.co/if-condition) to know more about If Condition.
{% endhint %}

### **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 **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](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkaL2W9NZFlCXt6UDRY%2F-MkaQ6xpYjZsc-xv9HhL%2Fimage.png?alt=media\&token=333fe1b0-203a-4a2e-8cab-34cd160cced0)

**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 6: Forward message to agent action](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkaL2W9NZFlCXt6UDRY%2F-MkaS3UkwVvAfot2nLnj%2Fimage.png?alt=media\&token=2cac52cc-ea99-46a4-a282-e7306f65ef02)

The complete journey structure will look like this:

![Figure 7: The complete journey](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkaL2W9NZFlCXt6UDRY%2F-MkaSn1_6fK8CMk96ie3%2Fimage.png?alt=media\&token=a36e8f02-bdd5-4a23-b686-39ba7d421905)

Click the **Save changes** button and start the execution by clicking the **Save & Start** 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 Conversation Management 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 **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](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkejIv-TtnDhN9mCBS8%2F-MkejtO85VTDYvWkvlvd%2Fimage.png?alt=media\&token=5bf06b5f-c1bc-4e60-a6eb-af1682d28f5f)

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](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fquickwork-chat%2F-MVtT0rWmbDt3L5LSlfi%2F-MVu86sDRFeg1_ESscYr%2F7.png?generation=1615883174263715\&alt=media)

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

![Figure 10: New agent message](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkejIv-TtnDhN9mCBS8%2F-MkelCf47p3BuAHwwGT0%2Fimage.png?alt=media\&token=5a3208c1-f7db-4a89-a7af-037bf31eeb26)

### **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 11: Twitter action](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkejIv-TtnDhN9mCBS8%2F-Mken73O2EoyGVie9Aw9%2Fimage.png?alt=media\&token=ac7cab17-7fbf-450f-96d4-4bfe8d05f86f)

9\. Now click the **Save changes** button and then the **Start Journey** button to push it in execution.

## Executing the multichannel functionality

Now, consider Daniel has sent the message. ***Hello. I need some assistance for Conversation Management*** on Twitter to John:&#x20;

![Figure 12: Message from a user on Twitter](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkejIv-TtnDhN9mCBS8%2F-Mkeoy7eZcL3gle3ObTJ%2Fimage.png?alt=media\&token=6f868f2e-3800-4c11-b162-aef0bfdffdbf)

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](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-Mker8hlnVAsmttP7PJD%2F-MkesVuCpbHgKrjWZstz%2Fimage.png?alt=media\&token=87fa6eea-d522-415e-a03b-433e40dadf4b)

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](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-Mker8hlnVAsmttP7PJD%2F-MketYxTLr9lWt9tbike%2Fimage.png?alt=media\&token=cd32f090-6b23-462c-ae28-c5e1e61f56bf)

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

![Figure 15: Reply from an agent](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkejIv-TtnDhN9mCBS8%2F-MkeqxrWhqWY1RXGTcPM%2Fimage.png?alt=media\&token=b9ad1ae6-a340-42b2-9138-a9c3be46a9f7)

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.&#x20;

Hence, this is how a human agent can connect with a user on Twitter with the help of Conversation Management and Quickwork.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.chat.quickwork.co/how-to-connect-twitter-with-a-human-agent-service.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
