Integrating Handlebars templates
This solution supports the
Handlebars
-
From the content designer, choose Add.
-
Enter ID:
Handlebars.001
-
Enter question:
What is my interaction count?
-
Enter answer:
So far, you have interacted with me {{UserInfo.InteractionCount}} times.
-
-
Save the new item.
-
Use the web UI, or any Alexa device to say, “What is my interaction count?” to your chatbot, and listen to it respond.
-
Ask a few more questions, and then ask “What is my interaction count?” again. Notice that the value has increased.
-
From the content designer, edit item
Handlebars.001
-
Modify the answer to:
So far, you have interacted with me {{UserInfo.InteractionCount}} times. {{#ifCond UserInfo.TimeSinceLastInteraction '>' 60}} It’s over a minute since I heard from you last.. I almost fell asleep! {{else}} Keep those questions coming fast.. It’s been {{UserInfo.TimeSinceLastInteraction}} seconds since your last interaction. {{/ifCond}}
-
Use the web UI, or Alexa, to interact with the chatbot again. Wait over a minute between interactions and observe the conditional answer in action.
There’s a lot more that you can do with Handlebars, such as
randomly selecting content from a list, setting and accessing
session attributes, and generating Amazon S3 presigned URLs. For
more information see the
Handlebars