BotFramework-WebChat icon indicating copy to clipboard operation
BotFramework-WebChat copied to clipboard

Is it possible to make speech option by default option instead of text in bot framework

Open UsamaAslam opened this issue 8 years ago • 13 comments

i was searching for the method to make speaker by default like only voice bot no text like alexa in Microsoft Bot framework. How can i make the bot that start with voice message by default and user don't have to press the speaker option form chat BOT window for reply back just like siri and other . Please help me .

UsamaAslam avatar Jul 12 '18 06:07 UsamaAslam

Whenever you receive a message from user, you would need to dispatch the start_listening action.

To remove the text box you would need to update the render method in shell.tsx

Kartik1607 avatar Jul 12 '18 14:07 Kartik1607

There's currently no way for speak by default on Web Chat, but it is on the way from Web Chat v.Next.

If you would like to implement a temporary fix yourself, you can navigate to Store.ts L589 on your own build and make the check always-true so that the bot is always listening after speak.

corinagum avatar Jul 13 '18 00:07 corinagum

One more thing. On iOS, Safari requires user interaction to enable speech support. That means, without asking the user to click a button, speech recognition/synthesis will not work.

compulim avatar Jul 27 '18 06:07 compulim

@compulim Do you have an example in Javascript so that the voice conversation works in Safaria / IOS? Thanks

serpino avatar Aug 06 '18 10:08 serpino

I'm creating a bot which accept text and voice input and also can answer in both mode. The bot works really good but i have to click always the button of microphone to speak with the bot. Do you know it is possible to make microphone always on and to recognize the voice without clicking the button of microphone ? @corinagum @Kartik1607 @compulim @serpino

UsamaAslam avatar Oct 25 '18 16:10 UsamaAslam

The microphone does get enabled automatically. But there are certain conditions which must be met for it to happen.

In the start the microphone and speech are disabled by default. Once a user clicks the mic button, the microphone and speech would be enabled for all subsequent messages.

The microphone will only be enabled if and only if the message from bot expects input . Usually there are messages of type prompt. Whenever you want the microphone to be enabled automatically, you would need to add expects input in the message.

Kartik1607 avatar Oct 25 '18 16:10 Kartik1607

can you share some sort of code that explain this concept ? @Kartik1607 i will be grateful thanks in advance .

UsamaAslam avatar Oct 25 '18 16:10 UsamaAslam

Sure, I'll give out an example. But you'll have to wait till tomorrow morning. I am on mobile right now.

Kartik1607 avatar Oct 25 '18 16:10 Kartik1607

okay .. no problem

thanks

UsamaAslam avatar Oct 25 '18 16:10 UsamaAslam

Still waiting for you comment @Kartik1607

thanks

UsamaAslam avatar Oct 26 '18 12:10 UsamaAslam

Hi. Sorry for late reply. I got busy doing a side project to build UI for bot dispatcher. I believe you are using webchat v3.

For auto listen part, have a look at this line

autoListenAfterSpeak : (msg.inputHint === 'expectingInput') || (msg.channelData && msg.channelData.botState === 'WaitingForAnswerToQuestion')

This shows that webchat will enable mic automatically if any one of the above conditions is met in message.

To add inputHint in the message, you can simply either use a message of type prompt, or you can explicitly add it to your outgoing message in your bot code.

public async Task AskAsync(IDialogContext context, string text)
{
    var msg = context.MakeMessage();
    msg.Text = text;
    msg.InputHint =  "expectingInput";
    await context.PostAsync(msg);
}

This, means if you send a normal message like context.PostAsync("Hello for bot"), the mic will not be enabled automatically. So, whenever you need user input in form of voice, you need to make sure to add inputHint in the message.

Do you also want to enable voice from starting? Generally this would be bad UX design, as to enable mic you would need to ask for permission explicitly and not all users may want mic input. You can modify your code as above to enable mic automatically once a user has clicked the mic button.

As a side not, I am not a fan of mic button in webchat. I would prefer an animating mic like you see in other AI assistant like Siri, Cortana etc. The webchat mic button just changes the color and is not that great at retaining user attention when it is listening.

Kartik1607 avatar Oct 26 '18 13:10 Kartik1607

point them to the sample we have that shows how to do this

sgellock avatar Oct 30 '18 17:10 sgellock

We created a new bug #1401 to track the "always-on microphone" feature/sample.

compulim avatar Nov 27 '18 21:11 compulim