maxbeckers/amazon-alexa-bundle

Symfony Bundle for amazon alexa skills.

Installs: 1 845

Dependents: 0

Suggesters: 0

Security: 0

Stars: 12

Watchers: 2

Forks: 2

Open Issues: 1

Type:symfony-bundle

1.2.0 2022-10-21 12:12 UTC

This package is auto-updated.

Last update: 2024-10-25 11:34:42 UTC


README

This bundle is a simlpe helper to create an Amazon Echo (Alexa) endpoint to your symfony project. You only need to add the Bundle to your project and create some handlers for the alexa requests, configured in amazon alexa backend.

Install via composer

Require the bundle via composer:

composer require maxbeckers/amazon-alexa-bundle

Enable Routing

Then add the Bundle endpoint for alexa to config/routes.yaml.

# config/routes.yaml
maxbeckers_amazon_alexa:
    path:     /alexa/ # the url, the alexa endpoint should be available 
    defaults: { _controller: MaxBeckers\AmazonAlexaBundle\Controller\AmazonAlexa::amazonRequest }

Create handlers

To add Handlers for alexa, create them as a service and tag them with maxbeckers_amazon_alexa.request_handler. How to create a handler see maxbeckers/amazon-alexa-php.

services:
    example.my_handler:
        class: Example\MyIntentHandler
        arguments:
            - '@maxbeckers_amazon_alexa.response_helper' # ResponseHelper
        tags:
            - 'maxbeckers_amazon_alexa.request_handler'

Generate ssml

For ssml use the maxbeckers_amazon_alexa.ssml_generator service to create valid ssml.

$ssmlGenerator = $this->get('maxbeckers_amazon_alexa.ssml_generator');

// add a message
$ssmlGenerator->say('Hallo World');
$ssml = $ssmlGenerator->getSsml();
// $ssml === '<speak>Hallo World</speak>'