question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proactive Message Delay in Client

See original GitHub issue

This is a bit of an overlapping issue between Sdk / Composer / Client, however posting it here.

I have developed an handoff integration with Genesys that is built around a websocket that calls ContinueConversationAsync when a new message arrives from the agent :

private async Task SendActivity(string eventName, string text = null, object data = null)
{
    await DialogContext.Context.Adapter.ContinueConversationAsync(_claimsIdentity, _conversationReference, new BotCallbackHandler(async (turnContext, cancellationToken) =>
    {
        turnContext.Activity.Type = ActivityTypes.Event;
        turnContext.Activity.Name = eventName;
        turnContext.Activity.Text = text;
        turnContext.Activity.Value = data;
        await _callbackHandler(turnContext, cancellationToken);
    }), default);
}

This is then picked up in Composer and send to the user: image

The speed at which the message arrives at the client (emulator in this scenario) is within a second. However before it is actually displayed another 6 seconds pass.

So in the screenshot below the yellow marked “ola” arrives almost instantaneously but 6 seconds pass before it is displayed in the chat itself. image

What is causing this?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:19 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
rbohaccommented, Jun 16, 2021

In the botbuilder-dotnet source within ActivityEx.cs:535 it sets the replyToId to the value contained in Activity.Id of the turnContext. I’m not sure if there is a valid reason to ever do this on a proactive message.

However I was able to find a workaround. When sending the proactive message you can null Activity.Id and the framework will end up passing null in the replyToId field, which then eliminates the queueing delay in the webchat client

public async Task<IActionResult> Get()
       {
           foreach (var conversationReference in _conversationReferences.Values)
           {
               await ((BotAdapter)_adapter).ContinueConversationAsync(_appId, conversationReference,
                               async (ITurnContext turnContext2, CancellationToken cancellationToken2) =>
                               {
                                   var activity = MessageFactory.Text("proactive hello 2");                                   
                                   turnContext2.Activity.Id = "";
                                   await turnContext2.SendActivityAsync(activity);
                               }
                               , default(CancellationToken));
           }
           return new ContentResult()
           {
               Content = "<html><body><h1>Proactive messages have been sent.</h1></body></html>",
               ContentType = "text/html",
               StatusCode = (int)HttpStatusCode.OK,
           };
       }
1reaction
MikeCardiffcommented, May 24, 2021

Just wanted to chime in and say I’m also experiencing this issue using webchat/directline. We’re using proactive messages for handoff and inactivity prompts.

Here’s the websocket messages from a conversation resumed from the directline cache in case it’s of any help. The bottom two are the delayed proactive messages. They are recieved at the same time as other messages but have a delay before being shown in UI. image

Could the issue be related to the activity replyToId? The value set on proactive messages does not match any in the conversation. Prehaps webchat is waiting to find the matching ID before showing the message?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Recipe: Delay your proactive messages to give customers a ...
Another solution is to delay all your proactive messages. This gives visitors the opportunity to notice the chat option, and manually request a ......
Read more >
Send proactive messages - Teams | Microsoft Learn
A proactive message is any message sent by a bot that isn't in response to a request from a user. This message can...
Read more >
5 Ways to Navigate Shipping Delays with Proactive Customer ...
5 Ways to Navigate Shipping Delays with Proactive Customer Service · 1. Be upfront and honest. · 2. Address the issue before it...
Read more >
How to Communicate Delivery Delays: 7 Excellent Email ...
B. Proactive notifications regarding stalled shipments ... Delays happen. When they do, it's best to alert the customer you're aware of the issue...
Read more >
Provide Help Before It's Needed With Proactive Support
Why proactive support is your first line of defense 1 min; Preemptively identify recurring customer issues 3 min; 4 proactive messages to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found