Properly Injected SSML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Creates a {@code SpeechletResponse} for the hello intent. | |
* | |
* @return SpeechletResponse spoken and visual response for the given intent | |
*/ | |
private SpeechletResponse getHelloResponse(Session session) { | |
String speechText = "Hello world"; | |
// Create the Simple card content. | |
SimpleCard card = new SimpleCard(); | |
card.setTitle("HelloWorld"); | |
card.setContent(speechText); | |
SsmlOutputSpeech speech = monetize.injectSSML(session.getUser().getUserId(), | |
"<speak>Hello! And now a word from our sponsor {ad} What would you like to do?</speak>", | |
"<speak>Hello! Tell me something!</speak>") | |
.asSsmlOutputSpeech(); | |
return SpeechletResponse.newTellResponse(speech, card); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void onSessionStarted(final SessionStartedRequest request, final Session session) | |
throws SpeechletException { | |
log.info("onSessionStarted requestId={}, sessionId={}", request.getRequestId(), | |
session.getSessionId()); | |
monetize.prime(session.getUser().getUserId()); | |
// any initialization logic goes here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "1.0", | |
"response": { | |
"outputSpeech": { | |
"type": "SSML", | |
"ssml": "<speak>Hello! And now a word from our sponsor <audio src=\"https://s3.amazonaws.com/bespoken-monetization/30-seconds-spot-encoded.mp3\" /><audio src=\"https://monetization.bespoken.tools/v1/track?requestID=d42a4120-fe95-11e6-a1dc-35c4036ba0ea\" /> What would you like to do?</speak>" | |
}, | |
"card": { | |
"type": "Simple", | |
"title": "HelloWorld", | |
"content": "Hello world" | |
}, | |
"shouldEndSession": true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment