Do you have hard time to decide which one to go with, when shopping online for a new headphone? See a cool commercial for a smart home device, but do not know whether it fits your need? With Expert Review skill, you would get helps from expert's opinion right way.
Expert Review is a custom Alexa Skill, which is available to Alexa-enabled device users. (Yes, it passed certification review and is published!) Just ask Alexa 'Get a review for Bose QuietComfort 35', the expert review is on its way.
And give it a try: http://alexa.amazon.com/spa/index.html#skills/dp/B01N1REAXI/?ref=skill_dsk_skb_sr_0
Part 1 Design the Voice InterfaceAs users are going to look for review of any products, an Intent that can accept free-form text is defined in the Intent Schema as below:
{
"intents": [
{
"intent": "ProductReviewSearchIntent",
"slots": [
{
"name": "Product",
"type": "LIST_OF_PRODUCTS"
}
]
}
]
}
Intent "ProductReviewSearchIntent" has the sample utterance:
ProductReviewSearchIntent Get review for {Product}
The custom slot type "LIST_OF_PRODUCTS" is a placeholder that can be mapped to the products that users mentioned in their requests. In order to make the free-form text custom slot work, a custom slot value file should be included too, although it is good enough to have only one sample product.
Part 2 Interaction flow chart- Welcome message once Alexa opens the custom skill
- After users ask for a review of a certain product, Alexa will ask to confirm if the found product is the one that user wants to hear the review of
- Then, follow the product review summary, including rating and MSRP.
- The good, the bad and the bottom about the product will be told after the summary
- If users are still interested and they want to learn more about the review, a card with review detail can be sent to Alexa app
Also, as shown on the chart, the skill also provides help for each step with step specific hint.
Part 3 Write a Conversational Custom SkillAs you can see in the flow chart, the entire flow has more steps than some Alexa built-in skills. Thus being aware of the context and maintaining the conversation are key to write this custom skill.
With the help of Session class provided by Alexa skill SDK, it makes the job much easier. A Session object will be sent with the normal intent request, shown as below:
SpeechletResponse onIntent(IntentRequest request, Session session) throws SpeechletException;
Session class has defined a set of methods to allow developer to have the control on the conversation context data, including attributes that are available through the entire session until the session is ended, and also sessionId, application and current user.
/** * Returns the session Id. * * @return a unique identifier for the session */
public String getSessionId() {
return sessionId;
}
/** * Returns the application. * * @return the application */
public Application getApplication() {
return application;
}
/** * Returns all the session attributes. * * @return a mutable map of all the attributes that may be altered directly */
@JsonInclude(Include.NON_EMPTY)
public Map<String, Object> getAttributes() {
return attributes;
}
/** * Returns the attribute associated with the provided name. * * @param name
* the name of the attribute to retrieve * @return the value or {@code null} */
public Object getAttribute(final String name) {
return attributes.get(name);
}
/** * Add or modify the attribute with the provided name. * * @param name
* the name of the attribute to set * @param value
* the new value for the attribute */
public void setAttribute(final String name, final Object value) {
attributes.put(name, value);
}
/** * Remove the attribute associated with the provided name. * * @param name
* the name of the attribute to remove */
public void removeAttribute(final String name) {
attributes.remove(name);
}
/** * Returns the user associated with this session. * * @return the user */
public User getUser() {
return user;
}
Here is the snippet of code that I use the session attribute to control what to response for each step within the session:
final String state = getSessionAttribute(session, SESSION_FLOW_STATE, String.class);
StringBuilder responseString = new StringBuilder();
switch (state) {
case STATE_REVIEW_SEARCH_FIRST_HIT:
responseString.append("Please say 'Yes' or 'No' to confirm whether or not ");
....
responseString.append("?");
return newAskResponse(session, responseString.toString(), false, null, false);
case STATE_REVIEW_SEARCH_SUMMARY:
final String highlightBreak = "<break strength='medium'/>";
responseString.append("<speak>");
responseString.append("<s>Please say 'Yes' or 'No' to confirm if you want to learn the basis on ");
....
responseString.append("</speak>");
return newAskResponse(session, responseString.toString(), true, null, false);
case STATE_REVIEW_SEARCH_GOOD_BAD_BOTTOMLINE:
responseString.append("Please say 'Yes' or 'No' to confirm whether or not you want to take a peek at the full review. ");
responseString.append("A card will be sent to your Alexa app. ");
....
return newAskResponse(session, responseString.toString(), false, null, false);
default:
return newTellResponse(session, "Not Implemented yet", false, true);
}
Future Fuzzy Product Search and Product PurchaseSometimes, people just hear some exciting description about a certain thing, but don't know the exact name of the product. So if the expert review skill can start from a fuzzy product search, that can be even more useful in our daily life scenarios.
Another feature that could add more value to this skill is the purchase feature. Even though right now the skill tells users about MSRP of the product, and sometimes even the lowest price, it would be better have Amazon one-click purchase integrated. Because reviews, especially experts', can really help to convert a potential buyer to an actual product owner.
Comments