diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 09577152b4..318ce26214 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -1069,7 +1069,8 @@ SWITCH_DECLARE(void) switch_dial_handle_list_add_global_var(switch_dial_handle_l SWITCH_DECLARE(void) switch_dial_handle_list_add_global_var_printf(switch_dial_handle_list_t *hl, const char *var, const char *fmt, ...); SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_list_t *hl, switch_call_cause_t *cause); SWITCH_DECLARE(switch_status_t) switch_ivr_orig_and_bridge(switch_core_session_t *session, const char *data, switch_dial_handle_t *dh, switch_call_cause_t *cause); - +SWITCH_DECLARE(switch_status_t) switch_ivr_send_prompt(switch_core_session_t *session, const char *type, const char *text, const char *regex); + SWITCH_DECLARE(switch_status_t) switch_ivr_play_and_collect_input(switch_core_session_t *session, const char *prompt, const char *recognizer_mod_name, diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 7217a207a4..69e87f4aff 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1173,6 +1173,7 @@ typedef enum { SWITCH_MESSAGE_RESAMPLE_EVENT, SWITCH_MESSAGE_HEARTBEAT_EVENT, SWITCH_MESSAGE_INDICATE_SESSION_ID, + SWITCH_MESSAGE_INDICATE_PROMPT, SWITCH_MESSAGE_INVALID } switch_core_session_message_types_t; diff --git a/src/mod/endpoints/mod_verto/mod_verto.c b/src/mod/endpoints/mod_verto/mod_verto.c index e12cc99677..230d0ff615 100644 --- a/src/mod/endpoints/mod_verto/mod_verto.c +++ b/src/mod/endpoints/mod_verto/mod_verto.c @@ -2623,6 +2623,40 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_ } break; + case SWITCH_MESSAGE_INDICATE_PROMPT: + { + const char *type = NULL, *text = NULL, *regex = NULL; + cJSON *jmsg = NULL, *params = NULL; + jsock_t *jsock = NULL; + + if ((jsock = get_jsock(tech_pvt->jsock_uuid))) { + + type = msg->string_array_arg[0]; + text = msg->string_array_arg[1]; + regex = msg->string_array_arg[2]; + + if (type && (!strcasecmp(type, "dtmf") || !strcasecmp(type, "message")) && text) { + jmsg = jrpc_new_req("verto.prompt", tech_pvt->call_id, ¶ms); + + cJSON_AddItemToObject(params, "type", cJSON_CreateString(type)); + cJSON_AddItemToObject(params, "text", cJSON_CreateString(text)); + + if (regex) { + cJSON_AddItemToObject(params, "regex", cJSON_CreateString(regex)); + } + + jsock_queue_event(jsock, &jmsg, SWITCH_TRUE); + + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Parsing Media Params\n"); + r = SWITCH_STATUS_FALSE; + } + + + switch_thread_rwlock_unlock(jsock->rwlock); + } + } + break; case SWITCH_MESSAGE_INDICATE_MEDIA_RENEG: { jsock_t *jsock = NULL; diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 2258824159..4440da639d 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -827,6 +827,8 @@ static const char *message_names[] = { "RING_EVENT", "RESAMPLE_EVENT", "HEARTBEAT_EVENT", + "SESSION_ID", + "PROMPT", "INVALID" }; diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 97bece7c36..ba292376f0 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -1506,6 +1506,22 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess return status; } + +SWITCH_DECLARE(switch_status_t) switch_ivr_send_prompt(switch_core_session_t *session, const char *type, const char *text, const char *regex) +{ + switch_core_session_message_t msg = { 0 }; + + msg.message_id = SWITCH_MESSAGE_INDICATE_PROMPT; + msg.string_array_arg[0] = type; + msg.string_array_arg[1] = text; + msg.string_array_arg[2] = regex; + msg.from = __FILE__; + + switch_core_session_receive_message(session, &msg); + + return SWITCH_STATUS_SUCCESS; +} + SWITCH_DECLARE(switch_status_t) switch_ivr_hold(switch_core_session_t *session, const char *message, switch_bool_t moh) { switch_core_session_message_t msg = { 0 };