Referencing https://github.com/Microsoft/BotFramework-WebChat/issues/1179
Is this still possible in v4? I can't seem to find lastInputViaSpeech in the repository. How do I tell the bot to always speak whatever it is trying to say?
lastInputViaSpeech appears to be a Web Chat v3 feature that is no longer compatible with v4. I'm inclined to say this was intentionally removed because the intended action of a bot is to use speech only when spoken to, see Enable Web Chat docs (second paragraph)
However the issue you linked appears to disagree with that. @compulim, do you have input? Have there been changes in the past over how speech bots should function?
What's the design reason as to why you only want the bot to speak if microphone was used by the user? To me that's a limiting functionality. I want the bot to speak at a welcome chat or always talk for accessibility issue without having to require the user to speak. What if the user can't talk but requires to hear what the bot is saying?
@corinagum Could you try out something?
store.dispatch({ type: 'WEB_CHAT/START_SPEAKING' })echo ABC in Web ChatHey @leolorenzoluis, @compulim and I had a fun discussion about this today and got this non-recommended workaround code to work: (it's a bit hack-y)
const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
console.log(action.type);
if(action.type === 'DIRECT_LINE/INCOMING_ACTIVITY' && action.payload.activity.from.role !== 'user') {
// We need to postpone the dispatch because we need to wait until the reducer adds this activity to the store, before we can mark it to be spoken.
setImmediate(() => {
store.dispatch({ type: 'WEB_CHAT/MARK_ACTIVITY', payload: { activityID: action.payload.activity.id, name: 'speak', value: true } });
});
}
return next(action);
});
Meanwhile, we are waiting to continue discussion on whether we want to use channel data to pass customization to Web Chat. This would be a flag indicating that the bot should always speak incoming activities from the bot, regardless if the user begins typing in the sendbox. I'll update this issue again once that discussion has taken place. :)
Although hacky, workaround provided is sufficient for now. Web Chat team would like to discuss this UX with a conversation designer before implementing any code changes.
This is also related to #2211. When we implement the feature, it will fix this issue.
Closing this. Please follow https://github.com/microsoft/BotFramework-WebChat/issues/2211 for updated to this issue.
Most helpful comment
What's the design reason as to why you only want the bot to speak if microphone was used by the user? To me that's a limiting functionality. I want the bot to speak at a welcome chat or always talk for accessibility issue without having to require the user to speak. What if the user can't talk but requires to hear what the bot is saying?