Customer.io: automated WhatsApp messages using TimelinesAI Public API

This Customer.io workflow: sends WhatsApp messages when a user fills out a web form; checks for responses, and follows up with additional messages if no response is received. If a response is received, the workflow sends an automated thank-you message.. The flow is based on TimelinesAI Public API and Customer.io Journeys Workflow.

image 28

Setting up the Trigger

1. Open your Customer.io account > Campaigns
2. Create a campaign: give your campaign the desired name, description, and tags
3. Select the desired trigger. In this example, we will use the When someone submits a form trigger
4. Configure your form. This workflow requires a form several hidden fields. Please check with the form provider whether such fields can be added to the form. Hidden field names must have the values listed below and values should be left empty. Values to those fields will be added by the workflow automatically at a later stages.

Required hidden field names:

  • message_1
  • message_2
  • chatid
  • message1_timestamp
  • message2_timestamp
  • last_message_timestamp
  • last_message_timestamp_2

Required standard field:

  • field for the phone number that the user fills in within the form.

5. Select desired Settings and Goal & Exist

image 29

6. Save your campaign and fill in your form to get the initial data for the further workflow steps. When the form is submitted new contact must appear at Customer.io > People. The created contact will have the form field data as attributes. Hidden fields will result in attributes with xxxxx as a value.

image 30

Sending the 1st automated WhatsApp message in response to the filled-in form

The purpose of this step is to automatically send the 1st WhatsApp message when the customer fills in the form

1. Re-open your campaign at Customer.io and navigate to the Workflows tab.
2. Drag and drop the Send and Receive Data to the workflow board ( place it after the Trigger). Click the newly placed “Webhooks” module to configure it.

image 31

3. Configure the module:

  • WEBHOOK NAME – rename the module to Send 1st WA message
  • SENDING BEHAVIOR– select send automatically
  • other settings – select as needed

4. Add a request:

{
"phone": "YOUR_DATA_HERE",
"whatsapp_account_phone": "+YOUR_WA_SENDER_NUMBER_HERE",
"text": "YOUR_CUSTOM_MESSAGE_HERE"
}
  • YOUR_WA_SENDER_NUMBER_HERE – must contain your WhatsApp account number in an international format
  • YOUR_CUSTOM_MESSAGE_HERE – the desired message
  • YOUR_DATA_HERE – must contain the phone number person entered when filling in your form. To add custom data, delete the YOUR_DATA_HERE text first, Leave the cursor between ” ” and open the sample data from the left sidebar > Event Data tab > scroll down to find the form field that contains a phone number > click the + next to it > select T_he message or action will fail_ in a popup > click add. Your request will change to something like this: “phone”: “{{event.nLJpTuNCaZrs}}”
image 32
  • Response – switch to the Response tab > Setup an attribute > select message_1 under the Set drop down > add {{response.data.message_uid}} into the request box
image 33

5. After the request and response are added click the Send Test button in the upper right corner of the page. You should have the 200 OK response status and Success message for setting the attribute:

image 34

Getting data about TimelinesAI chat ID and message sent timestamp

The purpose of this step is to obtain the chatID and timestamp of the initial WhatsApp message. This information is essential for determining whether the customer responded to the first message later on

1. Re-open your campaign at Customer.io and navigate to the Workflows tab.
2. Drag and drop the Send and Receive Data to the workflow board ( place it after the Send 1st WA message module). Click the newly placed “Webhooks” module to configure it.
3. Configure the module:

  • WEBHOOK NAME – rename the module to Get chatID and 1st message timestamp
  • SENDING BEHAVIOR– select send automatically
  • other settings – select as needed

4. Add a request:

  • Type: GET
  • URLhttps://app.timelines.ai/integrations/api/messages/{{customer.message_1}}
  • Header1: name = Content-Type, value = application/json
  • Header2: name = Authorization, value = Bearer XXX . Where XXX be replaced with your TimelinesAI token from https://app.timelines.ai/integrations/api/
  • Response: switch to the Response tab > Setup an attribute> select chatid under the Set drop down > add {{response.data.chat_id}} into the request box . Then click Set another attribute. Select message1_timestamp under the Set drop down> add {{response.data.timestamp}} into the request box
image 35

5. After the request and response are added click the Send Test button. You should have the 200 OK response status and Success message for setting the attribute
6. Drag and drop the Time Delay to the workflow board ( place it after the Get chatID and 1st message timestamp module). Select the desired amount of time you would like the flow to hold on until proceeding further. Example: 1 hour
7. Drag and drop the Send and Receive Data to the workflow board ( place it after the Time Delay module). Click the newly placed “Webhooks” module to configure it.
8. Configure the module:

  • WEBHOOK NAME – rename the module to Check chatID
  • SENDING BEHAVIOR– select send automatically
  • other settings – select as needed

9. Add a request:

10. After the request and response are added click the Send Test button. You should have the 200 OK response status and Success message for setting the attribute

Intermediate results:

image 36

Verifying if the 1st WhatsApp message received a response or not. Sending a “Thank you” message if the response was received.

  1. Drag and drop the True/False branch to the workflow board ( place it after the Check chatID module).
  • Name to avoid confusion we recommend giving the following name to this module: TRUE=no reply. customer replied to 1st message?
  • Conditions : select lastmessagetimestamp in the first drop down; is equal to in the second drop down; the current person’s attribute in the third drop down; message1timestamp_ in the fourth drop down :
image 37

Our workflow is now split into two branches: “True” indicates that the customer has not replied to the initial WhatsApp message, while “False” indicates that the customer has replied.

It is crucial to consider that determining whether a customer has responded involves comparing two timestamps: the timestamp of the initial WhatsApp message and the timestamp of the last message in the chat. If these timestamps are identical, it indicates that no new messages have appeared in the chat, directly suggesting that the user has not replied to the first message. Conversely, if the timestamps do not match, it implies that new messages were present in the chat after the first WhatsApp message was sent. While this strongly suggests a response, it is not an absolute guarantee, as it is conceivable that, within the one-hour waiting period between the first message and the present moment, you may have sent another message to the user, altering the last message timestamp.

Let’s finish the “False” branch first:

2. Drag and drop the Send and Receive Data to the workflow board ( place it under the False branch). Click the newly placed “Webhooks” module to configure it.
3. Configure the module:

  • WEBHOOK NAME – give the module any name. Example: Send Thank you message
  • SENDING BEHAVIOR– select send automatically
  • other settings – select as needed

4. Add a request:

{
"text": "YOUR_CUSTOM_MESSAGE_HERE"

}
  • YOUR_CUSTOM_MESSAGE_HERE – the desired message

5. Drag and drop the Exit module to the workflow

Sending the the 2nd automated WhatsApp message if no response was received for the 1st one

1. Drag and drop the Send and Receive Data to the workflow board ( place it under the True branch). Click the newly placed “Webhooks” module to configure it.
2. Configure the module:

  • WEBHOOK NAME – name the module Send 2nd WA message
  • SENDING BEHAVIOR– select send automatically
  • other settings – select as needed

3. Add a request:

{
"text": "YOUR_CUSTOM_MESSAGE_HERE"

}
  • YOUR_CUSTOM_MESSAGE_HERE – the desired message
  • Response: switch to the Response tab > setup an attribute > select message_2 under the Set drop down > add {{response.data.message_uid}} into the request box .

5. After the request and response are added click the Send Test button in the upper right corner of the page. You should have the 200 OK response status and Success message for setting the attribute
6. Drag and drop the Send and Receive Data to the workflow board ( place it after the Send 1st WA message module). Click the newly placed “Webhooks” module to configure it.
7. Configure the module:

  • WEBHOOK NAME – rename the module to Get 2nd message timestamp
  • SENDING BEHAVIOR– select send automatically
  • other settings – select as needed

Add a request :

9. After the request and response are added click the Send Test button. You should have the 200 OK response status and Success message for setting the attribute

10. Drag and drop the Time Delay to the workflow board ( place it after the Get 2nd message timestamp module). Select the desired amount of time you would like the flow to hold on until proceeding further. Example: 1 hour
11. Drag and drop the Send and Receive Data to the workflow board ( place it after the Time Delay module). Click the newly placed “Webhooks” module to configure it.
12. Configure the module:

  • WEBHOOK NAME – rename the module to Check chatID
  • SENDING BEHAVIOR– select send automatically
  • other settings – select as needed

13. Add a request:

10. After the request and response are added click the Send Test button in the upper right corner of the page. You should have the 200 OK response status and Success message for setting the attribute

Verifying if the 2nd WhatsApp message received a response

1. Drag and drop the True/False branch to the workflow board ( place it after the Check chatID module).

  • Name to avoid confusion we recommend giving the following name to this module: TRUE=no reply. customer replied to 2nd message?
  • Conditions : select lastmessage_timestamp_2_ in the first drop down; is equal to in the second drop down; the current person’s attribute in the third drop down; message2timestamp_ in the fourth drop down:
image 38

Now our workflow is divided into 2 branches again where “True” = customer has NOT replied to the second WhatsApp Message and “False” = customer replied.

2. Drag and drop the Send and Receive Data to the workflow board ( place it under the False branch). When placed it will create a new block called “Webhooks” by default.
3. Configure the module:

  • WEBHOOK NAME – give the module any name. Example: Send Thank you message
  • SENDING BEHAVIOR– select send automatically
  • other settings – select as needed

4. Add a request:

{
"text": "YOUR_CUSTOM_MESSAGE_HERE"

}

5. Drag and drop the Exit module to the workflow
6. Drag and drop the Exit module to the workflow under the True branch

End result: user fills in the form, workflow sends the 1st WhatsApp message automatically in response to the filled in form> checks whether user replied to the 1st Message. If yes > send a Thank you message in response and exist the flow. If user did not reply to the 1st message: send the 2nd WhatsApp message > check whether user replied to the 2nd message. If yes > send a Thank you message in response and exist the flow. If user has not replied to the 2nd message > exit the flow. Download the full workflow image here: https://storage.crisp.chat/users/helpdesk/website/94268256ba492800/customerio-workflow-sending-wa_k4393j.png

Table of Contents

Omnichannel Automation Platform

TimelinesAI helps businesses with multiple individual numbers gain 360° visibility & boost performance on WhatsApp.

ajkasjdlaspng

Latest from Blog