A Freeswitch module that connects a Freeswitch channel to a dialogflow agent so that an IVR interaction can be driven completely by dialogflow logic.
Once a Freeswitch channel is connected to a dialogflow agent, media is streamed to the dialogflow service, 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 wave 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 wave 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:
dialogflow_start <uuid> <project-id> <lang-code> [<timeout-secs>] [<event>]
Attaches media bug to channel and performs streaming recognize request.
uuid
- unique identifier of Freeswitch channelproject-id
- the identifier of the dialogflow project to executelang-code
- a valid dialogflow language tag to use for speech recognitiontimeout-secs
- number of seconds to wait for an intent to be returned; default 30 secs. (Note: timeout behavior is currently not implemented)event
- name of an initial event to send to dialogflow; e.g. to trigger an initial prompt
dialogflow_stop <uuid>
Stop dialogflow on the channel.
dialogflow::intent
- a dialogflow intent has been detected.dialogflow::transcription
- a transcription has been returneddialogflow::audio_provided
- an audio prompt has been returned from dialogflow. Dialogflow will return both an audio clip in linear 16 format, as well as the text of the prompt. The audio clip will be played out to the caller and the prompt text is returned to the application in this event.dialogflow::end_of_utterance
- dialogflow has detected the end of an utterancedialogflow::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('dialogflow_start', `${ep.uuid} my-project-id en-US 30 welcome`);