Skip to content

postActivity responses to an Invoke return the string 'retry' #260

Open

Description

If you send an InvokeActivity to postActivity via dljs, a success will return an id with the activity ID. However, an Invoke can return other status codes for error/failure cases. When this happens, postActivity still calls the "success" trigger but with an id of 'retry'.

Repro code:

directLine.postActivity({
type: 'invoke',
name: 'good'
}).subscribe(
id => {
console.log("Posted activity, assigned ID ", id); // this is called with a real id
},
error => {
console.log("Error posting activity", error);
}
);

directLine.postActivity({
type: 'invoke',
name: 'bad'
}).subscribe(
id => {
console.log("Posted activity, assigned ID ", id); // this is called with an id of 'retry'
},
error => {
console.log("Error posting activity", error);
}
);

For the boy, just handle invokes and return an InvokeResponse of 409 or whatnot in that bad case, and an InvokeResponse of 200 in the good case:

Here is some C# code to do this:

protected override async Task OnInvokeActivityAsync(ITurnContext turnContext, CancellationToken cancellationToken)
{
await turnContext.SendActivityAsync("Got an invoke: " + turnContext.Activity.Name);
if (turnContext.Activity.Name == "good")
{
await turnContext.SendActivityAsync(
new Activity
{
Type = ActivityTypesEx.InvokeResponse,
Value = new InvokeResponse
{
Status = 200
},
}, cancellationToken).ConfigureAwait(false);
}
else if (turnContext.Activity.Name == "bad")
{
await turnContext.SendActivityAsync(
new Activity
{
Type = ActivityTypesEx.InvokeResponse,
Value = new InvokeResponse
{
Status = 409
},
}, cancellationToken).ConfigureAwait(false);
}
else
{
await base.OnInvokeActivityAsync(turnContext, cancellationToken);
}
}

Expected behavior:

(1) At least the error case should be called.
(2) It'd be nice to get the actual result code, or the 502 saying message wasn't processed properly by the bot if that's all DirectLine returns

Activity

  1. akirilyuk commented on May 25, 2020

    @akirilyuk

    Any update on this? The issue is open since January, no proper debugging is possible if the error is swallowed. Also because of how this lib is build its impossible to set a breakpoint in code because it is dynamically compiled during runtime....

  2. vadimceb commented on Jul 6, 2022

    @vadimceb

    Any news? Two years later and still have this error.
    Deployed the bot with latest BotFrameworkComposer and updated this package.
    By the way, when using the emulator the bot responds correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions