@tiledesk/tiledesk-voice-twilio-connector 0.1.26-rc11 → 0.1.26-rc12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -145,7 +145,8 @@ router.post('/webhook/:id_project', async (req, res) => {
145
145
 
146
146
  const tdTranslator = new TiledeskTwilioTranslator({
147
147
  BASE_URL: BASE_URL,
148
- aiService: aiService
148
+ aiService: aiService,
149
+ uploadService: uploadService
149
150
  });
150
151
 
151
152
  let start2 = new Date().getTime();
@@ -226,7 +227,7 @@ router.post('/webhook/:id_project', async (req, res) => {
226
227
  let start_time_get_message = new Date()
227
228
  let message = await getMessage(callSid, from, project_id, conversation_id)
228
229
  let end_time_get_message = new Date()
229
- winston.verbose('Time to getMessage from queue in /webhook/:project_id : ' + (end_time_get_message-start_time_get_message) + '[ms] --- at time:' + new Date())
230
+ winston.verbose(`Time to getMessage from queue in /webhook/:${project_id} : ${(end_time_get_message-start_time_get_message)}[ms] --- at time:` + new Date())
230
231
 
231
232
  // //generate Tiledesk wait message
232
233
  // let delayTime = await voiceChannel.getNextDelayTimeForCallId(callSid)
@@ -1365,7 +1366,7 @@ async function connectRedis() {
1365
1366
 
1366
1367
 
1367
1368
  redis_client.on('error', err => {
1368
- winston.debug('(voice) Connect Redis Error ' + err);
1369
+ winston.error('(voice) Connect Redis Error ' + err);
1369
1370
  })
1370
1371
  /*
1371
1372
  redis_client.on('connect', () => {
package/logs/app.log CHANGED
@@ -2988,3 +2988,95 @@ info: (voice) Starting Manage Route
2988
2988
  info: (voice)-MANAGE API_URL: https://tiledesk-server-pre.herokuapp.com
2989
2989
  info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
2990
2990
  info: (voice)-MANAGE redis_client: [object Object]
2991
+ info: (voice) Starting VOICE TWILIO App
2992
+ info: (voice) Starting Manage Route
2993
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
2994
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
2995
+ info: (voice)-MANAGE redis_client: [object Object]
2996
+ info: (voice) Starting VOICE TWILIO App
2997
+ info: (voice) Starting Manage Route
2998
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
2999
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3000
+ info: (voice)-MANAGE redis_client: [object Object]
3001
+ error: undefined {"name":"MongoServerSelectionError","reason":{"commonWireVersion":null,"compatibilityError":null,"compatible":true,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"logicalSessionTimeoutMinutes":null,"maxElectionId":null,"maxSetVersion":null,"servers":{},"setName":null,"stale":false,"type":"Single"}}
3002
+ info: (voice) Starting VOICE TWILIO App
3003
+ info: (voice) Starting Manage Route
3004
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3005
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3006
+ info: (voice)-MANAGE redis_client: [object Object]
3007
+ error: undefined {"name":"MongoServerSelectionError","reason":{"commonWireVersion":null,"compatibilityError":null,"compatible":true,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"logicalSessionTimeoutMinutes":null,"maxElectionId":null,"maxSetVersion":null,"servers":{},"setName":null,"stale":false,"type":"Single"}}
3008
+ info: (voice) Starting VOICE TWILIO App
3009
+ info: (voice) Starting Manage Route
3010
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3011
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3012
+ info: (voice)-MANAGE redis_client: [object Object]
3013
+ info: (voice) Starting VOICE TWILIO App
3014
+ info: (voice) Starting Manage Route
3015
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3016
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3017
+ info: (voice)-MANAGE redis_client: [object Object]
3018
+ info: (voice) Starting VOICE TWILIO App
3019
+ info: (voice) Starting Manage Route
3020
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3021
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3022
+ info: (voice)-MANAGE redis_client: [object Object]
3023
+ error: undefined {"name":"MongoServerSelectionError","reason":{"commonWireVersion":null,"compatibilityError":null,"compatible":true,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"logicalSessionTimeoutMinutes":null,"maxElectionId":null,"maxSetVersion":null,"servers":{},"setName":null,"stale":false,"type":"Single"}}
3024
+ info: (voice) Starting VOICE TWILIO App
3025
+ info: (voice) Starting Manage Route
3026
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3027
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3028
+ info: (voice)-MANAGE redis_client: [object Object]
3029
+ info: (voice) Starting VOICE TWILIO App
3030
+ info: (voice) Starting Manage Route
3031
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3032
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3033
+ info: (voice)-MANAGE redis_client: [object Object]
3034
+ info: (voice) Starting VOICE TWILIO App
3035
+ info: (voice) Starting Manage Route
3036
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3037
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3038
+ info: (voice)-MANAGE redis_client: [object Object]
3039
+ error: undefined {"name":"MongoServerSelectionError","reason":{"commonWireVersion":null,"compatibilityError":null,"compatible":true,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"logicalSessionTimeoutMinutes":null,"maxElectionId":null,"maxSetVersion":null,"servers":{},"setName":null,"stale":false,"type":"Single"}}
3040
+ info: (voice) Starting VOICE TWILIO App
3041
+ info: (voice) Starting Manage Route
3042
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3043
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3044
+ info: (voice)-MANAGE redis_client: [object Object]
3045
+ error: undefined {"name":"MongoServerSelectionError","reason":{"commonWireVersion":null,"compatibilityError":null,"compatible":true,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"logicalSessionTimeoutMinutes":null,"maxElectionId":null,"maxSetVersion":null,"servers":{},"setName":null,"stale":false,"type":"Single"}}
3046
+ info: (voice) Starting VOICE TWILIO App
3047
+ info: (voice) Starting Manage Route
3048
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3049
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3050
+ info: (voice)-MANAGE redis_client: [object Object]
3051
+ info: (voice) Starting VOICE TWILIO App
3052
+ info: (voice) Starting Manage Route
3053
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3054
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3055
+ info: (voice)-MANAGE redis_client: [object Object]
3056
+ info: (voice) Starting VOICE TWILIO App
3057
+ info: (voice) Starting Manage Route
3058
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3059
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3060
+ info: (voice)-MANAGE redis_client: [object Object]
3061
+ error: undefined {"name":"MongoServerSelectionError","reason":{"commonWireVersion":null,"compatibilityError":null,"compatible":true,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"logicalSessionTimeoutMinutes":null,"maxElectionId":null,"maxSetVersion":null,"servers":{},"setName":null,"stale":false,"type":"Single"}}
3062
+ info: (voice) Starting VOICE TWILIO App
3063
+ info: (voice) Starting Manage Route
3064
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3065
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3066
+ info: (voice)-MANAGE redis_client: [object Object]
3067
+ info: (voice) Starting VOICE TWILIO App
3068
+ info: (voice) Starting Manage Route
3069
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3070
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3071
+ info: (voice)-MANAGE redis_client: [object Object]
3072
+ error: undefined {"name":"MongoServerSelectionError","reason":{"commonWireVersion":null,"compatibilityError":null,"compatible":true,"heartbeatFrequencyMS":10000,"localThresholdMS":15,"logicalSessionTimeoutMinutes":null,"maxElectionId":null,"maxSetVersion":null,"servers":{},"setName":null,"stale":false,"type":"Single"}}
3073
+ info: (voice) Starting VOICE TWILIO App
3074
+ info: (voice) Starting Manage Route
3075
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3076
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3077
+ info: (voice)-MANAGE redis_client: [object Object]
3078
+ info: (voice) Starting VOICE TWILIO App
3079
+ info: (voice) Starting Manage Route
3080
+ info: (voice)-MANAGE API_URL: https://stage.eks.tiledesk.com/api
3081
+ info: (voice)-MANAGE BASE_URL: https://pw99h2hr-3000.euw.devtunnels.ms
3082
+ info: (voice)-MANAGE redis_client: [object Object]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-voice-twilio-connector",
3
- "version": "0.1.26-rc11",
3
+ "version": "0.1.26-rc12",
4
4
  "description": "Tiledesk VOICE Twilio connector",
5
5
  "license": "MIT",
6
6
  "author": "Gabriele Panico",
@@ -77,7 +77,14 @@ class TiledeskTwilioTranslator {
77
77
  vxmlAttributes.TTS_MODEL = flowAttributes.TTS_MODEL? flowAttributes.TTS_MODEL : OPENAI_SETTINGS.TTS_MODEL;
78
78
  vxmlAttributes.STT_MODEL = flowAttributes.STT_MODEL? flowAttributes.STT_MODEL : OPENAI_SETTINGS.STT_MODEL;
79
79
  }
80
-
80
+
81
+ // IF VOICE_PROVIDER is ELEVENLABS --> default values is on user account twilio settings
82
+ // IF VOICE_PROVIDER is ELEVENLABS --> set default values from constants
83
+ if(this.voiceProvider === VOICE_PROVIDER.ELEVENLABS){
84
+ vxmlAttributes.TTS_VOICE_NAME = flowAttributes.TTS_VOICE_NAME? flowAttributes.TTS_VOICE_NAME : ELEVENLABS_SETTINGS.TTS_VOICE_NAME;
85
+ vxmlAttributes.TTS_MODEL = flowAttributes.TTS_MODEL? flowAttributes.TTS_MODEL : ELEVENLABS_SETTINGS.TTS_MODEL;
86
+ vxmlAttributes.TTS_VOICE_LANGUAGE = flowAttributes.TTS_VOICE_LANGUAGE? flowAttributes.TTS_VOICE_LANGUAGE : ELEVENLABS_SETTINGS.TTS_VOICE_LANGUAGE;
87
+ }
81
88
 
82
89
  }
83
90
 
@@ -633,7 +640,7 @@ class TiledeskTwilioTranslator {
633
640
  break;
634
641
  case VOICE_PROVIDER.ELEVENLABS:
635
642
  let ELEVENLABS_APIKEY = this.integrations.find((el => el.type === VOICE_PROVIDER.ELEVENLABS))?.key
636
- audioData = await this.aiService.textToSpeechElevenLabs(text, attributes.TTS_VOICE_NAME, attributes.TTS_MODEL, ELEVENLABS_APIKEY).catch((err)=>{
643
+ audioData = await this.aiService.textToSpeechElevenLabs(text, attributes.TTS_VOICE_NAME, attributes.TTS_MODEL, attributes.TTS_VOICE_LANGUAGE, ELEVENLABS_APIKEY).catch((err)=>{
637
644
  console.log('errr while creating elevenlabs audio message', err.response?.data)
638
645
  })
639
646
  break;
@@ -58,5 +58,10 @@ module.exports = {
58
58
  TTS_VOICE_NAME: 'alloy',
59
59
  TTS_MODEL: 'tts-1',
60
60
  STT_MODEL: 'whisper-1'
61
+ },
62
+ ELEVENLABS_SETTINGS:{
63
+ TTS_VOICE_NAME: '21m00Tcm4TlvDq8ikWAM',
64
+ TTS_MODEL: 'eleven_multilingual_v2',
65
+ TTS_VOICE_LANGUAGE: 'en'
61
66
  }
62
67
  }
@@ -50,7 +50,7 @@ class AiService {
50
50
  formData.append('model', model);
51
51
 
52
52
  axios({
53
- url: this.OPENAI_ENDPOINT + "/audio/transcriptions",
53
+ url: `${this.OPENAI_ENDPOINT}/audio/transcriptions`,
54
54
  headers: {
55
55
  ...formData.getHeaders(),
56
56
  "Authorization": "Bearer " + GPT_KEY
@@ -81,7 +81,7 @@ class AiService {
81
81
 
82
82
  return new Promise((resolve, reject) => {
83
83
  axios({
84
- url: this.OPENAI_ENDPOINT + "/audio/speech",
84
+ url: `${this.OPENAI_ENDPOINT}/audio/speech`,
85
85
  headers: {
86
86
  "Content-Type": "application/json",
87
87
  "Authorization": "Bearer " + GPT_KEY
@@ -125,7 +125,7 @@ class AiService {
125
125
  formData.append('language_code', language)
126
126
 
127
127
  axios({
128
- url: this.ELEVENLABS_ENDPOINT + "/v1/speech-to-text",
128
+ url: `${this.ELEVENLABS_ENDPOINT}/v1/speech-to-text`,
129
129
  headers: {
130
130
  ...formData.getHeaders(),
131
131
  "xi-api-key": API_KEY
@@ -133,31 +133,26 @@ class AiService {
133
133
  data: formData,
134
134
  method: 'POST'
135
135
  }).then((resbody) => {
136
- console.log('dataaaaaa', resbody)
137
136
  resolve(resbody.data.text);
138
137
  }).catch((err) => {
139
- console.log('errrrrrr', err?.response)
140
138
  reject(err);
141
139
  })
142
140
 
143
141
  })
144
142
  }
145
143
 
146
- async textToSpeechElevenLabs(text, voice_id, model, API_KEY){
147
-
144
+ async textToSpeechElevenLabs(text, voice_id, model, language_code, API_KEY){
148
145
 
149
146
  const data = {
150
147
  model_id: model,
151
148
  text: text,
152
- output_format: "mp3_44100_128",
149
+ language_code: language_code
153
150
  };
154
-
155
-
156
151
  winston.debug('[AiService] ELEVEN Labs textToSpeech config:', data)
157
152
 
158
153
  return new Promise((resolve, reject) => {
159
154
  axios({
160
- url: this.ELEVENLABS_ENDPOINT + "/v1/text-to-speech/"+ voice_id,
155
+ url: `${this.ELEVENLABS_ENDPOINT}/v1/text-to-speech/${voice_id}?output_format=mp3_44100_128`,
161
156
  headers: {
162
157
  "Content-Type": "application/json",
163
158
  "xi-api-key": API_KEY
@@ -185,7 +180,7 @@ class AiService {
185
180
  return new Promise((resolve, reject) => {
186
181
 
187
182
  axios({
188
- url: this.API_URL + "/" + projectId + "/quotes/tokens",
183
+ url: `${this.API_URL}/${projectId}/quotes/tokens`,
189
184
  headers: {
190
185
  'Content-Type': 'application/json',
191
186
  'Authorization': token