I will deploy on my server my app that has two handlers, 1 for Alexa, and 1 for Google conversational, both are working. I would like to know how is possible to make them work simultaneously (if two people ask the same intent in the same moment it crashes).
Problem with same webhook for two handlers
const alexaHandlers = ({
async PlayIntent() {
Id = this.getUserId() + this.getDeviceId();
await this.readData();
console.log(‘PLAY’);
console.log('offset: ’ + offset);
let stream = streamingRadio;
if (streamingRadio == ‘’) {
stream = '’;
}
let urlTest = (stream.split(":"))[0];
if (urlTest == ‘https’ || urlTest == ‘http’) {
this.$alexaSkill.$audioPlayer
.setOffsetInMilliseconds(0)
.play(stream, ‘token’);
console.log(streamingRadio);
} else {
this.tell(‘Mi dispiace, non posso riprodurre questo audio’);
}
},
AUDIOPLAYER: {
‘AlexaSkill.PlaybackStarted’ () {
console.log(‘AlexaSkill.PlaybackStarted’)
},
‘AlexaSkill.PlaybackNearlyFinished’ () {
console.log(‘AlexaSkill.PlaybackNearlyFinished’);
},
‘AlexaSkill.PlaybackFinished’ () {
console.log(‘AlexaSkill.PlaybackFinished’);
this.$alexaSkill.$audioPlayer.stop();
},
‘AlexaSkill.PlaybackStopped’ () {
console.log(‘AlexaSkill.PlaybackStopped’)
},
‘AlexaSkill.PlaybackFailed’ () {
console.log(‘AlexaSkill.PlaybackFailed’);
},
},
});
const googleAssistantHandlers = ({
async PlayIntent() {
Id = this.getUserId();
await this.readData();
console.log(‘PLAY’);
console.log('offset: ’ + offset);
let stream = streamingRadio;
if (streamingRadio == ‘*’) {
stream = ‘*’;
}
//controllo url, verifico se è in https
let urlTest = (stream.split(":"))[0];
if (urlTest == ‘https’) {
this.$googleAction.$audioPlayer.playAudio({
name: ’ ’ + radioName,
description: ‘Adesso in ripduzione’,
url: " " + stream,
image: {
large: {
alt: ’ ’ + radioName,
height: 0,
url: ‘*’,
width: 0,
},
},
});
this.tell(“Mi sto collegando alla diretta”);
} else {
}
console.log(“TEST”);
return;
},
‘AUDIOPLAYER’: {
‘GoogleAction.PlaybackStarted’ () {
console.log(‘GoogleAction.PlaybackStarted’)
},
‘GoogleAction.Paused’ () {
// no response posible
this.tell(‘Playback paused’);
},
‘GoogleAction.Stopped’ () {
// no response posible
},
‘GoogleAction.Finished’ () {
this.tell(‘Playback finished’);
},
‘GoogleAction.Failed’ () {
this.tell(‘Playback failed’);
},
},
});
app.setPlatformHandler(‘Alexa’, alexaHandlers);
app.setPlatformHandler(‘GoogleAssistant’, googleAssistantHandlers);
module.exports.app = app;
This is the first function that I have tested in the same moment on both platforms and didn’t work.