Switch to BEAST mode
Rampage through code/test iterations for Alexa and Lambda development
This an Early Access version of our bst tools for Java. It provides:
- Logging
- Monetization
To include in a Maven project, add the following to your pom.xml:
<dependency>
<groupId>tools.bespoken</groupId>
<artifactId>bst4j</artifactId>
<version>RELEASE</version>
</dependency>
More details to come.
compile 'tools.bespoken:bst4j:+'
JavaDocs for Logless are here.
To capture logs from a Speechlet running inside a Lambda, simply call:
public HelloWorldSpeechletRequestStreamHandler() {
super(Logless.capture("<SKILL_KEY>", new HelloWorldSpeechlet()),
supportedApplicationIds);
}
This constructor wraps the creation of the Speechlet before it is passed to the Lambda handler.
An example can be found in our bst4jSample project here
To capture logs from a Speechlet running inside a Java servlet (i.e., as a standalone server), simply call:
Speechlet wrapper = Logless.capture("<SKILL_KEY>",
new HelloWorldSpeechlet());
context.addServlet(new ServletHolder(createServlet(wrapper)), "/");
An example can be found in our bst4jSample project here.
JavaDocs for BSTMonetize are here.
To use it, first call BSTMonetize.prime(<USER_ID>). This pre-fetches an ad for playback. This should be done on the first request.
Then call BSTMonetize.injectSSML:
BSTMonetize monetize = new BSTMonetize("<SKILL_KEY>");
SpeechletResponse.newSpeechletResponse(monetize.injectSSML(session.getUser().getUserId(),
"<speak>Hi! Now a word from our sponsor {ad}! What do you want to do now?</speak>",
"<speak>Hi!What do you want to do now?</speak>")
).asSsmlOutputSpeech(), repromptSpeech, card);
The call to injectSSML will replace the {ad} token with an tag for the advertisement.
If no ad is available to be served, the fallback SSML (the second parameter) will be used.
Notice that we use different wording for the example with an ad - it prefaces it with "Now a word from our sponsor." It is not necessary, but is a nice user experience consideration.
Detailed API documentation is at javadoc.io.