drachtio / drachtio-freeswitch-modules

A collection of open-sourced freeswitch modules that I use in various drachtio applications
MIT License
171 stars 119 forks source link

Change mod_dialogflow to receive optional parameter for enabling sentiment analysis #100

Closed ruipfmendes closed 1 year ago

ruipfmendes commented 1 year ago

Description

Why

What

StreamingDetectIntent request ( https://cloud.google.com/dialogflow/es/docs/reference/rpc/google.cloud.dialogflow.v2beta1#google.cloud.dialogflow.v2beta1.StreamingDetectIntentRequest ) allows sending query params:

The first message must contain session, query_input plus optionally query_params.

The query parameters (see here: https://cloud.google.com/dialogflow/es/docs/reference/rpc/google.cloud.dialogflow.v2beta1#google.cloud.dialogflow.v2beta1.QueryParameters ) can allow to set fields such as sentiment_analysis_request_config (enables sentiment analysis)

Tests

davehorton commented 1 year ago

@ruipfmendes is it not necessary to add logic to the parser to return sentiment results?

ruipfmendes commented 1 year ago

@ruipfmendes is it not necessary to add logic to the parser to return sentiment results?

it seems that logic is already implemented in the parser here

I tested and got this result json in my logs which contains the sentiment_analysis_result:

mod_dialogflow.c:26 json payload for type dialogflow::intent: 
{
    ...
   "query_result":{
      ...
      "sentiment_analysis_result":{
         "query_text_sentiment":{
            "score":0.89999997615814209,
            "magnitude":0.89999997615814209
         }
      },
      ...
}