In certain scenarios, you might want to update customer attributes in a customer profile from within a campaign journey. You can do that by setting up a custom app that uses Blueshift’s Update Customer API and then using a trigger for the custom app in the campaign journey.
Let’s look at an example use case and see the steps required to update a customer profile attribute. You can follow the same steps for any other use case.
Example 1
Update the membership_tier attribute for a customer to Gold if the lifetime revenue for the customer exceeds $5000.
For this example, we use the revenue attribute from the purchase event. This revenue from the purchase event is added to the current user.lifetime_revenue and the membership_tier is determined based on the new value for user.lifetime_revenue.
Here are the steps involved:
- In the App Hub, add a custom app that uses Blueshift’s Update Customer API.
- Add an adapter for the custom app.
- Set up a cloud app template that will send data via the custom app (Blueshift’s Update Customer API).
- Add a trigger in the campaign journey for the custom app and select the cloud app template.
Add a custom app
To add a custom app that uses Blueshift’s Update Customer API, complete the following steps.
- Go to App Hub > My Apps and click +ADD CUSTOM APP.
- Provide a Name for the app and add a Description.
- Specify the Type of Authentication as Basic HTTP.
- Upload a logo for the app.
- Click Save.
The custom app is created.
In the following example, the custom app is named as UpdateCustomer.
For more information, see Custom apps.
Add an adapter for the custom app
To set up the adapter, you need the API username which is the User API key in Blueshift. You can get the User API Key from the API Keys tab of your Account Settings in the Blueshift app.
- Open the custom app and click +ADAPTER.
- Provide the authentication information:
- API username: The User API Key from the API Keys tab of your Account Settings in the Blueshift app.
- API password: There is no API password. However, since this field is mandatory, add a single space here.
- Click Save.
In the following example, the UpdateCustomer_API adapter is added for the custom app UpdateCustomer.
Create a cloud app template
To send messages from within a campaign, you must create a cloud app messaging template for the custom app that you created to update a customer profile. In the cloud app template, you must set up the schema as per the requirements of the Update Customer API.
To create a cloud app template, complete the following steps:
- Open the custom app and click +CREATE A TEMPLATE.
OR
Go to Creatives > Cloud App and click +TEMPLATE. Select the custom app that you added previously. - Add a name for the cloud app template. For example, UpdateCustomer_type.
- Go to the Properties tab > Settings section.
- Select the Adapter that you want to use to send the message.
In this example, we are using the UpdateCustomer_API adapter that we added for the custom app UpdateCustomer. - For the API endpoint, add https://api.getblueshift.com/api/v1/customers.
- Go to the Advanced Settings section.
- Select POST as the HTTP Method.
- Select the Send payload as a URL encoded form option.
- Go to the Content tab > Schema section.
- Add the schema for the Update Customer API.
For the Update Customer API, the customer identifiers email and customer_id are mandatory fields. Include these fields as required fields in the schema. - Add other fields based on the customer attributes that you want to update.
For this example, we will be updating the membership_tier attribute.
- Go to the Content Form section. For the required customer identifier fields, you can use Liquid for personalizations.
- Go to the email field and add double curly brackets. The list of available attribute categories is displayed.
- Select user and then select email.
- Similarly, go to the customer_id field and add double curly brackets. The list of available attribute categories is displayed.
- Select user and then select customer_id.
- To use attributes from an event in the content, go to the Data tab > Preview Data section.
- Select Event as the option and then select the event from which you want to use attributes to update the customer profile.
In this example, we are using the purchase event. - In the Show Data section, go to the bsft_event_context object. This contains the event specific data that you can use in your template.
- In this example, revenue is added to the current user.lifetime_revenue. If the lifetime revenue for the customer exceeds $5000, the membership_tier attribute is updated to gold.
The following Liquid expression is used to determine the value of the membership_tier attribute.{% assign rev = user.lifetime_revenue | plus: bsft_event_context.revenue %} {% if rev > 5000 %} gold {% else %} regular {% endif %}
- You can view the filled fields in the right Preview pane.
- Save the template.
You can now use this template in a campaign journey.
Use template in campaign journey
In this example, the campaign journey is triggered by the purchase event. The first trigger checks and updates the membership_tier for the customer. Then a Regular customer is sent an Order Received email, whereas the Gold customer gets a 20% discount coupon along with the Order Received email.
To use the custom app template in the campaign journey to update customer attributes, complete the following steps:
- In the campaign journey, add a trigger for the custom app.
- Select the cloud app template that you created to update the customer membership_tier attribute.
- Add the triggers for sending the emails. Send an Order Received email to a regular customer, and send the Order Received plus a 20% discount coupon to the gold customer.
Example 2
Update customer profile with data from an event or transaction attribute.
In this example, when a customer makes a booking for a car rental, the last_reservation attribute for the customer is updated with the Last reservation time (timestamp attribute) from the car rental booking (car_booking event).
Example 3
In this example, a customer responds to a survey or promotion SMS with a specific keyword denoting a preference, a preferred color. The data from the message_body attribute from the Inbound Message (bsft_inbound_message) event is added to the customer_color_selection attribute in the customer profile.
Comments
0 comments