Skip to content

raseidl/bst4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BST

Switch to BEAST mode
Rampage through code/test iterations for Alexa and Lambda development

Build Status Codecov Javadocs


This an Early Access version of our bst tools for Java. It provides:

  • Logging
  • Monetization

Getting Started

Maven

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.

Gradle

compile 'tools.bespoken:bst4j:+'

Logless

JavaDocs for Logless are here.

Logless Lambda

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

Logless Servlet

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.

BSTMonetize

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.

Reference

Detailed API documentation is at javadoc.io.

About

☕ Bespoken Tools for Java

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages