# How to create a chatbot using Quickwork

Creating a chatbot using Conversation Management and Quickwork is quite simpler. Quickwork sends automated messages to a user, upon proper configuration, acting as a full-fledged chatbot eliminating the need for a human agent. Let's create a simple journey in Quickwork and understand the procedure to create a chatbot.

## What is Quickwork

Before moving towards bot creation, let us know what is Quickwork. Quickwork is an integration and automation platform chosen by enterprises to build workflows, publish APIs, and manage conversations. Integrated apps using Quickwork, send and receive data seamlessly using triggers and actions to achieve the next level of automation.

Visit <https://automation.quickwork.co/> to use the product and refer to <https://docs.quickwork.co/> to understand its working.&#x20;

## Use case

*"Reply to a user on the **Conversation Management widget automatically whenever a new message is received from the user."*** According to this use case, **New text message** is the trigger, and **Send text message** is the action to be used from the **Conversation Management by Quickwork** adaptor supported by the journey builder.

## Choosing an inbox&#x20;

Log in to your Conversation Management account as an admin and select an inbox that has a human-agent service configured. For simplicity, let's select the **Medicare human-agent service** that we edited in the previous document:

![Figure 1: Medicare human-agent service](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkQoAAvRaeu5V3ZpMVv%2F-MkQzczm99vLTnlpEAfj%2Fimage.png?alt=media\&token=007b24ca-bc04-47ff-8b8f-ebd3cdf4fda2)

{% hint style="info" %}
If you don't have any Inboxes in your account, create one. Refer to the [*How to create a human-agent service for a website*](https://docs.chat.quickwork.co/how-to-create-a-human-agent-service-for-a-website-using-quickwork-chat) guide to create an Inbox and deploy it on a web browser.
{% endhint %}

Now move to the **Toolkits** tab and make a note of the **API Keys** and **Inbox ID** of this inbox. Next, move to the **Webhook** tab. It contains the **Webhook** field. This input field is crucial and used only in terms of integration while creating a chatbot. If you wish to send and receive the messages through your messaging service or an integration platform such as Quickwork, specify the webhook URL as an HTTP webhook endpoint in this input field:

![Figure 2: The Webhook tab](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MMTxU8DZLATQ9y1skxM%2F-MMU3SRYlDpKLdnupCOJ%2Fimage.png?alt=media\&token=32e59c9c-4334-4af8-88d6-b17b585ed54a)

To get the webhook, switch to Quickwork where we'll be creating a basic journey that will trigger a message automatically.&#x20;

## Using Quickwork to create a chatbot

Log in to [Quickwork](https://automation.quickwork.co) and create a new journey, say **Conversation Management chatbot configuration**. Let's start configuring a trigger first:

1. In the **Event** section, search for **Conversation Management by Quickwork** app as a new trigger under the **Apps** list.
2. Select the trigger event, **New text message**, from the **Triggers** drop-down menu field.
3. Create a new connection by following these steps:
   1. &#x20;Click the **Link Account** button.&#x20;
   2. The **Connect to Conversation Management by Quickwork** window will pop up. Paste the **API Key** and **Inbox ID** of the **Medicare human-agent service**.&#x20;
   3. Click the **Link Account** button. Your connection is now established. Click [here](https://helpdesk.quickwork.co/hc/en-us/articles/360051481693-Quickwork-Chat-Connecting-your-account) to know more:

![Figure 3: Connection an inbox of Conversation Management ](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkR1XYMM7xG3qTGhQIA%2F-MkR1tbiqe8tOk-SJRHl%2Fimage.png?alt=media\&token=71ac6509-948b-4f07-9263-674630493e11)

&#x20;    4\. In the **Event** field, enter **new message** as an event.&#x20;

As soon as you complete specifying all the input, Journey Builder will return a Webhook URL as shown in the following figure:

![Figure 4: Webhook URL generated](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkR25t0Ahyx96lchDLG%2F-MkR2HbtDsaXO0GLU4Pa%2Fimage.png?alt=media\&token=e18dfdb1-b3f1-4b75-8e03-c5a7c9140d39)

Now, copy this URL, return to the Medicare human-agent service inbox, and paste this webhook URL in the **Webhook** field. Also, checkmark the **Events** checkbox. Then, click the **Save Changes** button:

![Figure 5: Pasting the webhook URL](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkR25t0Ahyx96lchDLG%2F-MkR37O0mHaMR020Runi%2Fimage.png?alt=media\&token=e21d5e0e-e081-4ae8-a2cd-1e6eb3fdcf2a)

Your Medicare human-agent service inbox has been integrated with Quickwork and the **Conversation Management by Quickwork-New text message** trigger has been configured successfully. It will look like this: &#x20;

![Figure 6: New text message trigger](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkR25t0Ahyx96lchDLG%2F-MkR4X-eZgQcgs8fOK2L%2Fimage.png?alt=media\&token=0160b1ec-544c-4cd4-a10c-103bf6f2d220)

## Configuring Conversation Management by Quickwork-Send text message action

To do this, follow these steps:

1. Click the **Simple Action** button and choose the **Conversation Management by Quickwork** app from the **App** drop-down menu field.
2. Select the **Send text message** action in the **Actions** list.
3. The journey builder will automatically connect the same Conversation Management Inbox as we have already done in the trigger section. &#x20;
4. In the **Message** field, enter the message that the journey builder should send to a user acting as a chatbot. E.g., *Hi there! We're so glad you stopped by. Chances are you are looking for something in particular. Whether it's tech support, product info, or useful resources, we've got you covered. What can we help you with today?*
5. In the **Conversation ID** field, drag and drop the `Conversation Id|Trigger` data pill from the **App Data-New text message trigger output**:&#x20;

![Figure 7: Send text message action](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MkR4pVrSSVSMElv3WVL%2F-MkRBSrjCqr3Qu36zih1%2Fimage.png?alt=media\&token=58a38a83-bee0-4089-bcc3-5f72a0edfcff)

&#x20;       7\. In the **Private** field, select **No** as an input from the drop-down menu. This\
&#x20;           will ensure that the sent messages are visible to the customer in the chat window.\
&#x20;           Selecting **Yes** as an input will consider the sent messages as a private\
&#x20;           conversation among the agents and would eventually not be visible to\
&#x20;           the customers.

## Executing the journey

Save the Journey by clicking the **Save changes** button and start the execution by hitting the **Start Journey** button. You'll be redirected to the **History** tab automatically. Currently, it would have no entries to display.

## Testing the chatbot

Now, open the HTML file or the website in a web browser containing the Medicare human-agent service inbox. Send a message, ***Hello*** to the chat window. As soon as you send the message, the journey builder will send a response, which we had specified during action configuration, immediately to you on the chat window:

![Figure 8: Automated responses from Quickwork](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-MMU7XkizivZT9DbGANg%2F-MMU8A6GzawbKsj6hYjR%2Fimage.png?alt=media\&token=e9815f91-cc84-42f0-b010-5d9c9179ae38)

This way of chatbot configuration not only makes you understand the working of the journey builder but also lets you create numerous journeys and chatbots without any coding. Any human-agent service inbox can be converted to a chatbot using this method. You can also build smarter chatbots that send custom questions, quick replies, carousels, postback messages using Conversation Management by Quickwork actions that the journey builder supports.

## Passing custom payload&#x20;

As mentioned earlier, pasting the Inbox script in the HTML code embeds the chat widget on the web portal through which communication could be initiated easily. However, this analogy leads to a conversation in the support panel with a haphazardly assigned random user name and email address for a genuine visitor. Thus, it becomes difficult to recognize the actual potential customers through their genuine identification. Custom payloads help you to deal with such dilemmas.

To use these, go to the Inboxes window where the script for your inbox is generated. Scroll down and copy the messenger script that has custom payloads with keywords such as `name`, `email`, `created_at`, and `custom_payload` under the `settings` object:

* `name`: The genuine name of the user you want to get reflected in the support panel. E.g., John Doe.
* `email`: The genuine email address of the user. E.g., <johndoe@gmail.com>.
* `created_at`: The accurate timestamp of the conversation being created. E.g., Mon March 23 2020 17:01:15 GMT+0530.
* `custom_payload`: An object of payloads that you want to pass. It could be information related to sign up, log in details, or could contain a set of login credentials of a user.

Open the HTML file and paste the whole `settings` object below the `baseURL: BASE_URL` tag. Then replace the dummy input values of the above-mentioned fields with the real ones as shown in the following figure:

![Figure 8: Using a custom payload script](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-M3ArV6iq4DDX09TP-GP%2F-M3Av3AoeInfepwZhlLB%2Fhtmlfile_censored%20\(1\).jpg?alt=media\&token=389d5ac9-06c0-4963-9700-76a14c1a2164)

Now run the file in the web browser. You'll see that a conversation is created in the support panel reflecting the real name of the user that you have specified and not with a lame name such as *bold-grass*.&#x20;

Upon successful execution, you can see that the Conversation Management by Quickwork trigger passes the custom payload to the further actions configured in a journey:&#x20;

![Figure 9: Custom payload output](https://1811093075-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M34pLt4SmVLxK2J-oXh%2F-Mk_d84gq-GfwPQKFR9K%2F-Mk_f_f1jFle-4CK2nDF%2Fimage.png?alt=media\&token=2e3f15c7-8899-481a-a4a6-37b3674dae47)

This is an add-on feature that Conversation Management has adopted to smoothen your conversations. &#x20;
