# Test your WhatsApp - HubSpot integration

{{<tags >}}

In this guide, we'll demonstrate how to test the integration between WhatsApp and HubSpot using Truora's platform. You'll learn how to configure WhatsApp flows that connect users to HubSpot, and how to set up HubSpot to send outbound messages created in Truora, which can also trigger WhatsApp flows.

## Prerequisites

1. **Truora Account**: You must have access to your {{< newtab href="/customer-engagement/account/" >}}Truora account{{< /newtab >}}.
2. **Create a Truora API Key**: For the **Test sending outbound messages** section of this guide, you´ll need a Truora API Key. If you don't have one already, follow this {{< newtab href="/customer-engagement/authentication/" >}}guide{{< /newtab >}} to create yours.
3. **HubSpot Integration**: Ensure you've already set up your integration with **HubSpot**. If not, please refer to the guide on {{< newtab href="/guides/hubspot/" >}}How to integrate HubSpot with Truora{{< /newtab >}}.
4. **Activated WhatsApp line**: If you don't have one already, follow this {{< newtab href="/guides/waba_acquisition/" >}}guide{{< /newtab >}} to acquire and activate WhatsApp lines in **Truora**. You'll need this to test your WhatsApp flows.
5. **Create a WhatsApp Flow**: Have at least one flow already built. Learn how to {{< newtab href="/guides/flows" >}}Create a WhatsApp Flow{{< /newtab >}} in **Truora**.
6. **Create an Outbound Message**: For the **Test sending outbound messages** section, you'll need an **Outbound Message** of type **Flow**. Follow the {{< newtab href="/guides/outbound" >}}Outbound Messages{{< /newtab >}} guide, if you don't have one yet.
7. **Understand Inbound Messages**: Familiarize yourself with {{< newtab href="/guides/inbound" >}}Inbound Messages{{< /newtab >}} and their processes.


## WhatsApp Flow for Integration Testing

This guide focuses on testing rather than building WhatsApp flows. However, we'll provide an overview of the **example flow** used for this guide and highlight key settings needed to integrate HubSpot within your flows.

Please note that the flow has a general path and then branches into two paths based on the user's response. Refer to the [Example Flow](./#the-example-flow) image for visual reference.

### General Flow Path (<span class="text-blue-500">**Blue**</span>):

  - **Your client sends it to you** block: The user initiates the conversation by sending a specific **Inbound Message**. For this example we set *"Hello Truora Hubspot Test!"* in our WABA line.
  - **Open Question** block (greeting): The user is asked to provide their name.
  - **Answer Options** block (test_options): The user selects between **I want to subscribe** or **Talk to an agent** options.

### I want to subscribe (<span class="text-red-500">**Red Path**</span>):

  - **Open Question** block (ask_email): The user is asked to provide their email address.
  - **Finish chat** block: The conversation ends with a message to the user, *"Your email <ask_email> has been registered"*

### Talk to an agent (<span class="text-green-500">**Green Path**</span>):

  - **Connect chat to an agent** block (HubSpot): The user receives a message, *"A representative will get in touch with you soon"* and the conversation is redirected to HubSpot.

    - **When inserting this block in your flows**:
      - Click on the CRM options and select **HubSpot**. This option will only appear if you've previously set up your integration with **HubSpot**.
      - In the message box, if needed, edit the default message the user will receive before the assigned agent responds.

{{<img src="/images/illustrations/customer_engagement/hs_test_agent_hubspot_block.gif" alt="Initial messages" width="80%" class="border border-slate-300 rounded-md">}}

  - **Finish chat** block: Once the conversation is closed in HubSpot, the user receives a message: *"Thanks for contacting us!"*

### The Example Flow

Below is the basic WhatsApp flow created for this guide's example (click to enlarge):

{{<img src="/images/illustrations/customer_engagement/hs_test_example_flow.png" alt="Example test flow" width="100%" class="border border-slate-400 rounded-md">}}

<br>

---

## Testing the Whatsapp Flow Integration with HubSpot

In this section, we'll test the flow by selecting the path to connect with an agent on the HubSpot platform:

### Steps to Test the Integration:

1. **Send the triggering message**: From an ordinary WhatsApp account, we'll send the message that triggers the conversation, *"Hello Truora Hubspot Test!"*, to the WABA line configured in the flow.
2. **Select to talk to an agent**: The bot will first ask the user's name via the **Open Question (greeting)** block, followed by a choice between **I want to subscribe** or **Talk to an agent** using the **Answer Options** block:
  - For this test, we answered *"John Doe Smith"* to the  **Open Question (greeting)** and then selected **Talk to an agent** to activate the HubSpot path via the **Connect chat to an agent** block.

  {{<img src="/images/illustrations/customer_engagement/hs_test_msg_0.png" alt="Initial messages" width="30%" >}}

3. **HubSpot - WhatsApp Interaction**: The conversation is redirected to an agent in HubSpot, where it continues. Here's how the interaction looks (click to enlarge):

  {{<img src="/images/illustrations/customer_engagement/hs_test_hubspot_whatsapp.png" alt="HubSpot-Whatsapp Interaction" width="100%" class="border border-slate-300 rounded-md">}}

  **Please Note**:

  - Once the conversation is redirected to HubSpot, a new conversation will appear in your HubSpot inbox, identified with a prefix starting with **IDP**.
  - You can view the entire message exchange between the agent and the user in HubSpot. The chat will remain active in HubSpot until the conversation is closed.
  - After closing the conversation in HubSpot using the **Close conversation** button, the flow will resume in Truora. In this specific case, the flow will activate the **Finish Chat** block, sending the message *"Thanks for contacting us!"* to the user.

## Access user responses as WhatsApp properties

While interacting with the user, responses to the chatbot are stored in HubSpot as **Contact Properties**.

To access these properties:

1. Navigate to the **Contacts** section in HubSpot.
2. Click on **Actions** > **View all properties**:

{{<img src="/images/illustrations/customer_engagement/hs_test_view_properties.png" alt="View HubSpot Contact Properties" width="100%" class="border border-slate-300 rounded-md">}}

2. In the search bar, type *“Truora”* to locate **Truora Properties**. You will find two types of properties:

- **Default properties** (<span class="text-blue-600">**Blue**</span>): General information about the interactions you've had with the contact through WhatsApp.

- **User responses** (<span class="text-green-500">**Green**</span>): The user's responses to chatbot interactions (excluding those with an agent).

{{<img src="/images/illustrations/customer_engagement/hs_test_contact_properties.png" alt="HubSpot Contact Properties" width="100%" class="border border-slate-300 rounded-md">}}

## Test sending outbound messages with HubSpot

**Outbound Messages** are sent directly to users without prior interaction on your WhatsApp Business Account (WABA) line. These messages can be configured with a **Conversation Type** set to **Flow**, which triggers a conversation flow once the outbound message is sent and the user agrees to continue.

>For instructions on creating and setting up an **Outbound Message** in **Truora**, refer to the {{< newtab href="/guides/outbound" >}}Outbound Messages Guide{{< /newtab >}}.

Here's how to test this type of message with HubSpot:

### 1. Access the Workflows section

In the left sidebar, navigate to **Automations** > **Workflows** to set up a workflow.

{{<img src="/images/illustrations/customer_engagement/hs_test_workflows.png" alt="Access Workflows Section" width="70%" class="border border-slate-300 rounded-md">}}

### 2. Create Workflow

Select **Create workflow** and then choose **From scratch**.

{{<img src="/images/illustrations/customer_engagement/hs_test_workflow_scratch.png" alt="Create Workflow" width="70%" class="border border-slate-300 rounded-md">}}

### 3. Select a Blank Workflow 

Choose **Contact-based** and then **Blank workflow**, and click **Next**.

{{<img src="/images/illustrations/customer_engagement/hs_test_contact_based_workflow.png" alt="Blank Workflow" width="70%" class="border border-slate-300 rounded-md">}}

###  4. Select "Send WhatsApp message by Truora"

Click the **Plus(+)** icon, scroll to **Whatsapp integration by Truora**, and select **Send WhatsApp message by Truora**.

{{<img src="/images/illustrations/customer_engagement/hs_test_select_send_wa_msg.gif" alt="Select Send WhatsApp message by Truora" width="80%" class="border border-slate-300 rounded-md">}}

### 5. Fill in the required fields

{{<img src="/images/illustrations/customer_engagement/hs_test_fill_outbound_required.png" alt="Fill Required Outbound Fields" width="80%" class="border border-slate-300 rounded-md">}}


>To flawlessly perform the following steps, and fill the required fields, you must meet the [prerequisites](./#prerequisites) listed at the beginning of this guide.

<br>

The following fields are required and then click **Save**:

- **Whatsapp Phone number**: Select the **Contact Property** in HubSpot that contains the WhatsApp phone number of your user. Common choices are *Phone Number*, *Mobile Phone Number*, or *WhatsApp Phone Number*. Verify which property applies to your contacts.
- **Truora API Key**: Enter the **Truora API Key** from your **Truora** account. Once entered, your available WABA lines will be listed in the next field.
- **WABA line**: Choose the WABA line from your **Truora** account that will be used to send the message to your users. Once selected, the available Outbound messages associated with this WABA line will appear in the next field.
- **Outbound message:** Select the Outbound message you've configured in your **Truora** account. You can also search by keywords or by **Outbound ID**. 
  - To get the **Outbound ID** of your previously created Outbound message, go to the **Outbound Messages** section in **Truora's Customer Engagement** product and click the **copy button** next to the desired Outbound:
  {{<img src="/images/illustrations/customer_engagement/hs_test_copy_outbound_id.png" alt="Copy Outbound ID" width="90%" class="border border-slate-300 rounded-md">}}

>***Note***: The **Conversation Type** of your **Outbound message** must be set to **Flow** to allow it triggering a flow.

- **Flow ID**: Enter the **Flow ID** of the flow you want to trigger after the user responds to the **Outbound message**. This **Flow ID** will be associated with the **Outbound ID** specified earlier. 
  - To get the **Flow ID** of one of your previously created Flows, go to the **My flows** section in **Truora's Customer Engagement** product and click the **copy button** for the desired flow:
  {{<img src="/images/illustrations/customer_engagement/hs_test_copy_flow_id.png" alt="Copy Flow ID" width="90%" class="border border-slate-300 rounded-md">}}

### 6. **Enroll a Contact and Test Workflow**

  - Click **Review and Publish**, then select **Manually add contacts**.
  - Select **Choose individual contacts**, find the contact you want to enroll, and select it.
  - Click **Save existing**, then **Skip to turn on**.
  - Finally, click **Turn on workflow**. The workflow will execute, and the selected contact will receive the Outbound message you configured.

{{<img src="/images/illustrations/customer_engagement/hs_test_workflow_enroll_and_run.gif" alt="Enroll Contact + Run Workflow" width="80%" class="border border-slate-300 rounded-md">}}

For the example used in this guide, we set the **Flow ID** and the same **Contact** of the first example. 

The image below shows the message received by the contact. By responding to the **Outbound Message** with "*Continue*"", the [same flow](./#the-example-flow) used in this guide was triggered:

  {{<img src="/images/illustrations/customer_engagement/hs_test_outbound_msg.png" alt="Outbound message test" width="30%" >}}