Experience League | Image

Enhancing Voice and Chat Experiences with Personalized Dynamic Content.

Table of Contents

Lab Overview

In this lab you will learn how to provide Content Authors & Marketers greater input & control over the experiences delivered to consumers who interact with Chat Bots (eg Microsoft Bot Framework) and Voice Based Experiences (e.g. Amazon Alexa)

First you will experience an example of personalized content within a live Chatbot, and run a basic generic bot.

You will then create and reuse content from Adobe Experience Manager within the Bot using Content Fragments & Experience Fragments via standard Content Services APIs

Finally, you will also use Adobe Target to provide an optimized and personalized experience

Key Takeaways

  • Being able to managing voice & chat content with AEM Content Fragments as part of a multi-channel workflow.
  • Find & deliver relevant content in the right size, shape and format using AEM Experience Fragments & Dynamic Media / Smart Crop with Sensei.
  • Add new content and interactions without writing code.
  • Optimizing and personalizing chat and voice content using Adobe Target

Prerequisites

  • Adobe Experience Manager 6.5
  • Adobe Target (Lesson 5 only)
  • Microsoft Visual Studio Code (or your favourite code editor)
  • Microsoft Bot Framework Emulator

Lesson 1 - Understanding Bot Architecture

Objective

  1. Interact with a live chatbot.
  2. Deploy and run a simple chat bot
  3. Understand the relationship between Voice & Chatbots

Lesson Context

Most ChatBot & Voice UI solutions today are based on a client (a web component on a page, or device such as the Amazon Echo) which communicates with the back end via a NodeJS like environment. Without getting into a discussion on the differences between AWS Lambda & Microsoft Azure Functions, it's worth noting that the architecture is very similar, with only the platform nuances for the user experience requiring effort.

Example Microsoft Bot Framework & Adobe Experience Cloud Architecture

Whether building for Chat Bots or Alexa Skills, in many cases you can get a lot of value by extending your base Node.JS project with integrations with the Adobe Experience Cloud. That is our focus for the lab.

Example use cases for integration are as follows;

  • Adobe Experience Manager - Experience Authoring and Content Management
  • Adobe Analytics - Customer Journey Analytics across all channels + usage insights
  • Adobe Target - Decisioning engine for Personalised Experiences
  • Adobe Campaign - Connection to Profile Data + follow up actions (email, push, sms etc)
  • Adobe Audience Manager - Transferring Context & Real Time Profile from other channels to Chatbot/Voice

Exercise 1.1 - Interact with an existing bot.

Lets start by opening up a page in AEM and adding a chat component, so we can see how a completed bot might behave.

  1. Login to your lab machine with the following credentials

    • Username: L729
    • Password: summit2019
  2. Open up the Credit Card example page where we will add the Chatbot

    Open your browser to http://localhost:4502

    1. Username = admin
    2. Password = admin

    Click on Sites -> weFinance APAC -> Language Masters -> En -> Personal -> Credit Cards. Select & open.

    Figure 1: Credit Card Page

  3. Make sure you are in edit mode, then from the Components Panel, drag the "Chatbot" component to the bottom of the page. The chatbot should appear.

  4. Switch to Preview mode and the Bot should load.

    Figure 2: Chatbot Component

  5. Let's interact with our first example bot

    1. Type "Hi" as the message, then press send (or return).
      1. A few things happen here;
      2. The Bot understands Context of which page its been called from.
      3. It understands the user is anonymous so offers Bronze member benefits
      4. Adobe Target has been called and a default offer has been returned.
    2. Type "What offers" as the message and press send / return.
      1. The Bot returns 3 offers in a carousel.

        Figure 2: Credit Card Offer

      2. The decision for which offer to display was made by Adobe Target

      3. The images and text were coming from Adobe Experience Manager

      4. The interactions are being captured for analysis in Adobe Analytics.

    3. Click "Apply Now"
      1. The bot responds with a link to the appropriate Application Form

    If you are new to bots, you might be wondering how the magic is happening between typing something and getting a result. Each phrase you enter is commonly referred to as an utterance. Utterances are mapped to Intents, typically by an Machine Learning engine like Microsoft's LUIS. Once the Intent is mapped, the execution logic can be mapped.

    Figure 2: Utterances Mapping

    Note that for this lab we will be bypassing the use of LUIS and just mapping phrases directly to Intents to simplify the lab.

  6. Switch back to Edit Mode in AEM, and select the Bot (you may have to refresh the browser window if its not highlighting)

  7. Click on the Wrench to open the Chatbot properties. Note that the Bot ID & Bot Secret are entered into the component here. This is where you would normally add the connection details of your completed bot. We'll be creating a new bot, but thought it worthwhile to show how the final result is integrated back into a site.

    Note! In a production scenario you most likely want to hide these properties away from a casual content author so its not changed by user error. This is out of scope for the lab and presented this way for simplicity.

Exercise 1.2 - Getting to know our Bot Project

We will be building capabilities into a sample bot throughout this lab. While not trying to teach everything about building Bots in this lab, I'll try and cover some of the basics.

To build a bot using Microsoft Bot Framework you typically need access to a Microsoft Azure account. For the sake of the lab we will keep things as simple as possible, so we will use the Microsoft Bot Framework emulator to emulate the Chatbot Client (a very useful tool during development) and run Node.JS locally to test the backend functionality of our bot.

  1. Look for the "Bot Framework Emulator" in your Mac's Dock and open it.

  2. Click "Open Bot" on the Welcome Screen and browse within the project files for "weFinanceBot.bot"

  3. The Bot Emulator will load the Bot definition and is ready for interaction.

  4. Try typing a message.. it wont work as there is no server running yet!

  5. Open up Visual Studio Code from your Mac's Dock

  6. Ensure the project is loaded, otherwise select File -> Open..

  7. Open the Terminal within VS Code by selecting Terminal -> New Terminal

  8. Run the following two commands to initialise the bot

  9. If all goes well, you should see the following

    • ***weFinance BOT started ***
    • listening to http://[::]:3978
  10. Switch back to the Emulator and type "hi"

  11. The Bot should respond with "Hi There!".

  12. Lets see how this works.

  13. Open up bot.js in Visual Studio Code

  14. In this simplified example, there are a few things to call out

    1. bot.js is where the logic on how to respond to user input is managed.
    2. async onTurn on Line 14 is waiting for user interaction
    3. The logic is straight forward on line 17-20. If the user types 'hi' then respond with 'Hi There!'
  15. Let's try a couple of things

    1. Change the 'Hi There!' text to something else.
    2. Try it in the Bot Emulator
    3. Didnt work? You need to stop the app running in Terminal (in Visual Studio Code) and start it again
      1. Click on the terminal window in VS Code
      2. Type Control+C to exit Node.js
      3. type npm start to start it again
      4. Test your bot again.
    4. Duplicate the whole function to support another intent
      1. Copy lines 16-20 and paste below
      2. Edit the intent.. change 'hi' on line 17 to 'bye'
      3. Change the response on line 19 to 'Thanks for the chat'
    5. Stop / Start Node once again
    6. Test your bot. Now you can say hello and goodbye!

Exercise 1.3 - Preparing for Adobe Goodness

We will be calling on Adobe Experience Manager & Adobe Target in the next few lessons, but lets not get the core support in place. This will also enable us to track our bot using Adobe Analytics.

Let's add the Helper definitions and links to property setup files.

  1. Open snippets/ex1.3.1.js and examine the code

  2. There are a number of helper functions supplied as part of this Lab in the /helpers directory. The code above loads and initializes them. Lets look at the Adobe Analytics example.

    1. Open properties.config
      1. Note the name of the analytics.reportsuite used by Adobe Analytics
    2. Open helper/analytics.js
      1. Note the import of the publicly available adobe-analytics-di NPM module on line 3
      2. Note the reference to the the reportsuite set in the properties file on line 7
  3. Open bot.js

    1. Paste the entire contents of snippets/ex1.3.1.js into bot.js near to Line 6, like this
    1. Add the following line to each of your intent handlers to track within Adobe Analytics.
    1. Example as follows;
    1. Save bot.js
  4. Restart the bot (Control-C then type npm start -> return)

  5. Switch back to the Bot Emulator

    1. Type 'hi' to invoke the Greeting intent.
    2. Type 'bye' to invoke the Farewell intent.
  6. Switch to VS Code

    1. In the console you should see Analytics tracking intent: bye
    2. As you call an intent now, the server side Node.js code will call Adobe Analytics Direct Injection API to ingest the data into the report suite defined in the properties file.

      For more information on the Adobe Analytics NPM module: https://www.npmjs.com/package/adobe-analytics-di

  7. See the results in Adobe Analytics

    1. Open this Adobe Analytics Link

    2. Click "To login via the Experience Cloud ID, click here"

    3. Click "Sign in with an Adobe ID"

    4. Username: mszulc+lab05@adobetest.com

    5. Password: summit

    6. If a pop up to enter your phone number appears, click "skip"

    7. Click "Real Time" at the bottom of the list of reports.

    8. You should see a report similar to the image below.

      Figure 1.3.1: Real Time Reportt Note: There is a typical lag of around 15 seconds between action and report. Feel free to change the values of your intent and test the results.

      This is not an exhaustive overview of how to correctly track a chatbot. For more detailed information on this topic check out this resource Adobe Analytics Help

Lesson 2 - Basic Bot Content Management with AEM Content Fragments

Objective

  1. Create Content Fragments in AEM for Chatbot Prompts
  2. Explore new Content Fragment API in AEM 6.5
  3. Update our bot project to use the AEM content.

Lesson Context

In Lesson 1 we manually entered the chatbot response directly into the code. While this is easy to manage for simple bots like the one in this lab, over time it can be painful. We can use AEM Fluid Experiences feature to allow content authors to manage the chatbot content without dramatically altering the way we manage the bot logic.

Exercise 2.1 - Create Content Fragments in AEM for Chatbot Prompts.

  1. Log into AEM

    1. Browse to http://localhost:4502
    2. Username = admin
    3. Password = admin
  2. Navigate to Content Fragments

    1. Click Assets -> Files -> weFinance -> English -> Chatbot or click http://localhost:4502/assets.html/content/dam/wefinance-apac/en/chatbot
  3. Open existing fragment

    1. Open the Greeting Folder and then open the Hello fragment.

      This fragment will be used as our Bot greeting. In a moment we will wire up our bot to consume the content from this fragment

    2. Close the fragment
  4. Create new fragment + publish

    1. Click the Create button and select Content Fragment

    2. Select Simple Fragment (we'll look at the others soon)

    3. Enter the title as "Announcement"

    4. Click "Create" then open.

    5. Click the main body of text and enter "We are pleased to announce a drop in interest rates."

      Content Fragment Editor

    6. Click Save.

    7. Select both fragments (Hello & Announcement) and click "Quick Publish"

Exercise 2.2 - Explore new Content Fragment API in AEM 6.5.

Now that we have some content, lets see how we can access it from outside of AEM

  1. Open Postman (a recommended tool to help explore APIs.)

  2. Call the CF API

    1. Open the FSI Lab collection on the left, and select "AEM: Get Content Fragments (CF)
    2. This should open up the following URL to call; http://localhost:4503/api/assets/wefinance-apac/en/chatbot/greeting.json
    3. Note that the above URL relates to the path of the fragments within AEM. "greeting" was the name of the folder we placed our fragments into.
  3. Note the contents within the JSON related to our fragment

  4. Now we can write some simple code to consume the JSON

Exercise 2.3 - Update our bot project to use the AEM content.

  1. Open or switch back to Visual Studio Code

  2. Paste in the following code (from snippets/ex2.3.1.js) below your existing intent

  3. Run the Bot (if it's already running, type Control-C to quit)

  4. Open Bot Emulator and type "hello".

  5. You should see the following result

    CF Content in Chatbot

  6. Open the AEM CF helper file to see how its simply passing the JSON that we looked at in Postman

Use this technique for any part of the Chat experience that you want to hand off the content to a content author to manage. Note that for the lab the results are fetched live each time the user types "hello". In a production environment this detail could be cached and/or checked at intervals.

You may also be wondering why you wouldn't just update the dialog content within one Content Fragment.. above is a simple example but there are times where you might want to split the content across multiple dialogs or into a richer experience. We'll cover this next.

Lesson 3 - Multichannel Offers within Bots with AEM Experience Fragments & Dynamic Media

Objective

  1. Understanding Structured Content Fragments.
  2. Taking advantage of Experience Fragments & Dynamic Media Smart Crop
  3. Updating our bot project to use Experience Fragments.

Lesson Context

So far we've used simple content fragments to manage bot responses, but they've fairly basic. In this lesson we'll take advantage of both Structured Content Fragments & Experience Fragments to enhance our bot.

Exercise 3.1 - Understanding Structured Content Fragments

  1. Log into AEM
  2. Navigate to wefinance/en/offers or open http://localhost:4502/assets.html/content/dam/wefinance-apac/en/offers
  3. Open Offer "999 - Bonus Rewards Points"
    1. This is an example of a Structured Content Fragment
    2. It allows you to create a number of items with the same schema / model
  4. Investigate the Content Fragment Model
    1. Navigate to Tools -> Assets -> Content Fragment Models -> weFinance APAC or open http://localhost:4502/libs/dam/cfm/models/console/content/models.html/conf/wefinance-apac

    2. Click on "Credit Card" model and select Edit. CF Content in Chatbot

      You can use these models to define the structure of content so Content Authors can easily create & edit content, and developers can consume it with predictable format.

      Each field will have a Property Name. AEM will use this as the element name in the JSON output for each fragment.

  5. Open Postman
    1. Run the "AEM: Get Content Fragment Offer" example
    2. Postman will show the output of the content at http://localhost:4503/api/assets/wefinance-apac/en/offers/999.json Postman Example
    3. See how the content is output in the structure defined like the model specified above.

Exercise 3.2 - Taking advantage of Experience Fragments & Dynamic Media Smart Crop

The JSON output is great, but what if you want to process the data in advance and/or change the generated schema? Lets take a look at one possible option.

  1. Open Experience Fragment for Offer 999

    1. Navigate to Experience Fragments -> weFinance -> Offers -> English -> 999 - Bonus Rewards -> Web-Hero or click http://localhost:4502/editor.html/content/experience-fragments/wefinance/offers/en/999/master.html

      XF Example

  2. Look at the different variations

    1. Here you can see an example of using Experience Fragments for content displayed across many different channels, including Chatbots.
    2. Click on Chat Bot variation
    3. Note that the Content Fragment component is being used here. We arent using the generated HTML, but its good for an Author to visualise how it will appear.
    4. Click to edit the component and notice that its pointing to the Master variation
    5. Optional: Go back to the 999 Offer Content Fragment and create a Chatbot variation, change the CTA (Call to Action) and then select the variation here. CF Component Example
  3. Note the Smart Crops coming from Dynamic Media (we'll look at that in more detail in a moment, but notice that the image crop is different for chat than other fragment variations)

  4. Open Postman

    1. Run the "AEM: Get Experience Fragment" example

    2. Postman will show the output of the content at http://localhost:4503/content/experience-fragments/wefinance/offers/en/999/chat.model.json

    3. Note that the JSON output is different to the previous Content Fragment examples Postman Example

      Experience Fragments & Content Services together provide a lot of options for producing content in different ways. In this case we are using Sling Model Exporter to change the output. You can use this method to shape the output from AEM conform to the desired output.

      For more information look here: https://helpx.adobe.com/experience-manager/kt/platform-repository/using/sling-model-exporter-tutorial-develop.html

      For an example showing how this demo was built, see snippets -> otherexamplecode -> ExperienceFragmentModel.java

Exercise 3.3 - Using Dynamic Media & Smart Crop.

  1. Notice the Dynamic Media property within the JSON

  2. Open http://s7ap1.scene7.com/is/image/adobeanz/AdobeStock_133030795 in your browser

  3. This is the default image served by AEM Dynamic Media

    Dynamic Media Example

  4. The Smart Crop feature allows you to define crop points that can be called as needed.

    1. Append ":chatbot" to the image url.
    2. Note that the result is now cropped in a square, but centered around the content and exactly the size needed for the bot.

    Smart Crop Example

  5. You can see how this defined here: http://localhost:4502/libs/dam/gui/content/s7dam/smartcrop/smartcropedit.html/content/dam/wefinance-apac/en/stock/AdobeStock_133030795.jpeg

    Smart Crop Management

    Our Sling Model Exporter from Exercise 3.2 automatically looks for the image asset linked in the content fragment, and if its dynamic, adds the dynamic media value to the JSON output.

Exercise 3.4 - Updating our bot project to use Experience Fragments.

  1. Open or switch back to Visual Studio Code

  2. Paste in the following code (from snippets/ex3.4.2.js) below your existing intent

  3. Run the Bot (if it's already running, type Control-C to quit)

  4. Open the emulator

  5. Type in "offer"

  6. You should see a single line response displaying our offer.

    Text Based Offer

    It works, but hardly a compelling experience, so lets switch it out with a Rich Card.

  7. Switch back to Visual Studio Code.

  8. Paste in the following code (from snippets/ex3.4.8.js) below your existing intent

  9. Run the Bot (if it's already running, type Control-C to quit)

  10. Open the emulator & type in "card"

    Card Offer

    We now have a way to bring the same content used across other channels directly into our chatbot, and leveraging Smart Crop to ensure the images are sized accordingly!

Lesson 4 - Advanced Bot Dialog Management within AEM

Objective

  1. Exploring a new technique of managing dynamic bots with related content fragments
  2. Updating our bot project to use Experience Fragments.
  3. Creating and deploying new bot content without touching code.

Lesson Context

Have new content and can't wait for a code release? In this lesson we'll use a technique to use Content Fragments to not only manage content, but also utterances (the keywords that trigger the bot) as well as conversation flow.

It's worth noting that the following is using custom code within the bot, but no customization of AEM is required beyond building / importing some Content Fragment models.

Exercise 4.1 - Updating our code to leverage Dynamic Bot content

  1. Open or switch back to Visual Studio Code

  2. Paste in the code from (snippets/ex4.1.2.js) just before the last '}' at the bottom of bot.js

    This code is calling an AEM Dialog Helper, calling Content Fragments like before, however these Content Fragments have a different structure than the last section, which we can use to build a dynamic bot experience.

  3. Paste in the code from (snippets/ex4.1.3.js) just after the line "class MyBot {" towards the top of bot.js

    This code is nothing really to do with AEM, but was left out to simplify the code in previous steps. It is setting up the bot to understand the state of both the conversation, and properties of the user.

  4. Paste in the intent code from (snippets/ex4.1.4.js) just below the last Card Offer Intent code from Exercise 3.4

    This code takes the Content Fragment output and converts it into a series of Bot Framework dialogs.

  5. Finally, paste in the code from (snippets/ex4.1.5.js) just below the line that reads var ECID = "labuser"; which should be close to line 23.

    This code takes the Content Fragment output and converts it into a series of Bot Framework dialogs.

  6. Run the Bot (if it's already running, type Control-C to quit)

Exercise 4.2 - Interacting with a Dynamic Bot

  1. Open the emulator

  2. Type in "hey"

  3. You should be greated with the response "Hi there. I'd like to get to know you. What's your first name?"

  4. Enter your name

  5. You will be asked "Business or Personal"

  6. Enter Business or Personal

    Note that for simplicity we are expecting the user to type in the response. In a real bot you might consider using a Choice Prompt that the user can just select.

  7. You will be asked what type of service you are interested in.

  8. Enter a value - eg "Loans".

  9. You will be given a summary of the interaction.

    Dynamic Dialog

  10. Type "offer"

  11. Note that the existing bot functionality still works.

  12. Type "info"

  13. You will be given a summary of what you have already shared.

Exercise 4.3 - Exploring Chatbot Management within AEM.

  1. Log into AEM

  2. Navigate to Assets -> weFinance -> English -> Chatbot -> Dialogs or http://localhost:4502/assets.html/content/dam/wefinance-apac/en/chatbot/dialogs

  3. Open up "Welcome" Content Fragment

    Here you can see a number of "utterances" - phrases you can utter, to invoke a function. When we typed "hey" in Exercise 4.2.2 above, our bot knew how to response based on this.

    Below the utterances is a series of Steps that should be executed when a user invokes this Dialog.

  4. Close the Content Fragment and open up the "Welcome Name" fragment.

    Here you can see various properties that define the user experience. Dialog Kind is the type of prompt, Message is fairly obvious, and "name" is where the Bot will store the response. You can get more detail by clicking on the 'i' on each field.

  5. Open "Welcome - Result" Content Fragment

    Here you can see how a user property (name & accountype are examples here) can can be inserted into the message using the {{property}} format.

Lesson 5 - Personalised Bots with Adobe Target

Objective

  1. Exporting AEM Content as JSON to Adobe Target
  2. Calling Adobe Target from a bot programatically
  3. Experiencing an exciting personalised experience!

Lesson Context

At this stage we have a great dynamic bot that content authors can manage without relying on development cycles, and provide rich responses via Experience Fragments. In this final section we'll use Adobe Target to personalise the content delivered depending on parameters specified or collected during the dialog.

Exercise 5.1 - Publishing Experience Fragments as JSON to Adobe Target

  1. AEM 6.5 extends the Experience Fragment / Target integration by offering support for JSON in addition to HTML.

    You may have noticed the green JSON status previously when editing the fragments

    JSON Export

    This is a new enhancement in AEM 6.5 and is configured in the properties of the parent Experience Fragment as follows;

    JSON Export

    Due to the lab restrictions, we wont be using this live, but you watch this video of AEM -> Target to get more detail.

    Video of AEM + Target integration

  2. Open Postman

  3. Run the "Target: Basic Mbox call" example

    This example shows you the output of the direct call from Target. Note the Experience Fragment JSON output. This is the default response from the Target activity.

  4. Log into Adobe Target

    1. Go to https://fsilab.experiencecloud.adobe.com/content/mac/fsilab/target/activities.html

    2. Username: mszulc+lab05@adobetest.com

    3. Password: summit

    4. Click on the "Chatbot Example" activity.

      Target UI

      NOTE: Please do not change this.. the whole lab is using the same setup.

  5. Note the link to Business Account User audience

    Target Audience

Exercise 5.2 - Updating our bot project to use Adobe Target

  1. Open or switch back to Visual Studio Code

  2. Paste in the code from (snippets/ex5.2.2.js) just below the first couple of Intents in your code.

  3. Run the Bot (if it's already running, type Control-C to quit)

  4. Switch to the Bot Emulator

  5. Type "target". You should see a Rich Card with content from the AEM Experience Fragment. While it looks identical, the content is coming from Target instead of AEM.

    Target Offer

Exercise 5.3 - Providing context to influence the content decision.

Its time to put everything together...

  1. Type in "hey" and follow the prompts.

  2. Enter your name, and on the next prompt select "Business"

  3. Enter the last value with any value you want (its not used in this example

  4. type "target"

    Target Offer

    Adobe Target is sent the profileParameter "accounttype" which is currently set to "Business" based on our input. Target makes a decision and sends back the "Business" offer.. in this case Fragment 996.

Next Steps

Congrats! You got through the content!

Sad? Have no fear.. there is more content available on this topic at the following links

Additional Resources

Check out my blog. I'll add additional links / content here when time permits http://www.markszulc.com/adobe-summit-2019-lab-729/

Appendix

Microsoft Bot Framework - https://dev.botframework.com/

Experience Manager docs - https://helpx.adobe.com/support/experience-manager/6-5.html

Target API docs - http://developers.adobetarget.com/