How to
Setting up a STOP or unsubscribe flow

Shrawani Bhattarai
Shrawani Bhattarai
  • Updated

Method 1

This method outlines an approach for automating SMS unsubscribe requests using CRM integration.

method01.png

1. Inbound Message Trigger

Configure an inbound message trigger to continuously monitor incoming SMS messages for unsubscribe keywords.

The trigger should be set to recognise various keywords indicating an unsubscribe request. Common keywords include "stop", "unsubscribe", "opt out", "stopall", "cancel", "end", "quit", and similar variations. This ensures the system accurately detects and processes all unsubscribe requests promptly.

inbound.png

2. Check Contact in CRM

Upon receiving the unsubscribe keyword, use the **Make a web request** node to determine if the contact exists in the CRM (e.g., HubSpot). This involves configuring the node to send a POST request to the HubSpot contacts search API.

Here is how the configuration may look like:

checkcontact.png

In the request body, we send through the phone number via a merge field to be compared against the specified property in the CRM.


  {
  "filterGroups": [
    {
      "filters": [
        {
          "propertyName": "mobile_phone__pre_defined_country_format_",
          "operator": "EQ",
          "value": "{{ inboundSMSTrigger_1.fromNumber }}"
        }
      ]
    }
  ]
}

You can add a payload as such in the Make a web request node under Merge fields → Payload. The total field is part of the response body returned by the CRM search request, indicating the number of contacts matching the specified criteria (e.g., phone number).

  {
    "total": 1,
    "results": [
        {
            "id": "2017",
            "properties": {
                "mobile_phone__pre_defined_country_format_": "+61455841220",
                "email": "example@email.com",
                "firstname": "John",
                "hs_object_id": "2017",
                "use__ticket_activity__waiting_for_reg_forms_": " 180 days",
                "lastname": "Does"
            }
        }
    ]
}

3. Criteria Split

Utilise a criteria split to categorise recipients based on the existence of their contact information in the CRM. This split directs the flow along different paths depending on the search results from the previous step.

  • Contact Found: If the contact exists in the CRM, the flow proceeds to update their opt-out status. Recipients will follow this path if the total number of matches from the CRM search is greater than or equal to 1.
  • Contact Not Found: If the contact does not exist in the CRM, the flow sends an outbound SMS informing the recipient. Recipients will follow this path if the total number of matches from the CRM search is equal to 0.
  • Other: Recipients will follow this path if none of the previous path criteria are met. The flow sends an outbound SMS informing the recipient.

criteriasplit.png

4. Update Contact in CRM

For contacts found in the CRM, use the Make a web request node to update their contact details, setting their status to opt-out. This involves configuring the node to send a PATCH request to the HubSpot contacts API.

updatecontact.png

In the request body, include the properties that need to be updated. For example:

  {
    "properties": {
        "sms_opt_out__pendula_": "Opted Out",
        "sms_flow_status__pendula_": "SMS Replied-OptOut",
        "sms_last_response__pendula_":"Flow: Re-engage leads\nSMS Reply - OptOut Path\nResponse:{{ inboundSMSTrigger_1.messageBody }}"
    }
}

5. Notify the User

Use the **Outbound SMS** node to inform the customer about their unsubscribe request and provide options to resubscribe if it was done accidentally. To handle resubscription requests, you can set up another flow with an Inbound Message Trigger for the keyword RESUME.

Method 2

While the above method effectively handles unsubscribe requests, it doesn't provide insights into when or after which message a user decided to opt-out. This method addresses this limitation by offering a way to track when users opt-out and during which flow this occurs.

Flow 1

branded-flow1.png

1. Webhook trigger

Use a Webhook Trigger Node to send a data payload. This node will initiate the flow. You may have a payload as such:

{
  "mobile": "0423561439",
  "name": "John Doe"
}

2. Conversation Node

Define multiple paths based on the user's response.

  • Yes (in this example): Continues with the flow's primary purpose.
  • STOP: Directs the user to an unsubscribe path. You can use multiple keywords as we did in the first method.

3. Make a Web Request

Set up a Make a Web Request node to handle the unsubscribe action. This node will POST the data to the webhook URL used in Flow 2.

branded-flow1-makearequest.png

In the request body, you can send user details such as mobile number, name, and flow ID.

The flow ID needs to be manually copied from the URL.
For example, in the URL https://prod3.pendula.app/flows/875ebf90-0332-4b45-8d97-4a30b9f694e0, the flow ID is the part after flows/ and before any other parameters. In this case, the flow ID is 875ebf90-0332-4b45-8d97-4a30b9f694e0.

{
  "mobile": "0400000000",
  "name": "John Doe",
  "flow_id": "875ebf90-0332-4b45-8d97-4a30b9f694e0" 
}

By setting up Flow 1 in this manner, you can direct users based on their responses, track when they decide to opt-out, and handle the unsubscribe process efficiently through a subsequent flow (Flow 2).

Flow 2

Flow 2 is designed to handle the unsubscribe process initiated in Flow 1. It operates similarly to Method 1 but uses a webhook trigger instead of an inbound message trigger to start the process. Configure a Webhook Trigger Node to initiate Flow 2 when it receives a data payload from Flow 1.

You can also paste a sample payload:

{
  "mobile": "0400000000",
  "name": "John Doe",
  "flow_id": "875ebf90-0332-4b45-8d97-4a30b9f694e0" 
}