A Freeswitch module that connects to AWS Lex using the streaming API.
Once a Freeswitch channel is connected to a Lex bot, media is streamed to Lex, which returns information describing the "intent" that was detected, along with transcriptions and audio prompts and text to play to the caller. The handling of returned audio by the module is two-fold:
- If an audio clip was returned, it is not immediately played to the caller, but instead is written to a temporary file on the Freeswitch server.
- Next, a Freeswitch custom event is sent to the application containing the details of the dialogflow response as well as the path to the audio file.
This allows the application whether to decide to play the returned audio clip (via the mod_dptools 'play' command), or to use a text-to-speech service to generate audio using the returned prompt text.
The freeswitch module exposes the following API commands:
aws_lex_start <uuid> botId aliasId region locale [welcome-intent]
Attaches media bug to channel and performs streaming recognize request.
uuid
- freeswitch channel uuidbot
- name of Lex botalias
- alias of Lex botregion
- AWS region name (e.g 'us-east-1')locale
- AWS language to use for speech recognition (e.g. 'en-US')welcome-intent
- name of intent to trigger initially
aws_lex_dtmf <uuid> dtmf-entry
Notify Lex of a dtmf entry
aws_lex_play_done <uuid>
Notify Lex that an audio prompt has completed playing. The application needs to call this if barge-in is enabled.
aws_lex_stop <uuid>
Stop dialogflow on the channel.
ACCESS_KEY_ID
- AWS access key id to use to authenticate; if not provided an environment variable of the same name is used if providedSECRET_ACCESS_KEY
- AWS secret access key to use to authenticate; if not provided an environment variable of the same name is used if providedLEX_WELCOME_MESSAGE
- text for a welcome message to play at audio startx-amz-lex:start-silence-threshold-ms
- no-input timeout in milliseconds (Lex defaults to 4000 if not provided)
lex::intent
- an intent has been detected.lex::transcription
- a transcription has been returnedlex::text_response
- a text response has been returned; the telephony application can play this using text-to-speech if desired.lex::audio_provided
- an audio response (.mp3 format) has been returned; the telephony application can play this file if TTS is not being usedlex::text_response
- a text response was provided.lex::playback_interruption
- the caller has spoken during prompt playback; the telephony application should kill the current audio promptlex::error
- dialogflow has returned an error
When using drachtio-fsrmf, you can access this API command via the api method on the 'endpoint' object.
ep.api('aws_lex_start', `${ep.uuid} BookTrip Gamma us-east-1`);
See drachtio-lex-gateway.