Webengage

Documentation on how to consume the API in WebEngage

How to get the data from LEGO API

  1. Build API Request

    • Please ensure the REQUEST TYPE is POST and not GET which is the default option (underlined in blue)
    • Please copy and paste the following link https://lego.headout.com/api/template/<uid> in the URL bar. Replace <uid> (underlined in green) with the UID of the email.
    • Click on Set Body option and use the following format. Please ensure that you wrap each property and it's value in double quotes

    Default values:

      {
        "lang": "{{journey["state-27"].custom["language"]}}",
        "name": "John",
        "weTestResponse": "false",
        "userId": "{{user["system"]["cuid"]}}",
      }
    
    • In the above code, lang property is mandatory.
    • name and tourGroupName property can be named anything. Please ensure that you use the same when using the {field} shortcode. Ex: {field key=tourGroupName fallback="tour"}.

    Note: Set Body option is used to send WebEngage Data to the API and we can then show that data inside the email.

    • Once you are done with the above step, please click on CONTINUE.
  2. Test Response

    WebEngage Test API response
    • You will see the above screen only if there is dynamic variable in the body.
    • If you have dynamic value (webengage data), you can replace it with dummy data. For lang you can use en or english.
    • IMPORTANT: Please add "weTestResponse": "true" at the end (underlined in blue). This is going to give us dummy data during test. WebEngage has limits and if the response exceeds certain number of characters or size we wouldn't be able to save the API block.
    • Once you have replaced all the variables with dummy data and added "weTestResponse": "true". Click on the text inside the green bar.

Note: Please do not skip this step.

  1. Review

    WebEngage review
    • If the test is successful, you should see the above response. Status will be 200 (underlined in green)
    • Click on SAVE

    Note: Sometimes if the response body is long, WebEngage wouldn't let you save. Close the API block and reopen, repeat step 1, skip step 2 and save on step 3.

Retrieving the data inside the email

  1. Click on the Email block, and go to Message tab.
  2. Scroll down to the message section.Select Api
  3. Click on the PermanentIdentity icon (^^ underlined in blue).
  4. You would see 3 options:
  • User Attributes
  • Custom Events
  • Journey
  1. Select Journey and inside journey you should see the options () listed in the above image. Select Call an API: POST http. Note: You may not see all the options as shown in the above image but Call an API: POST should be one among them.

  2. Subject

    • After you select the above option you will two options. Select subject. By default, this how the webengage variable will look like {{journey["state-76"].api_data["subject"]}} you will have to add .variant_a. Final, code will be {{journey["state-76"].api_data["subject"].variant_a}}

    Note: Do not copy subject code from the above line and paste it in the journey. Each journey will have it's own state value, hence it may not work.

    • To get other variant's, replace .variant_a with .variant_b and so on.
  3. Body

    • Go to the body section, select the options as Raw HTML
    • Repeat steps 3-5
    • Select Body
Adding Subject and Body
  1. Follow the webengage docs to complete the email setup.

Example Journey

FAQs

  1. How do I use this api for an email which is localised?
    • The same email block will handle different languages. You do not have to create separate blocks for different languages.
    • There might be edge cases, but we will cross that bridge when we get there.

How to connect Webengage API Failure Alert slack app with webengage.

We have created api endpoint that alerts us on slack (#webengage_api_failure_alerts) if there is a API failure. However, we need to set this up for every failure block.

Steps:

  • On failure, hit lego.headout.com/api/
  • This is POST request, so please change the REQUEST_TYPE to POST
  • Add post body, please use the below example ensure that you modify the values accordingly
  • On success, we can end the journey

Fields:

  • journeyName - (static & manual) WebEngage Journey name
  • journeyUrl - (static & manual) WebEngage journey url
  • apiUrl - (static & manual) Copy and the paste the entire url from API block that's above this block
  • userEmail - (dynamic) Use the property from webengage
  • apiComments - (static & manual) Some comment
  • disable - (optional) if set to true, alerts will not be sent to slack

Note - All of the above fields are mandatory except disable

 {
    "journeyName": "Test",
    "journeyUrl": "www.test-headout.com",
    "apiUrl": "api.headout.com",
    "apiComments": "Some comment",
    "userEmail": "test@headout.com"
 }