Skip to main content

Connecting Amazon Alexa to JAICF project

tip
Amazon Alexa — is a voice assistant that can be used on Amazon Echo devices.

Alexa Skill — is an app that the user can activate using the voice and then can interact with Amazon Echo devices. For more details on Alexa Skills, see the official Amazon website.

To connect the Amazon Alexa channel to the JAICF project, please follow these steps:

  1. Prepare the project.
  2. Create a channel.
  3. Register a skill.
  4. Test the skill.
  5. Publish the skill.

Prepare the project

Before connecting the channel, prepare the JAICF project in advance:

  1. Specify the following in the dependencies of build.gradle.kts file:
dependencies {
// ...
implementation("com.just-ai.jaicf:jaicp:$jaicfVersion")
implementation("com.just-ai.jaicf:alexa:$jaicfVersion")
}
tip
Don’t forget to substitute $jaicfVersion with the latest framework version.
  1. Configure depending on the connection method to the platform:
  • long polling — the bot will connect to the Just AI server when interacting with the platform. Simple solution, convenient for local development and debugging.

    For this method, specify the channel AlexaChannel in the JaicpPoller.kt file:

package com.just-ai.jaicf.template.connections

fun main() {
JaicpPollingConnector(
templateBot,
accessToken,
channels = listOf(
ChatApiChannel,
ChatWidgetChannel,
TelephonyChannel,
AlexaChannel
)
).runBlocking()
}
  • webhook — the bot will receive messages from the platform using the specified link. Must be configured to connect JAICP Cloud.

    For this method, specify the channel AlexaChannel in the JaicpServer.kt file:

package com.just-ai.jaicf.template.connections

fun main() {
JaicpServer(
botApi = templateBot,
accessToken = accessToken,
channels = listOf(
ChatApiChannel,
ChatWidgetChannel,
TelephonyChannel,
AlexaChannel
)
).start(wait = true)
}

Create a channel

Open the JAICF project on JAICP. Go to the Channels tab on the side panel, then click Inbound → Connect channel. In the Voice Assistants section, choose Alexa. Specify the channel name and click Create.

Click Get webhook under the name of the newly created channel. It will be copied to the clipboard. The copied webhook will be needed later when configuring the skill.

Register a skill

tip
To make your skill available for Alexa’s users, you need to have an Amazon Developer account.

Create a new skill

Sign in to the Alexa Developer Console. To create the skill in the developer console, click Create skill, and specify the following parameters:

  • Skill name — skill name for the catalog.
  • Default language — the default language to use. You can add additional languages support after creating the skill.
  • Choose Custom as an interaction model, and Provision your own as a location.

Click Create skill. Select Start from scratch to create a new blank skill.

Configure the skill

Click Invocation on the left panel. Choose the invocation name in the field Skill Invocation Name. It will be used to launch a skill.

Then click Endpoint on the left panel. Choose HTTPS as a Service Endpoint Type, and then fill in the fields:

  • Default Region — fill in the webhook that was copied to the clipboard when creating the channel.
  • Choose My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority as an SSL certificate.

Click Save Endpoints.

Click Build on the upper panel → then click Build Model.

Test the skill

To test the skill, click Test on the upper panel, choose Development in the field Skill testing is enabled in. You can also use the Echo device for testing.

tip
You need to wait for the skill to be activated. The waiting time can be up to 5 minutes.

Publish the skill

While you are testing a skill, it is only available to you. To make it available to other users, you need to do the following:

  • Go to the Distribution tab.
  • Submit skill data and submit it for moderation to Amazon.

After the skill is moderated, it will become available to all users.