This commit is contained in:
Dave Horton
2024-08-16 08:36:15 -04:00
parent 20bdcb6687
commit ec00c91c0c
8 changed files with 424 additions and 611 deletions

View File

@@ -2,7 +2,7 @@ include $(top_srcdir)/build/modmake.rulesam
MODNAME=mod_dialogflow_cx
mod_LTLIBRARIES = mod_dialogflow_cx.la
mod_dialogflow_cx_la_SOURCES = mod_dialogflow.c google_glue.cpp parser.cpp
mod_dialogflow_cx_la_SOURCES = mod_dialogflow_cx.c parser.cpp google_glue.cpp
mod_dialogflow_cx_la_CFLAGS = $(AM_CFLAGS)
mod_dialogflow_cx_la_CXXFLAGS = -I $(top_srcdir)/libs/googleapis/gens $(AM_CXXFLAGS) -std=c++17

View File

@@ -1,5 +0,0 @@
<configuration name="dialogflow.conf" description="Google Dialogflow Configuration">
<settings>
<param name="google-application-credentials-json-file" value="/tmp/gcs_service_account_key.json"/>
</settings>
</configuration>

View File

@@ -16,20 +16,20 @@
#include "google/cloud/dialogflow/cx/v3/session.grpc.pb.h"
#include "mod_dialogflow.h"
#include "mod_dialogflow_cx.h"
#include "parser.h"
using google::cloud::dialogflow::v2beta1::Sessions;
using google::cloud::dialogflow::v2beta1::StreamingDetectIntentRequest;
using google::cloud::dialogflow::v2beta1::StreamingDetectIntentResponse;
using google::cloud::dialogflow::v2beta1::AudioEncoding;
using google::cloud::dialogflow::v2beta1::InputAudioConfig;
using google::cloud::dialogflow::v2beta1::OutputAudioConfig;
using google::cloud::dialogflow::v2beta1::SynthesizeSpeechConfig;
using google::cloud::dialogflow::v2beta1::QueryInput;
using google::cloud::dialogflow::v2beta1::QueryResult;
using google::cloud::dialogflow::v2beta1::StreamingRecognitionResult;
using google::cloud::dialogflow::v2beta1::EventInput;
using google::cloud::dialogflow::cx::v3::Sessions;
using google::cloud::dialogflow::cx::v3::StreamingDetectIntentRequest;
using google::cloud::dialogflow::cx::v3::StreamingDetectIntentResponse;
using google::cloud::dialogflow::cx::v3::AudioEncoding;
using google::cloud::dialogflow::cx::v3::InputAudioConfig;
using google::cloud::dialogflow::cx::v3::OutputAudioConfig;
using google::cloud::dialogflow::cx::v3::SynthesizeSpeechConfig;
using google::cloud::dialogflow::cx::v3::QueryInput;
using google::cloud::dialogflow::cx::v3::QueryResult;
using google::cloud::dialogflow::cx::v3::StreamingRecognitionResult;
using google::cloud::dialogflow::cx::v3::EventInput;
using google::rpc::Status;
using google::protobuf::Struct;
using google::protobuf::Value;
@@ -51,7 +51,7 @@ static switch_status_t hanguphook(switch_core_session_t *session) {
std::string filename = it->second;
std::remove(filename.c_str());
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
"google_dialogflow_session_cleanup: removed audio file %s\n", filename.c_str());
"google_dialogflow_cx_session_cleanup: removed audio file %s\n", filename.c_str());
}
audioFiles.erase(sessionId);
switch_core_event_hook_remove_state_change(session, hanguphook);
@@ -342,13 +342,13 @@ static void *SWITCH_THREAD_FUNC grpc_read_thread(switch_thread_t *thread, void *
if (response.has_query_result() || response.has_recognition_result()) {
cJSON* jResponse = parser.parse(response) ;
char* json = cJSON_PrintUnformatted(jResponse);
const char* type = DIALOGFLOW_EVENT_TRANSCRIPTION;
const char* type = DIALOGFLOW_CX_EVENT_TRANSCRIPTION;
if (response.has_query_result()) type = DIALOGFLOW_EVENT_INTENT;
if (response.has_query_result()) type = DIALOGFLOW_CX_EVENT_INTENT;
else {
const StreamingRecognitionResult_MessageType& o = response.recognition_result().message_type();
if (0 == StreamingRecognitionResult_MessageType_Name(o).compare("END_OF_SINGLE_UTTERANCE")) {
type = DIALOGFLOW_EVENT_END_OF_UTTERANCE;
type = DIALOGFLOW_CX_EVENT_END_OF_UTTERANCE;
}
}
@@ -394,7 +394,7 @@ static void *SWITCH_THREAD_FUNC grpc_read_thread(switch_thread_t *thread, void *
cJSON_AddItemToObject(jResponse, "path", cJSON_CreateString(s.str().c_str()));
char* json = cJSON_PrintUnformatted(jResponse);
cb->responseHandler(psession, DIALOGFLOW_EVENT_AUDIO_PROVIDED, json);
cb->responseHandler(psession, DIALOGFLOW_CX_EVENT_AUDIO_PROVIDED, json);
free(json);
cJSON_Delete(jResponse);
}
@@ -404,7 +404,7 @@ static void *SWITCH_THREAD_FUNC grpc_read_thread(switch_thread_t *thread, void *
break;
}
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dialogflow read loop is done\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dialogflow_cx read loop is done\n");
// finish the detect intent session: here is where we may get an error if credentials are invalid
switch_core_session_t* psession = switch_core_session_locate(cb->sessionId);
@@ -429,7 +429,7 @@ static void *SWITCH_THREAD_FUNC grpc_read_thread(switch_thread_t *thread, void *
}
extern "C" {
switch_status_t google_dialogflow_init() {
switch_status_t google_dialogflow_cx_init() {
const char* gcsServiceKeyFile = std::getenv("GOOGLE_APPLICATION_CREDENTIALS");
if (NULL == gcsServiceKeyFile) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
@@ -441,12 +441,12 @@ extern "C" {
return SWITCH_STATUS_SUCCESS;
}
switch_status_t google_dialogflow_cleanup() {
switch_status_t google_dialogflow_cx_cleanup() {
return SWITCH_STATUS_SUCCESS;
}
// start dialogflow on a channel
switch_status_t google_dialogflow_session_init(
switch_status_t google_dialogflow_cx_session_init(
switch_core_session_t *session,
responseHandler_t responseHandler,
errorHandler_t errorHandler,
@@ -510,7 +510,7 @@ extern "C" {
return status;
}
switch_status_t google_dialogflow_session_stop(switch_core_session_t *session, int channelIsClosing) {
switch_status_t google_dialogflow_cx_session_stop(switch_core_session_t *session, int channelIsClosing) {
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_media_bug_t *bug = (switch_media_bug_t*) switch_channel_get_private(channel, MY_BUG_NAME);
@@ -519,21 +519,21 @@ extern "C" {
switch_status_t st;
// close connection and get final responses
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "google_dialogflow_session_cleanup: acquiring lock\n");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "google_dialogflow_cx_session_cleanup: acquiring lock\n");
switch_mutex_lock(cb->mutex);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "google_dialogflow_session_cleanup: acquired lock\n");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "google_dialogflow_cx_session_cleanup: acquired lock\n");
GStreamer* streamer = (GStreamer *) cb->streamer;
if (streamer) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "google_dialogflow_session_cleanup: sending writesDone..\n");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "google_dialogflow_cx_session_cleanup: sending writesDone..\n");
streamer->writesDone();
streamer->finish();
}
if (cb->thread) {
switch_status_t retval;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "google_dialogflow_session_cleanup: waiting for read thread to complete\n");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "google_dialogflow_cx_session_cleanup: waiting for read thread to complete\n");
switch_thread_join(&retval, cb->thread);
cb->thread = NULL;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "google_dialogflow_session_cleanup: read thread completed\n");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "google_dialogflow_cx_session_cleanup: read thread completed\n");
}
killcb(cb);
@@ -541,7 +541,7 @@ extern "C" {
if (!channelIsClosing) switch_core_media_bug_remove(session, &bug);
switch_mutex_unlock(cb->mutex);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "google_dialogflow_session_cleanup: Closed google session\n");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "google_dialogflow_cx_session_cleanup: Closed google session\n");
return SWITCH_STATUS_SUCCESS;
}
@@ -550,7 +550,7 @@ extern "C" {
return SWITCH_STATUS_FALSE;
}
switch_bool_t google_dialogflow_frame(switch_media_bug_t *bug, void* user_data) {
switch_bool_t google_dialogflow_cx_frame(switch_media_bug_t *bug, void* user_data) {
switch_core_session_t *session = switch_core_media_bug_get_session(bug);
uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
switch_frame_t frame = {};
@@ -577,13 +577,13 @@ extern "C" {
}
else {
//switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
// "google_dialogflow_frame: not sending audio because google channel has been closed\n");
// "google_dialogflow_cx_frame: not sending audio because google channel has been closed\n");
}
switch_mutex_unlock(cb->mutex);
}
else {
//switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
// "google_dialogflow_frame: not sending audio since failed to get lock on mutex\n");
// "google_dialogflow_cx_frame: not sending audio since failed to get lock on mutex\n");
}
return SWITCH_TRUE;
}

View File

@@ -1,12 +1,12 @@
#ifndef __GOOGLE_GLUE_H__
#define __GOOGLE_GLUE_H__
switch_status_t google_dialogflow_init();
switch_status_t google_dialogflow_cleanup();
switch_status_t google_dialogflow_session_init(switch_core_session_t *session, responseHandler_t responseHandler, errorHandler_t errorHandler,
switch_status_t google_dialogflow_cx_init();
switch_status_t google_dialogflow_cx_cleanup();
switch_status_t google_dialogflow_cx_session_init(switch_core_session_t *session, responseHandler_t responseHandler, errorHandler_t errorHandler,
uint32_t samples_per_second, char* lang, char* projectId, char* welcomeEvent, char *text, struct cap_cb **cb);
switch_status_t google_dialogflow_session_stop(switch_core_session_t *session, int channelIsClosing);
switch_bool_t google_dialogflow_frame(switch_media_bug_t *bug, void* user_data);
switch_status_t google_dialogflow_cx_session_stop(switch_core_session_t *session, int channelIsClosing);
switch_bool_t google_dialogflow_cx_frame(switch_media_bug_t *bug, void* user_data);
void destroyChannelUserData(struct cap_cb* cb);
#endif

View File

@@ -1,21 +1,21 @@
/*
*
* mod_dialogflow.c -- Freeswitch module for running a google dialogflow
* mod_dialogflow_cx.c -- Freeswitch module for running a google dialogflow
*
*/
#include "mod_dialogflow.h"
#include "mod_dialogflow_cx.h"
#include "google_glue.h"
#define DEFAULT_INTENT_TIMEOUT_SECS (30)
#define DIALOGFLOW_INTENT "dialogflow_intent"
#define DIALOGFLOW_INTENT_AUDIO_FILE "dialogflow_intent_audio_file"
#define DIALOGFLOW_INTENT "dialogflow_cx_intent"
#define DIALOGFLOW_INTENT_AUDIO_FILE "dialogflow_cx_intent_audio_file"
/* Prototypes */
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dialogflow_shutdown);
SWITCH_MODULE_RUNTIME_FUNCTION(mod_dialogflow_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_dialogflow_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dialogflow_cx_shutdown);
SWITCH_MODULE_RUNTIME_FUNCTION(mod_dialogflow_cx_runtime);
SWITCH_MODULE_LOAD_FUNCTION(mod_dialogflow_cx_load);
SWITCH_MODULE_DEFINITION(mod_dialogflow, mod_dialogflow_load, mod_dialogflow_shutdown, NULL);
SWITCH_MODULE_DEFINITION(mod_dialogflow_cx, mod_dialogflow_cx_load, mod_dialogflow_cx_shutdown, NULL);
static switch_status_t do_stop(switch_core_session_t *session);
@@ -34,7 +34,7 @@ static void errorHandler(switch_core_session_t* session, const char * json) {
switch_event_t *event;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DIALOGFLOW_EVENT_ERROR);
switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, DIALOGFLOW_CX_EVENT_ERROR);
switch_channel_event_set_data(channel, event);
switch_event_add_body(event, "%s", json);
@@ -56,14 +56,14 @@ static switch_bool_t capture_callback(switch_media_bug_t *bug, void *user_data,
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got SWITCH_ABC_TYPE_CLOSE.\n");
google_dialogflow_session_stop(session, 1);
google_dialogflow_cx_session_stop(session, 1);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Finished SWITCH_ABC_TYPE_CLOSE.\n");
}
break;
case SWITCH_ABC_TYPE_READ:
return google_dialogflow_frame(bug, user_data);
return google_dialogflow_cx_frame(bug, user_data);
break;
case SWITCH_ABC_TYPE_WRITE:
@@ -97,7 +97,7 @@ static switch_status_t start_capture(switch_core_session_t *session, switch_medi
projectId, lang, event, text);
switch_core_session_get_read_impl(session, &read_impl);
if (SWITCH_STATUS_FALSE == google_dialogflow_session_init(session, responseHandler, errorHandler,
if (SWITCH_STATUS_FALSE == google_dialogflow_cx_session_init(session, responseHandler, errorHandler,
read_impl.samples_per_second, lang, projectId, event, text, &cb)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error initializing google dialogflow session.\n");
status = SWITCH_STATUS_FALSE;
@@ -128,7 +128,7 @@ static switch_status_t do_stop(switch_core_session_t *session)
if (bug) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Received user command command to stop dialogflow.\n");
status = google_dialogflow_session_stop(session, 0);
status = google_dialogflow_cx_session_stop(session, 0);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "stopped dialogflow.\n");
}
@@ -136,7 +136,7 @@ static switch_status_t do_stop(switch_core_session_t *session)
}
#define DIALOGFLOW_API_START_SYNTAX "<uuid> project-id lang-code [event]"
SWITCH_STANDARD_API(dialogflow_api_start_function)
SWITCH_STANDARD_API(dialogflow_cx_api_start_function)
{
char *mycmd = NULL, *argv[10] = { 0 };
int argc = 0;
@@ -187,7 +187,7 @@ SWITCH_STANDARD_API(dialogflow_api_start_function)
}
#define DIALOGFLOW_API_STOP_SYNTAX "<uuid>"
SWITCH_STANDARD_API(dialogflow_api_stop_function)
SWITCH_STANDARD_API(dialogflow_cx_api_stop_function)
{
char *mycmd = NULL, *argv[10] = { 0 };
int argc = 0;
@@ -224,31 +224,31 @@ SWITCH_STANDARD_API(dialogflow_api_stop_function)
}
/* Macro expands to: switch_status_t mod_dialogflow_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
SWITCH_MODULE_LOAD_FUNCTION(mod_dialogflow_load)
/* Macro expands to: switch_status_t mod_dialogflow_cx_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
SWITCH_MODULE_LOAD_FUNCTION(mod_dialogflow_cx_load)
{
switch_api_interface_t *api_interface;
/* create/register custom event message types */
if (switch_event_reserve_subclass(DIALOGFLOW_EVENT_INTENT) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", DIALOGFLOW_EVENT_INTENT);
if (switch_event_reserve_subclass(DIALOGFLOW_CX_EVENT_INTENT) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", DIALOGFLOW_CX_EVENT_INTENT);
return SWITCH_STATUS_TERM;
}
if (switch_event_reserve_subclass(DIALOGFLOW_EVENT_TRANSCRIPTION) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", DIALOGFLOW_EVENT_TRANSCRIPTION);
if (switch_event_reserve_subclass(DIALOGFLOW_CX_EVENT_TRANSCRIPTION) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", DIALOGFLOW_CX_EVENT_TRANSCRIPTION);
return SWITCH_STATUS_TERM;
}
if (switch_event_reserve_subclass(DIALOGFLOW_EVENT_END_OF_UTTERANCE) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", DIALOGFLOW_EVENT_END_OF_UTTERANCE);
if (switch_event_reserve_subclass(DIALOGFLOW_CX_EVENT_END_OF_UTTERANCE) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", DIALOGFLOW_CX_EVENT_END_OF_UTTERANCE);
return SWITCH_STATUS_TERM;
}
if (switch_event_reserve_subclass(DIALOGFLOW_EVENT_AUDIO_PROVIDED) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", DIALOGFLOW_EVENT_AUDIO_PROVIDED);
if (switch_event_reserve_subclass(DIALOGFLOW_CX_EVENT_AUDIO_PROVIDED) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", DIALOGFLOW_CX_EVENT_AUDIO_PROVIDED);
return SWITCH_STATUS_TERM;
}
if (switch_event_reserve_subclass(DIALOGFLOW_EVENT_ERROR) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", DIALOGFLOW_EVENT_ERROR);
if (switch_event_reserve_subclass(DIALOGFLOW_CX_EVENT_ERROR) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", DIALOGFLOW_CX_EVENT_ERROR);
return SWITCH_STATUS_TERM;
}
@@ -256,21 +256,21 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dialogflow_load)
/* connect my internal structure to the blank pointer passed to me */
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Google Dialogflow API loading..\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Google Dialogflow CX API loading..\n");
if (SWITCH_STATUS_FALSE == google_dialogflow_init()) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed initializing google dialogflow interface\n");
if (SWITCH_STATUS_FALSE == google_dialogflow_cx_init()) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed initializing google dialogflow cx interface\n");
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Google Dialogflow API successfully loaded\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Google Dialogflow CX API successfully loaded\n");
SWITCH_ADD_API(api_interface, "dialogflow_start", "Start a google dialogflow", dialogflow_api_start_function, DIALOGFLOW_API_START_SYNTAX);
SWITCH_ADD_API(api_interface, "dialogflow_stop", "Terminate a google dialogflow", dialogflow_api_stop_function, DIALOGFLOW_API_STOP_SYNTAX);
SWITCH_ADD_API(api_interface, "dialogflow_cx_start", "Start a google dialogflow cx", dialogflow_cx_api_start_function, DIALOGFLOW_API_START_SYNTAX);
SWITCH_ADD_API(api_interface, "dialogflow_CX_stop", "Terminate a google dialogflow cx", dialogflow_cx_api_stop_function, DIALOGFLOW_API_STOP_SYNTAX);
switch_console_set_complete("add dialogflow_stop");
switch_console_set_complete("add dialogflow_start project lang");
switch_console_set_complete("add dialogflow_start project lang timeout-secs");
switch_console_set_complete("add dialogflow_start project lang timeout-secs event");
switch_console_set_complete("add dialogflow_stop_cx");
switch_console_set_complete("add dialogflow_start_cx project lang");
switch_console_set_complete("add dialogflow_start_cx project lang timeout-secs");
switch_console_set_complete("add dialogflow_start_cx project lang timeout-secs event");
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
@@ -279,15 +279,15 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dialogflow_load)
/*
Called when the system shuts down
Macro expands to: switch_status_t mod_dialogflow_shutdown() */
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dialogflow_shutdown)
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dialogflow_cx_shutdown)
{
google_dialogflow_cleanup();
google_dialogflow_cx_cleanup();
switch_event_free_subclass(DIALOGFLOW_EVENT_INTENT);
switch_event_free_subclass(DIALOGFLOW_EVENT_TRANSCRIPTION);
switch_event_free_subclass(DIALOGFLOW_EVENT_END_OF_UTTERANCE);
switch_event_free_subclass(DIALOGFLOW_EVENT_AUDIO_PROVIDED);
switch_event_free_subclass(DIALOGFLOW_EVENT_ERROR);
switch_event_free_subclass(DIALOGFLOW_CX_EVENT_INTENT);
switch_event_free_subclass(DIALOGFLOW_CX_EVENT_TRANSCRIPTION);
switch_event_free_subclass(DIALOGFLOW_CX_EVENT_END_OF_UTTERANCE);
switch_event_free_subclass(DIALOGFLOW_CX_EVENT_AUDIO_PROVIDED);
switch_event_free_subclass(DIALOGFLOW_CX_EVENT_ERROR);
return SWITCH_STATUS_SUCCESS;
}

View File

@@ -1,17 +1,17 @@
#ifndef __MOD_DIALOGFLOW_H__
#define __MOD_DIALOGFLOW_H__
#ifndef __MOD_DIALOGFLOW_CX_H__
#define __MOD_DIALOGFLOW_CX_H__
#include <switch.h>
#include <speex/speex_resampler.h>
#include <unistd.h>
#define MY_BUG_NAME "__dialogflow_bug__"
#define DIALOGFLOW_EVENT_INTENT "dialogflow::intent"
#define DIALOGFLOW_EVENT_TRANSCRIPTION "dialogflow::transcription"
#define DIALOGFLOW_EVENT_AUDIO_PROVIDED "dialogflow::audio_provided"
#define DIALOGFLOW_EVENT_END_OF_UTTERANCE "dialogflow::end_of_utterance"
#define DIALOGFLOW_EVENT_ERROR "dialogflow::error"
#define MY_BUG_NAME "__dialogflow_cx_bug__"
#define DIALOGFLOW_CX_EVENT_INTENT "dialogflow_cx::intent"
#define DIALOGFLOW_CX_EVENT_TRANSCRIPTION "dialogflow_cx::transcription"
#define DIALOGFLOW_CX_EVENT_AUDIO_PROVIDED "dialogflow_cx::audio_provided"
#define DIALOGFLOW_CX_EVENT_END_OF_UTTERANCE "dialogflow_cx::end_of_utterance"
#define DIALOGFLOW_CX_EVENT_ERROR "dialogflow_cx::error"
#define MAX_LANG (12)
#define MAX_PROJECT_ID (128)

View File

@@ -10,43 +10,22 @@ template <typename T> cJSON* GRPCParser::parseCollection(const RepeatedPtrField<
return json;
}
const std::string& GRPCParser::parseAudio(const StreamingDetectIntentResponse& response) {
return response.output_audio();
}
cJSON* GRPCParser::parse(const StreamingDetectIntentResponse& response) {
cJSON * json = cJSON_CreateObject();
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(m_session), SWITCH_LOG_INFO, "GStrGRPCParser - parsing StreamingDetectIntentResponse\n");
// response_id
cJSON_AddItemToObject(json, "response_id",cJSON_CreateString(response.response_id().c_str()));
// recognition_result
if (response.has_recognition_result()) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(m_session), SWITCH_LOG_INFO, "GStrGRPCParser - adding recognition result\n");
cJSON_AddItemToObject(json, "recognition_result", parse(response.recognition_result()));
}
// query_result
if (response.has_query_result()) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(m_session), SWITCH_LOG_INFO, "GStrGRPCParser - adding query result\n");
cJSON_AddItemToObject(json, "query_result", parse(response.query_result()));
}
// alternative_query_results
cJSON_AddItemToObject(json, "alternative_query_results", parseCollection(response.alternative_query_results()));
// webhook_status
cJSON_AddItemToObject(json, "webhook_status", parse(response.webhook_status()));
//
if (response.has_output_audio_config()) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(m_session), SWITCH_LOG_INFO, "GStrGRPCParser - adding audio config\n");
cJSON_AddItemToObject(json, "output_audio_config", parse(response.output_audio_config()));
}
// XXXX: not doing anything with output_audio for the moment
// detect_intent_response
if (response.has_detect_intent_response()) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(m_session), SWITCH_LOG_INFO, "GStrGRPCParser - adding detect intent response\n");
cJSON_AddItemToObject(json, "detect_intent_response", parse(response.detect_intent_response()));
}
return json;
}
@@ -55,6 +34,24 @@ cJSON* GRPCParser::parse(const OutputAudioEncoding& o) {
return cJSON_CreateString(OutputAudioEncoding_Name(o).c_str());
}
cJSON* GRPCParser::parse(const SynthesizeSpeechConfig& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "speaking_rate", cJSON_CreateNumber(o.speaking_rate()));
cJSON_AddItemToObject(json, "pitch", cJSON_CreateNumber(o.pitch()));
cJSON_AddItemToObject(json, "volume_gain_db", cJSON_CreateNumber(o.volume_gain_db()));
return json;
}
cJSON* GRPCParser::parse(const VoiceSelectionParams& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "name", cJSON_CreateString(o.name().c_str()));
cJSON_AddItemToObject(json, "ssml_gender", cJSON_CreateString(SsmlVoiceGender_Name(o.ssml_gender()).c_str()));
return json;
}
cJSON* GRPCParser::parse(const OutputAudioConfig& o) {
cJSON * json = cJSON_CreateObject();
@@ -65,31 +62,6 @@ cJSON* GRPCParser::parse(const OutputAudioConfig& o) {
return json;
}
cJSON* GRPCParser::parse(const SynthesizeSpeechConfig& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "speaking_rate", cJSON_CreateNumber(o.speaking_rate()));
cJSON_AddItemToObject(json, "pitch", cJSON_CreateNumber(o.pitch()));
cJSON_AddItemToObject(json, "volume_gain_db", cJSON_CreateNumber(o.volume_gain_db()));
cJSON_AddItemToObject(json, "effects_profile_id", parseCollection(o.effects_profile_id()));
cJSON_AddItemToObject(json, "voice", parse(o.voice()));
return json;
}
cJSON* GRPCParser::parse(const SsmlVoiceGender& o) {
return cJSON_CreateString(SsmlVoiceGender_Name(o).c_str());
}
cJSON* GRPCParser::parse(const VoiceSelectionParams& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "name", cJSON_CreateString(o.name().c_str()));
cJSON_AddItemToObject(json, "ssml_gender", parse(o.ssml_gender()));
return json;
}
cJSON* GRPCParser::parse(const google::rpc::Status& o) {
cJSON * json = cJSON_CreateObject();
@@ -149,281 +121,15 @@ cJSON* GRPCParser::parse(const Struct& rpcStruct) {
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_SimpleResponse& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "ssml", cJSON_CreateString(o.ssml().c_str()));
cJSON_AddItemToObject(json, "text_to_speech", cJSON_CreateString(o.text_to_speech().c_str()));
cJSON_AddItemToObject(json, "display_text", cJSON_CreateString(o.display_text().c_str()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Parameter& param) {
cJSON * json = cJSON_CreateObject();
cJSON* GRPCParser::parse(const Intent_Message_SimpleResponses& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "simple_responses", parseCollection(o.simple_responses()));
return json;
}
cJSON_AddItemToObject(json, "id", cJSON_CreateString(param.id().c_str()));
cJSON_AddItemToObject(json, "entity_type", cJSON_CreateString(param.entity_type().c_str()));
cJSON_AddItemToObject(json, "is_list", cJSON_CreateBool(param.is_list()));
cJSON_AddItemToObject(json, "redact", cJSON_CreateBool(param.redact()));
cJSON* GRPCParser::parse(const Intent_Message_Image& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "accessibility_text", cJSON_CreateString(o.accessibility_text().c_str()));
cJSON_AddItemToObject(json, "image_uri", cJSON_CreateString(o.image_uri().c_str()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_BasicCard_Button_OpenUriAction& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "uri", cJSON_CreateString(o.uri().c_str()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_BasicCard_Button& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "title", cJSON_CreateString(o.title().c_str()));
cJSON_AddItemToObject(json, "open_uri_action", parse(o.open_uri_action()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_Card_Button& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "text", cJSON_CreateString(o.text().c_str()));
cJSON_AddItemToObject(json, "postback", parse(o.postback()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_BasicCard& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "title", cJSON_CreateString(o.title().c_str()));
cJSON_AddItemToObject(json, "subtitle", cJSON_CreateString(o.subtitle().c_str()));
cJSON_AddItemToObject(json, "formatted_text", cJSON_CreateString(o.formatted_text().c_str()));
cJSON_AddItemToObject(json, "image", parse(o.image()));
cJSON_AddItemToObject(json, "buttons", parseCollection(o.buttons()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_Card& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "title", cJSON_CreateString(o.title().c_str()));
cJSON_AddItemToObject(json, "subtitle", cJSON_CreateString(o.subtitle().c_str()));
cJSON_AddItemToObject(json, "image_uri", cJSON_CreateString(o.image_uri().c_str()));
cJSON_AddItemToObject(json, "buttons", parseCollection(o.buttons()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_Suggestion& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "title", cJSON_CreateString(o.title().c_str()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_Suggestions& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "suggestions", parseCollection(o.suggestions()));
return json;
}
cJSON* GRPCParser::parse(const std::string& val) {
return cJSON_CreateString(val.c_str());
}
cJSON* GRPCParser::parse(const Intent_Message_LinkOutSuggestion& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "destination_name", cJSON_CreateString(o.destination_name().c_str()));
cJSON_AddItemToObject(json, "uri", cJSON_CreateString(o.uri().c_str()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_SelectItemInfo& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "key", cJSON_CreateString(o.key().c_str()));
cJSON_AddItemToObject(json, "synonyms", parseCollection(o.synonyms()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_ListSelect_Item& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "info", parse(o.info()));
cJSON_AddItemToObject(json, "title", cJSON_CreateString(o.title().c_str()));
cJSON_AddItemToObject(json, "description", cJSON_CreateString(o.description().c_str()));
cJSON_AddItemToObject(json, "image", parse(o.image()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_CarouselSelect& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "items", parseCollection(o.items()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_CarouselSelect_Item& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "info", parse(o.info()));
cJSON_AddItemToObject(json, "title", cJSON_CreateString(o.title().c_str()));
cJSON_AddItemToObject(json, "description", cJSON_CreateString(o.description().c_str()));
cJSON_AddItemToObject(json, "image", parse(o.image()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_ListSelect& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "title", cJSON_CreateString(o.title().c_str()));
cJSON_AddItemToObject(json, "items", parseCollection(o.items()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_TelephonyPlayAudio& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "audio_uri", cJSON_CreateString(o.audio_uri().c_str()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_TelephonySynthesizeSpeech& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "text", cJSON_CreateString(o.text().c_str()));
cJSON_AddItemToObject(json, "ssml", cJSON_CreateString(o.ssml().c_str()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_TelephonyTransferCall& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "phone_number", cJSON_CreateString(o.phone_number().c_str()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_QuickReplies& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "title", cJSON_CreateString(o.title().c_str()));
cJSON_AddItemToObject(json, "quick_replies", parseCollection(o.quick_replies()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Message_Text& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "text", parseCollection(o.text()));
return json;
}
cJSON* GRPCParser::parse(const Intent_TrainingPhrase_Part& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "text", cJSON_CreateString(o.text().c_str()));
cJSON_AddItemToObject(json, "entity_type", cJSON_CreateString(o.entity_type().c_str()));
cJSON_AddItemToObject(json, "alias", cJSON_CreateString(o.alias().c_str()));
cJSON_AddItemToObject(json, "user", cJSON_CreateBool(o.user_defined()));
return json;
}
cJSON* GRPCParser::parse(const Intent_WebhookState& o) {
return cJSON_CreateString(Intent_WebhookState_Name(o).c_str());
}
cJSON* GRPCParser::parse(const Intent_TrainingPhrase_Type& o) {
return cJSON_CreateString(Intent_TrainingPhrase_Type_Name(o).c_str());
}
cJSON* GRPCParser::parse(const Intent_TrainingPhrase& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "name", cJSON_CreateString(o.name().c_str()));
cJSON_AddItemToObject(json, "type", parse(o.type()));
cJSON_AddItemToObject(json, "parts", parseCollection(o.parts()));
cJSON_AddItemToObject(json, "times_added_count", cJSON_CreateNumber(o.times_added_count()));
return json;
}
cJSON* GRPCParser::parse(const Intent_Parameter& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "name", cJSON_CreateString(o.name().c_str()));
cJSON_AddItemToObject(json, "display_name", cJSON_CreateString(o.display_name().c_str()));
cJSON_AddItemToObject(json, "value", cJSON_CreateString(o.value().c_str()));
cJSON_AddItemToObject(json, "default_value", cJSON_CreateString(o.default_value().c_str()));
cJSON_AddItemToObject(json, "entity_type_display_name", cJSON_CreateString(o.entity_type_display_name().c_str()));
cJSON_AddItemToObject(json, "mandatory", cJSON_CreateBool(o.mandatory()));
cJSON_AddItemToObject(json, "prompts", parseCollection(o.prompts()));
cJSON_AddItemToObject(json, "is_list", cJSON_CreateBool(o.is_list()));
return json;
}
cJSON* GRPCParser::parse(const Intent_FollowupIntentInfo& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "followup_intent_name", cJSON_CreateString(o.followup_intent_name().c_str()));
cJSON_AddItemToObject(json, "parent_followup_intent_name", cJSON_CreateString(o.parent_followup_intent_name().c_str()));
return json;
}
cJSON* GRPCParser::parse(const Sentiment& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "score", cJSON_CreateNumber(o.score()));
cJSON_AddItemToObject(json, "magnitude", cJSON_CreateNumber(o.magnitude()));
return json;
}
cJSON* GRPCParser::parse(const SentimentAnalysisResult& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "query_text_sentiment", parse(o.query_text_sentiment()));
return json;
}
cJSON* GRPCParser::parse(const KnowledgeAnswers_Answer_MatchConfidenceLevel& o) {
return cJSON_CreateString(KnowledgeAnswers_Answer_MatchConfidenceLevel_Name(o).c_str());
}
cJSON* GRPCParser::parse(const KnowledgeAnswers_Answer& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "source", cJSON_CreateString(o.source().c_str()));
cJSON_AddItemToObject(json, "faq_question", cJSON_CreateString(o.faq_question().c_str()));
cJSON_AddItemToObject(json, "answer", cJSON_CreateString(o.answer().c_str()));
cJSON_AddItemToObject(json, "match_confidence_level", parse(o.match_confidence_level()));
cJSON_AddItemToObject(json, "match_confidence", cJSON_CreateNumber(o.match_confidence()));
return json;
}
cJSON* GRPCParser::parse(const KnowledgeAnswers& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "answers", parseCollection(o.answers()));
return json;
return json;
}
cJSON* GRPCParser::parse(const Intent& o) {
@@ -431,123 +137,239 @@ cJSON* GRPCParser::parse(const Intent& o) {
cJSON_AddItemToObject(json, "name", cJSON_CreateString(o.name().c_str()));
cJSON_AddItemToObject(json, "display_name", cJSON_CreateString(o.display_name().c_str()));
cJSON_AddItemToObject(json, "webhook_state", parse(o.webhook_state()));
cJSON* params = cJSON_CreateArray();
for (int i = 0; i < o.parameters_size(); i++) {
cJSON_AddItemToArray(params, parse(o.parameters(i)));
}
cJSON_AddItemToObject(json, "parameters", params);
cJSON_AddItemToObject(json, "priority", cJSON_CreateNumber(o.priority()));
cJSON_AddItemToObject(json, "is_fallback", cJSON_CreateBool(o.is_fallback()));
cJSON_AddItemToObject(json, "ml_disabled", cJSON_CreateBool(o.ml_disabled()));
cJSON_AddItemToObject(json, "end_interaction", cJSON_CreateBool(o.end_interaction()));
cJSON_AddItemToObject(json, "input_context_names", parseCollection(o.input_context_names()));
cJSON_AddItemToObject(json, "events", parseCollection(o.events()));
cJSON_AddItemToObject(json, "training_phrases", parseCollection(o.training_phrases()));
cJSON_AddItemToObject(json, "action", cJSON_CreateString(o.action().c_str()));
cJSON_AddItemToObject(json, "output_contexts", parseCollection(o.output_contexts()));
cJSON_AddItemToObject(json, "reset_contexts", cJSON_CreateBool(o.reset_contexts()));
cJSON_AddItemToObject(json, "parameters", parseCollection(o.parameters()));
cJSON_AddItemToObject(json, "messages", parseCollection(o.messages()));
cJSON* j = cJSON_CreateArray();
for (int i = 0; i < o.default_response_platforms_size(); i++) {
cJSON_AddItemToArray(j, cJSON_CreateString(Intent_Message_Platform_Name(o.default_response_platforms(i)).c_str()));
}
cJSON_AddItemToObject(json, "default_response_platforms", j);
cJSON_AddItemToObject(json, "root_followup_intent_name", cJSON_CreateString(o.root_followup_intent_name().c_str()));
cJSON_AddItemToObject(json, "followup_intent_info", parseCollection(o.followup_intent_info()));
return json;
}
cJSON* GRPCParser::parse(const google::cloud::dialogflow::v2beta1::Context& o) {
cJSON * json = cJSON_CreateObject();
cJSON* GRPCParser::parse(const Match& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "name", cJSON_CreateString(o.name().c_str()));
cJSON_AddItemToObject(json, "lifespan_count", cJSON_CreateNumber(o.lifespan_count()));
if (o.has_parameters()) cJSON_AddItemToObject(json, "parameters", parse(o.parameters()));
cJSON_AddItemToObject(json, "resolved_input", cJSON_CreateString(o.resolved_input().c_str()));
cJSON_AddItemToObject(json, "event", cJSON_CreateString(Match_MatchType_Name(o.event()).c_str()));
if (o.has_intent()) cJSON_AddItemToObject(json, "intent", parse(o.intent()));
cJSON_AddItemToObject(json, "parameters", parse(o.parameters()));
cJSON_AddItemToObject(json, "match_type", cJSON_CreateString(Match_MatchType_Name(o.match_type()).c_str()));
cJSON_AddItemToObject(json, "confidence", cJSON_CreateNumber(o.confidence()));
return json;
return json;
}
cJSON* GRPCParser::parse(const Intent_Message& msg) {
cJSON * json = cJSON_CreateObject();
cJSON* GRPCParser::parse(const AdvancedSettings_SpeechSettings& o) {
cJSON * json = cJSON_CreateObject();
auto platform = msg.platform();
cJSON_AddItemToObject(json, "platform", cJSON_CreateString(Intent_Message_Platform_Name(platform).c_str()));
if (msg.has_text()) {
cJSON_AddItemToObject(json, "text", parse(msg.text()));
}
if (o.has_no_speech_timeout()) {
double total_seconds = o.no_speech_timeout().seconds() + o.no_speech_timeout().nanos() / 1e9;
cJSON_AddItemToObject(json, "no_speech_timeout", cJSON_CreateNumber(total_seconds));
}
cJSON_AddItemToObject(json, "endpointer_sensitivity", cJSON_CreateNumber(o.endpointer_sensitivity()));
cJSON_AddItemToObject(json, "use_timeout_based_endpointing", cJSON_CreateBool(o.use_timeout_based_endpointing()));
if (msg.has_image()) {
cJSON_AddItemToObject(json, "image", parse(msg.image()));
}
if (msg.has_quick_replies()) {
cJSON_AddItemToObject(json, "quick_replies", parse(msg.quick_replies()));
}
if (msg.has_card()) {
cJSON_AddItemToObject(json, "card", parse(msg.card()));
}
if (msg.has_payload()) {
cJSON_AddItemToObject(json, "payload", parse(msg.payload()));
}
if (msg.has_simple_responses()) {
cJSON_AddItemToObject(json, "simple_responses", parse(msg.simple_responses()));
}
if (msg.has_basic_card()) {
cJSON_AddItemToObject(json, "basic_card", parse(msg.card()));
}
if (msg.has_suggestions()) {
cJSON_AddItemToObject(json, "suggestions", parse(msg.suggestions()));
}
if (msg.has_link_out_suggestion()) {
cJSON_AddItemToObject(json, "link_out_suggestion", parse(msg.link_out_suggestion()));
}
if (msg.has_list_select()) {
cJSON_AddItemToObject(json, "list_select", parse(msg.list_select()));
}
if (msg.has_telephony_play_audio()) {
cJSON_AddItemToObject(json, "telephony_play_audio", parse(msg.telephony_play_audio()));
}
if (msg.has_telephony_synthesize_speech()) {
cJSON_AddItemToObject(json, "telephony_synthesize_speech", parse(msg.telephony_synthesize_speech()));
}
if (msg.has_telephony_transfer_call()) {
cJSON_AddItemToObject(json, "telephony_transfer_call", parse(msg.telephony_transfer_call()));
}
return json;
return json;
}
cJSON* GRPCParser::parse(const AdvancedSettings_DtmfSettings& o) {
cJSON * json = cJSON_CreateObject();
double interdigit_timeout_duration = o.interdigit_timeout_duration().seconds() + o.interdigit_timeout_duration().nanos() / 1e9;
double endpointing_timeout_duration = o.endpointing_timeout_duration().seconds() + o.endpointing_timeout_duration().nanos() / 1e9;
cJSON_AddItemToObject(json, "interdigit_timeout_duration", cJSON_CreateNumber(interdigit_timeout_duration));
cJSON_AddItemToObject(json, "endpointing_timeout_duration", cJSON_CreateNumber(endpointing_timeout_duration));
cJSON_AddItemToObject(json, "enabled", cJSON_CreateBool(o.enabled()));
cJSON_AddItemToObject(json, "max_digits", cJSON_CreateNumber(o.max_digits()));
return json;
}
cJSON* GRPCParser::parse(const AdvancedSettings_LoggingSettings& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "enable_stackdriver_logging", cJSON_CreateBool(o.enable_stackdriver_logging()));
cJSON_AddItemToObject(json, "enable_interaction_logging", cJSON_CreateBool(o.enable_interaction_logging()));
cJSON_AddItemToObject(json, "enable_consent_based_redaction", cJSON_CreateBool(o.enable_consent_based_redaction()));
return json;
}
cJSON* GRPCParser::parse(const GcsDestination& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "uri", cJSON_CreateString(o.uri().c_str()));
return json;
}
cJSON* GRPCParser::parse(const AdvancedSettings& o) {
cJSON * json = cJSON_CreateObject();
if (o.has_audio_export_gcs_destination()) cJSON_AddItemToObject(json, "audio_export_gcs_destination", parse(o.audio_export_gcs_destination()));
if (o.has_speech_settings()) cJSON_AddItemToObject(json, "speech_settings", parse(o.speech_settings()));
if (o.has_dtmf_settings()) cJSON_AddItemToObject(json, "dtmf_settings", parse(o.dtmf_settings()));
if (o.has_logging_settings()) cJSON_AddItemToObject(json, "logging_settings", parse(o.logging_settings()));
return json;
}
cJSON* GRPCParser::parse(const ResponseMessage_Text& o) {
cJSON* t = cJSON_CreateArray();
for (int i = 0; i < o.text_size(); i++) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "text", cJSON_CreateString(o.text(i).c_str()));
cJSON_AddItemToObject(json, "allow_playback_interruption", cJSON_CreateBool(o.allow_playback_interruption()));
cJSON_AddItemToArray(t, json);
}
return t;
}
cJSON* GRPCParser::parse(const ResponseMessage_ConversationSuccess& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "metadata", parse(o.metadata()));
return json;
}
cJSON* GRPCParser::parse(const ResponseMessage_OutputAudioText& o) {
cJSON * json = cJSON_CreateObject();
if (o.has_text()) cJSON_AddItemToObject(json, "text", cJSON_CreateString(o.text().c_str()));
if (o.has_ssml()) cJSON_AddItemToObject(json, "ssml", cJSON_CreateString(o.ssml().c_str()));
return json;
}
cJSON* GRPCParser::parse(const ResponseMessage_LiveAgentHandoff& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "metadata", parse(o.metadata()));
return json;
}
cJSON* GRPCParser::parse(const ResponseMessage_EndInteraction& o) {
cJSON * json = cJSON_CreateObject();
// TODOL: need to research this more
return json;
}
cJSON* GRPCParser::parse(const ResponseMessage_PlayAudio& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "audio_uri", cJSON_CreateString(o.audio_uri().c_str()));
cJSON_AddItemToObject(json, "allow_playback_interruption", cJSON_CreateBool(o.allow_playback_interruption()));
return json;
}
cJSON* GRPCParser::parse(const ResponseMessage_MixedAudio& o) {
cJSON * json = cJSON_CreateArray();
for (int i = 0; i < o.segments_size(); i++) {
cJSON * segment = cJSON_CreateObject();
if (o.segments(i).has_audio()) cJSON_AddItemToObject(segment, "audio", cJSON_CreateString(o.segments(i).audio().c_str()));
else if (o.segments(i).has_uri()) cJSON_AddItemToObject(segment, "uri", cJSON_CreateString(o.segments(i).uri().c_str()));
cJSON_AddItemToObject(segment, "allow_playback_interruption", cJSON_CreateBool(o.segments(i).allow_playback_interruption()));
}
return json;
}
cJSON* GRPCParser::parse(const ResponseMessage_TelephonyTransferCall& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "phone_number", cJSON_CreateString(o.phone_number().c_str()));
return json;
}
cJSON* GRPCParser::parse(const ResponseMessage& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "response_type", cJSON_CreateString(ResponseMessage_ResponseType_Name(o.response_type()).c_str()));
cJSON_AddItemToObject(json, "text", parse(o.text()));
cJSON_AddItemToObject(json, "payload", parse(o.payload()));
cJSON_AddItemToObject(json, "conversation_success", parse(o.conversation_success()));
cJSON_AddItemToObject(json, "output_audio_text", parse(o.output_audio_text()));
cJSON_AddItemToObject(json, "live_agent_handoff", parse(o.live_agent_handoff()));
cJSON_AddItemToObject(json, "end_interaction", parse(o.end_interaction()));
cJSON_AddItemToObject(json, "play_audio", parse(o.play_audio()));
cJSON_AddItemToObject(json, "mixed_audio", parse(o.mixed_audio()));
cJSON_AddItemToObject(json, "telephony_transfer_call", parse(o.telephony_transfer_call()));
return json;
}
cJSON* GRPCParser::parse(const QueryResult& qr) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "query_text", cJSON_CreateString(qr.query_text().c_str()));
// one-of
if (qr.has_text()) cJSON_AddItemToObject(json, "text", cJSON_CreateString(qr.text().c_str()));
else if (qr.has_trigger_intent()) cJSON_AddItemToObject(json, "trigger_intent", cJSON_CreateString(qr.trigger_intent().c_str()));
else if (qr.has_transcript()) cJSON_AddItemToObject(json, "transcript", cJSON_CreateString(qr.transcript().c_str()));
else if (qr.has_trigger_event()) cJSON_AddItemToObject(json, "trigger_event", cJSON_CreateString(qr.trigger_event().c_str()));
if (qr.has_dtmf()) cJSON_AddItemToObject(json, "dtmf", parse(qr.dtmf()));
cJSON_AddItemToObject(json, "language_code", cJSON_CreateString(qr.language_code().c_str()));
cJSON_AddItemToObject(json, "speech_recognition_confidence", cJSON_CreateNumber(qr.speech_recognition_confidence()));
cJSON_AddItemToObject(json, "action", cJSON_CreateString(qr.action().c_str()));
cJSON_AddItemToObject(json, "parameters", parse(qr.parameters()));
cJSON_AddItemToObject(json, "all_required_params_present", cJSON_CreateBool(qr.all_required_params_present()));
cJSON_AddItemToObject(json, "fulfillment_text", cJSON_CreateString(qr.fulfillment_text().c_str()));
cJSON_AddItemToObject(json, "fulfillment_messages", parseCollection(qr.fulfillment_messages()));
cJSON_AddItemToObject(json, "webhook_source", cJSON_CreateString(qr.webhook_source().c_str()));
if (qr.has_webhook_payload()) cJSON_AddItemToObject(json, "webhook_payload", parse(qr.webhook_payload()));
cJSON_AddItemToObject(json, "output_contexts", parseCollection(qr.output_contexts()));
cJSON_AddItemToObject(json, "intent", parse(qr.intent()));
cJSON_AddItemToObject(json, "intent_detection_confidence", cJSON_CreateNumber(qr.intent_detection_confidence()));
if (qr.has_diagnostic_info()) cJSON_AddItemToObject(json, "diagnostic_info", parse(qr.diagnostic_info()));
cJSON_AddItemToObject(json, "sentiment_analysis_result", parse(qr.sentiment_analysis_result()));
cJSON_AddItemToObject(json, "knowledge_answers", parse(qr.knowledge_answers()));
cJSON* rms = cJSON_CreateArray();
for (int i = 0; i < qr.response_messages_size(); i++) {
cJSON_AddItemToArray(rms, parse(qr.response_messages(i)));
}
cJSON_AddItemToObject(json, "response_messages", rms);
cJSON* whids = cJSON_CreateArray();
for (int i = 0; i < qr.webhook_ids_size(); i++) {
cJSON_AddItemToArray(whids, cJSON_CreateString(qr.webhook_ids(i).c_str()));
}
cJSON_AddItemToObject(json, "webhook_ids", whids);
cJSON* whDisplayNames = cJSON_CreateArray();
for (int i = 0; i < qr.webhook_display_names_size(); i++) {
cJSON_AddItemToArray(whDisplayNames, cJSON_CreateString(qr.webhook_display_names(i).c_str()));
}
cJSON_AddItemToObject(json, "webhook_display_names", whDisplayNames);
cJSON* whLatencies = cJSON_CreateArray();
for (int i = 0; i < qr.webhook_latencies_size(); i++) {
double total_seconds = qr.webhook_latencies(i).seconds() + qr.webhook_latencies(i).nanos() / 1e9;
cJSON_AddItemToArray(whLatencies, cJSON_CreateNumber(total_seconds));
}
cJSON* whTags = cJSON_CreateArray();
for (int i = 0; i < qr.webhook_tags_size(); i++) {
cJSON_AddItemToArray(whids, cJSON_CreateString(qr.webhook_tags(i).c_str()));
}
cJSON* whStatuses = cJSON_CreateArray();
for (int i = 0; i < qr.webhook_statuses_size(); i++) {
cJSON_AddItemToArray(whStatuses, parse(qr.webhook_statuses(i)));
}
cJSON* whPayloads = cJSON_CreateArray();
for (int i = 0; i < qr.webhook_payloads_size(); i++) {
cJSON_AddItemToArray(whPayloads, parse(qr.webhook_payloads(i)));
}
//if (qr.has_current_page()) cJSON_AddItemToObject(json, "current_page", parse(qr.current_page());
//if (qr.has_current_flow()) cJSON_AddItemToObject(json, "current_flow", parse(qr.current_flow());
if (qr.has_match()) cJSON_AddItemToObject(json, "match", parse(qr.match()));
if (qr.has_diagnostic_info()) cJSON_AddItemToObject(json, "diagnostic_info", parse(qr.diagnostic_info()));
if (qr.has_sentiment_analysis_result()) cJSON_AddItemToObject(json, "sentiment_analysis_result", parse(qr.sentiment_analysis_result()));
if (qr.has_advanced_settings()) cJSON_AddItemToObject(json, "advanced_settings", parse(qr.advanced_settings()));
cJSON_AddItemToObject(json, "allow_answer_feedback", cJSON_CreateBool(qr.allow_answer_feedback()));
// skipping DataStoreConnectionSignals for now, it doesn't seem consequential
return json;
}
@@ -555,6 +377,15 @@ cJSON* GRPCParser::parse(const StreamingRecognitionResult_MessageType& o) {
return cJSON_CreateString(StreamingRecognitionResult_MessageType_Name(o).c_str());
}
cJSON* GRPCParser::parse(const DtmfInput& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "digits", cJSON_CreateString(o.digits().c_str()));
cJSON_AddItemToObject(json, "finish_digit", cJSON_CreateString(o.finish_digit().c_str()));
return json;
}
cJSON* GRPCParser::parse(const StreamingRecognitionResult& o) {
cJSON * json = cJSON_CreateObject();
@@ -562,6 +393,23 @@ cJSON* GRPCParser::parse(const StreamingRecognitionResult& o) {
cJSON_AddItemToObject(json, "transcript", cJSON_CreateString(o.transcript().c_str()));
cJSON_AddItemToObject(json, "is_final", cJSON_CreateBool(o.is_final()));
cJSON_AddItemToObject(json, "confidence", cJSON_CreateNumber(o.confidence()));
cJSON_AddItemToObject(json, "stability", cJSON_CreateNumber(o.stability()));
cJSON_AddItemToObject(json, "language_code", cJSON_CreateString(o.language_code().c_str()));
// TODO: we also have SpeechWordInfo if we want to dive into that
return json;
}
cJSON* GRPCParser::parse(const DetectIntentResponse& o) {
cJSON * json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "response_id", cJSON_CreateString(o.response_id().c_str()));
cJSON_AddItemToObject(json, "query_result", parse(o.query_result()));
cJSON_AddItemToObject(json, "output_audio", cJSON_CreateString(o.output_audio().c_str()));
cJSON_AddItemToObject(json, "output_audio_config", cJSON_CreateString(o.output_audio_config()));
cJSON_AddItemToObject(json, "response_type", cJSON_CreateString(o.response_type));
cJSON_AddItemToObject(json, "allow_cancellation", cJSON_CreateBool(o.allow_cancellation));
return json;
}

View File

@@ -3,65 +3,47 @@
#include <switch_json.h>
#include <grpc++/grpc++.h>
#include "google/cloud/dialogflow/v2beta1/session.grpc.pb.h"
#include "google/cloud/dialogflow/cx/v3/session.grpc.pb.h"
using google::cloud::dialogflow::v2beta1::Sessions;
using google::cloud::dialogflow::v2beta1::StreamingDetectIntentRequest;
using google::cloud::dialogflow::v2beta1::StreamingDetectIntentResponse;
using google::cloud::dialogflow::v2beta1::AudioEncoding;
using google::cloud::dialogflow::v2beta1::InputAudioConfig;
using google::cloud::dialogflow::v2beta1::OutputAudioConfig;
using google::cloud::dialogflow::v2beta1::SynthesizeSpeechConfig;
using google::cloud::dialogflow::v2beta1::VoiceSelectionParams;
using google::cloud::dialogflow::v2beta1::SsmlVoiceGender;
using google::cloud::dialogflow::v2beta1::SsmlVoiceGender_Name;
using google::cloud::dialogflow::v2beta1::QueryInput;
using google::cloud::dialogflow::v2beta1::QueryResult;
using google::cloud::dialogflow::v2beta1::StreamingRecognitionResult;
using google::cloud::dialogflow::v2beta1::StreamingRecognitionResult_MessageType;
using google::cloud::dialogflow::v2beta1::StreamingRecognitionResult_MessageType_Name;
using google::cloud::dialogflow::v2beta1::EventInput;
using google::cloud::dialogflow::v2beta1::OutputAudioEncoding;
using google::cloud::dialogflow::v2beta1::OutputAudioEncoding_Name;
using google::cloud::dialogflow::v2beta1::Context;
using google::cloud::dialogflow::v2beta1::Sentiment;
using google::cloud::dialogflow::v2beta1::SentimentAnalysisResult;
using google::cloud::dialogflow::v2beta1::KnowledgeAnswers;
using google::cloud::dialogflow::v2beta1::KnowledgeAnswers_Answer;
using google::cloud::dialogflow::v2beta1::KnowledgeAnswers_Answer_MatchConfidenceLevel;
using google::cloud::dialogflow::v2beta1::KnowledgeAnswers_Answer_MatchConfidenceLevel_Name;
using google::cloud::dialogflow::v2beta1::Intent;
using google::cloud::dialogflow::v2beta1::Intent_FollowupIntentInfo;
using google::cloud::dialogflow::v2beta1::Intent_WebhookState;
using google::cloud::dialogflow::v2beta1::Intent_WebhookState_Name;
using google::cloud::dialogflow::v2beta1::Intent_Parameter;
using google::cloud::dialogflow::v2beta1::Intent_TrainingPhrase;
using google::cloud::dialogflow::v2beta1::Intent_TrainingPhrase_Type;
using google::cloud::dialogflow::v2beta1::Intent_TrainingPhrase_Part;
using google::cloud::dialogflow::v2beta1::Intent_TrainingPhrase_Type_Name;
using google::cloud::dialogflow::v2beta1::Intent_Message;
using google::cloud::dialogflow::v2beta1::Intent_Message_QuickReplies;
using google::cloud::dialogflow::v2beta1::Intent_Message_Platform_Name;
using google::cloud::dialogflow::v2beta1::Intent_Message_SimpleResponses;
using google::cloud::dialogflow::v2beta1::Intent_Message_SimpleResponse;
using google::cloud::dialogflow::v2beta1::Intent_Message_BasicCard;
using google::cloud::dialogflow::v2beta1::Intent_Message_Card;
using google::cloud::dialogflow::v2beta1::Intent_Message_Image;
using google::cloud::dialogflow::v2beta1::Intent_Message_Text;
using google::cloud::dialogflow::v2beta1::Intent_Message_Card_Button;
using google::cloud::dialogflow::v2beta1::Intent_Message_BasicCard_Button;
using google::cloud::dialogflow::v2beta1::Intent_Message_BasicCard_Button_OpenUriAction;
using google::cloud::dialogflow::v2beta1::Intent_Message_Suggestion;
using google::cloud::dialogflow::v2beta1::Intent_Message_Suggestions;
using google::cloud::dialogflow::v2beta1::Intent_Message_LinkOutSuggestion;
using google::cloud::dialogflow::v2beta1::Intent_Message_ListSelect;
using google::cloud::dialogflow::v2beta1::Intent_Message_CarouselSelect;
using google::cloud::dialogflow::v2beta1::Intent_Message_CarouselSelect_Item;
using google::cloud::dialogflow::v2beta1::Intent_Message_ListSelect_Item;
using google::cloud::dialogflow::v2beta1::Intent_Message_SelectItemInfo;
using google::cloud::dialogflow::v2beta1::Intent_Message_TelephonyPlayAudio;
using google::cloud::dialogflow::v2beta1::Intent_Message_TelephonySynthesizeSpeech;
using google::cloud::dialogflow::v2beta1::Intent_Message_TelephonyTransferCall;
using google::cloud::dialogflow::cx::v3::Sessions;
using google::cloud::dialogflow::cx::v3::StreamingDetectIntentRequest;
using google::cloud::dialogflow::cx::v3::StreamingDetectIntentResponse;
using google::cloud::dialogflow::cx::v3::DetectIntentResponse;
using google::cloud::dialogflow::cx::v3::ResponseMessage;
using google::cloud::dialogflow::cx::v3::ResponseMessage_Text;
using google::cloud::dialogflow::cx::v3::ResponseMessage_LiveAgentHandoff;
using google::cloud::dialogflow::cx::v3::ResponseMessage_ConversationSuccess;
using google::cloud::dialogflow::cx::v3::ResponseMessage_OutputAudioText;
using google::cloud::dialogflow::cx::v3::ResponseMessage_EndInteraction;
using google::cloud::dialogflow::cx::v3::ResponseMessage_PlayAudio;
using google::cloud::dialogflow::cx::v3::ResponseMessage_MixedAudio;
using google::cloud::dialogflow::cx::v3::ResponseMessage_TelephonyTransferCall;
using google::cloud::dialogflow::cx::v3::ResponseMessage_KnowledgeInfoCard;
using google::cloud::dialogflow::cx::v3::ResponseMessage_ResponseType;
using google::cloud::dialogflow::cx::v3::AudioEncoding;
using google::cloud::dialogflow::cx::v3::InputAudioConfig;
using google::cloud::dialogflow::cx::v3::OutputAudioConfig;
using google::cloud::dialogflow::cx::v3::SynthesizeSpeechConfig;
using google::cloud::dialogflow::cx::v3::VoiceSelectionParams;
using google::cloud::dialogflow::cx::v3::Intent;
using google::cloud::dialogflow::cx::v3::Intent_Parameter;
using google::cloud::dialogflow::cx::v3::QueryInput;
using google::cloud::dialogflow::cx::v3::QueryResult;
using google::cloud::dialogflow::cx::v3::Match;
using google::cloud::dialogflow::cx::v3::Match_MatchType_Name;
using google::cloud::dialogflow::cx::v3::AdvancedSettings;
using google::cloud::dialogflow::cx::v3::AdvancedSettings_SpeechSettings;
using google::cloud::dialogflow::cx::v3::AdvancedSettings_DtmfSettings;
using google::cloud::dialogflow::cx::v3::AdvancedSettings_LoggingSettings;
using google::cloud::dialogflow::cx::v3::StreamingRecognitionResult;
using google::cloud::dialogflow::cx::v3::StreamingRecognitionResult_MessageType;
using google::cloud::dialogflow::cx::v3::StreamingRecognitionResult_MessageType_Name;
using google::cloud::dialogflow::cx::v3::EventInput;
using google::cloud::dialogflow::cx::v3::OutputAudioEncoding;
using google::cloud::dialogflow::cx::v3::OutputAudioEncoding_Name;
using google::cloud::dialogflow::cx::v3::SentimentAnalysisResult;
using google::cloud::dialogflow::cx::v3::GcsDestination;
using google::cloud::dialogflow::cx::v3::DtmfInput;
using google::protobuf::RepeatedPtrField;
using google::rpc::Status;
using google::protobuf::Struct;
@@ -81,53 +63,41 @@ public:
const std::string& parseAudio(const StreamingDetectIntentResponse& response);
cJSON* parse(const DetectIntentResponse& o) ;
cJSON* parse(const ResponseMessage& o) ;
cJSON* parse(const ResponseMessage_Text& o) ;
cJSON* parse(const ResponseMessage_ResponseType& o) ;
cJSON* parse(const ResponseMessage_LiveAgentHandoff& o) ;
cJSON* parse(const ResponseMessage_ConversationSuccess& o) ;
cJSON* parse(const ResponseMessage_OutputAudioText& o) ;
cJSON* parse(const ResponseMessage_EndInteraction& o) ;
cJSON* parse(const ResponseMessage_PlayAudio& o) ;
cJSON* parse(const ResponseMessage_MixedAudio& o) ;
cJSON* parse(const ResponseMessage_TelephonyTransferCall& o) ;
cJSON* parse(const ResponseMessage_KnowledgeInfoCard& o) ;
cJSON* parse(const Match& o) ;
cJSON* parse(const AdvancedSettings& o) ;
cJSON* parse(const AdvancedSettings_SpeechSettings& o) ;
cJSON* parse(const AdvancedSettings_DtmfSettings& o) ;
cJSON* parse(const AdvancedSettings_LoggingSettings& o) ;
cJSON* parse(const SynthesizeSpeechConfig& o) ;
cJSON* parse(const OutputAudioEncoding& o) ;
cJSON* parse(const OutputAudioConfig& o) ;
cJSON* parse(const SynthesizeSpeechConfig& o) ;
cJSON* parse(const SsmlVoiceGender& o) ;
cJSON* parse(const VoiceSelectionParams& o) ;
cJSON* parse(const Intent& o) ;
cJSON* parse(const Intent_Parameter& o) ;
cJSON* parse(const QueryInput& o) ;
cJSON* parse(const DtmfInput& o) ;
cJSON* parse(const google::rpc::Status& o) ;
cJSON* parse(const Value& value) ;
cJSON* parse(const Struct& rpcStruct) ;
cJSON* parse(const Intent_Message_SimpleResponses& o) ;
cJSON* parse(const Intent_Message_SimpleResponse& o) ;
cJSON* parse(const Intent_Message_Image& o) ;
cJSON* parse(const Intent_Message_BasicCard_Button_OpenUriAction& o) ;
cJSON* parse(const Intent_Message_BasicCard_Button& o) ;
cJSON* parse(const Intent_Message_Card_Button& o) ;
cJSON* parse(const Intent_Message_BasicCard& o) ;
cJSON* parse(const Intent_Message_Card& o) ;
cJSON* parse(const Intent_Message_Suggestion& o) ;
cJSON* parse(const Intent_Message_Suggestions& o) ;
cJSON* parse(const std::string& val) ;
cJSON* parse(const Intent_Message_LinkOutSuggestion& o) ;
cJSON* parse(const Intent_Message_SelectItemInfo& o) ;
cJSON* parse(const Intent_Message_ListSelect_Item& o) ;
cJSON* parse(const Intent_Message_CarouselSelect& o) ;
cJSON* parse(const Intent_Message_CarouselSelect_Item& o) ;
cJSON* parse(const Intent_Message_ListSelect& o) ;
cJSON* parse(const Intent_Message_TelephonyPlayAudio& o) ;
cJSON* parse(const Intent_Message_TelephonySynthesizeSpeech& o) ;
cJSON* parse(const Intent_Message_TelephonyTransferCall& o) ;
cJSON* parse(const Intent_Message_QuickReplies& o) ;
cJSON* parse(const Intent_Message_Text& o) ;
cJSON* parse(const Intent_TrainingPhrase_Part& o) ;
cJSON* parse(const Intent_WebhookState& o) ;
cJSON* parse(const Intent_TrainingPhrase_Type& o) ;
cJSON* parse(const Intent_TrainingPhrase& o) ;
cJSON* parse(const Intent_Parameter& o) ;
cJSON* parse(const Intent_FollowupIntentInfo& o) ;
cJSON* parse(const Sentiment& o) ;
cJSON* parse(const SentimentAnalysisResult& o) ;
cJSON* parse(const KnowledgeAnswers_Answer_MatchConfidenceLevel& o) ;
cJSON* parse(const KnowledgeAnswers_Answer& o) ;
cJSON* parse(const KnowledgeAnswers& o) ;
cJSON* parse(const Intent& o) ;
cJSON* parse(const google::cloud::dialogflow::v2beta1::Context& o) ;
cJSON* parse(const Intent_Message& msg) ;
cJSON* parse(const QueryResult& qr) ;
cJSON* parse(const StreamingRecognitionResult_MessageType& o) ;
cJSON* parse(const StreamingRecognitionResult& o) ;
cJSON* parse(const GcsDestination& o) ;
cJSON* parse(const QueryResult& qr);
private:
switch_core_session_t *m_session;