Reputation: 807
I am building a BOT application and the bot is showing data based on the data which is fetched after making an API call to CRM.API call is taking time and BOT is showing the response but as the API call is taking long time BOT is showing an error couldnot send but after fetching data it is working properly.How to overcome this.My code is like this
private async Task GetData(IDialogContext context, IAwaitable<string> result)
{
string prescriber = await result;
CRMInteraction crmConnect = new CRMInteraction();
var prescriberdetail = await crmConnect.searchData(prescriber);
this.NormalFlag = true;
await context.PostAsync(prescriberdetail);
context.Done("You are successfully registered.");
}
Upvotes: 0
Views: 42
Reputation: 27825
the API call is taking long time BOT is showing an error couldnot send but after fetching data it is working properly
I can reproduce same issue on my side if I make a request to the API service that is taking long time to return response. In this github issue: "Web chat shows retry but message is really send to bot", we can know the WebChat/DirectLineJS has a 20 second timeout, which would be the cause of this issue.
To solve it, you can try:
1) if possible, optimize your API service to reduce the response time
2) change your code logic: perform fetching data operation in a background task/job and send proactive message to notify the user when fetching data is completed/user is successfully registered.
Note: the following articles can help you know proactive messages, you could check it.
Upvotes: 1