botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Bot Framework: Typing indicator issue

Open tinuCoder opened this issue 8 years ago • 5 comments

Bot Info

  • SDK Platform: .Net
  • SDK Version: v3
  • Active Channels: Directline
  • Deployment Environment: Azure App Servic

Issue Description

  1. Typing indicator is not working with Directline channel when websocket flag is kept as "false" Due to our company's internal security policy I am unable to make websocket as "true".

  2. Wanted to understand why this feature not available on "https" also keen to find if there is any other way i can get typing indicator for my chat bot.

  3. This is the only issue that i have faced so far from directline channel, what is required to request to make typing indicator available on "https"

Code Example

                    MicrosoftAppCredentials.TrustServiceUrl(activity.ServiceUrl, DateTime.MaxValue);
                    ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
                    Activity typingActivity = activity.CreateReply();
                    typingActivity.Type = ActivityTypes.Typing;
                    await connector.Conversations.SendToConversationAsync(typingActivity);

Awaiting reply. Thanks in advance

tinuCoder avatar May 26 '18 07:05 tinuCoder

Typing activity types are not queued to be retrieved later. This implementation is within the Direct Line server itself. There is an explanation here: https://github.com/Microsoft/BotBuilder/issues/3635#issuecomment-340818330 and here: https://github.com/Microsoft/BotFramework-WebChat/issues/872

A workaround might be to send an event from the bot, then turn that event into a 'typing' activity client side before it is processed. Something like:

        const ownDirectLine = new BotChat.DirectLine({
            secret: 'YourSecret',
            webSocket: false
        });

        const mappedActivity$ = ownDirectLine.activity$.map(activity => {
            if (activity.type === 'event' && activity.name === 'typing') {
                return { ...activity, type: 'typing' };
            } else {
                return activity;
            }
        });

        ownDirectLine.activity$ = mappedActivity$;

        BotChat.App({
            botConnection: ownDirectLine,
            user: { id: 'userid' },
            bot: { id: 'botid' },
            resize: 'detect'
        }, document.getElementById("bot"));

.net sdk server side:

        private async Task SendTyping(Activity activity)
        {
            var client = new ConnectorClient(new Uri(activity.ServiceUrl));
            var r = activity.CreateReply();
            if (activity.ChannelId == ChannelIds.Webchat || activity.ChannelId == ChannelIds.Directline)
            {
                r.Type = ActivityTypes.Event;
                r.Name = "typing";
            }
            else
            {
                r.Type = ActivityTypes.Typing;
            }

            await client.Conversations.SendToConversationAsync(r);
        }

(Thanks to https://github.com/compulim for help with the .js syntax for this)

EricDahlvang avatar May 31 '18 00:05 EricDahlvang

I'm going to close this issue, since the two issues I referenced are still open and tracking the 'problem'.

EricDahlvang avatar May 31 '18 00:05 EricDahlvang

Help me!

Thomas

On Sat, May 26, 2018, 00:12 tinuCoder [email protected] wrote:

Bot Info

  • SDK Platform: .Net
  • SDK Version: v3
  • Active Channels: Directline
  • Deployment Environment: Azure App Servic

Issue Description

Typing indicator is not working with Directline channel when websocket flag is kept as "false" Due to our company's internal security policy I am unable to make websocket as "true". 2.

Wanted to understand why this feature not available on "https" also keen to find if there is any other way i can get typing indicator for my chat bot. 3.

This is the only issue that i have faced so far from directline channel, what is required to request to make typing indicator available on "https"

Code Example

                MicrosoftAppCredentials.TrustServiceUrl(activity.ServiceUrl, DateTime.MaxValue);
                ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
                Activity typingActivity = activity.CreateReply();
                typingActivity.Type = ActivityTypes.Typing;
                await connector.Conversations.SendToConversationAsync(typingActivity);

Awaiting reply. Thanks in advance

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BotBuilder/issues/4663, or mute the thread https://github.com/notifications/unsubscribe-auth/AM3U2ZVeaU0zDG3xHujDOjgG6HmG9aD9ks5t2QBxgaJpZM4UO0Cn .

Tcoop69 avatar Aug 06 '18 17:08 Tcoop69

@customcoops77 What can we do for you? Please try opening a new issue: https://github.com/Microsoft/BotBuilder/issues/new

EricDahlvang avatar Aug 06 '18 17:08 EricDahlvang

//custom code to support 'typing event' in WebChat, thanks to: https://github.com/Microsoft/BotBuilder/issues/4663#issuecomment-393359111
--
var customActivity$ = directLine.activity$.map(function (activity) {
if (activity.type === 'event' && activity.name === 'typing') {
return Object.assign({}, activity, { type: 'typing' });
}
else
return activity;
});
directLine.activity$ = customActivity$;

This works in Chrome but somehow does not work in IE... the pooling does not work, no messages are shown...

JobaDiniz avatar Sep 26 '19 21:09 JobaDiniz