microsoft / microsoft/BotFramework-DirectLineJS
postActivity responses to an Invoke return the string 'retry'
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 199
- Forks
- 133
- PR merge metrics
- No merged PRs in 30d
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the postActivity entry point and trace how Invoke responses are mapped to the observable's success and error paths. Reproduce the good and bad Invoke cases from the issue, then verify that non-success status responses no longer emit the literal 'retry' as a successful activity ID.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100