microsoft/BotFramework-DirectLineJS

Consistent 500 Server Error When using postActivity function of DirectLine object

ivanELEC opened this issue · 1 comments

I have a project in ReactJS that uses the ReactWebChat component of botframework-webchat with a DirectLine object for the conversation.

When I retrive the Direct Line object, confirm that the Direct Line is connected and try to use the postActivity function, I am getting a 500 Server error consistently on a POST request made by the postActivity function (conversation ID, name of event, user IDs hidden for privacy:

Request URL:
https://directline.botframework.com/v3/directline/conversations/******************/activities

Request Payload:
{from: "****", name: "", type: "event", value: "Button"}

Error:
Error 500 - {code: "ServiceError"}

Here's an example of the code that handles the postActivity:

if (directLineIn) {
      if (directLineIn) {
        directLineIn.connectionStatus$.subscribe((connectionStatus) => {
          switch (connectionStatus) {
            //show current status of the direct line bot connection
            case ConnectionStatus.Uninitialized: // the status when the DirectLine object is first created/constructed
              console.log("Bot Connection Uninitialized");
              setBotLoading(true);
              break;
            case ConnectionStatus.Connecting: // currently trying to connect to the conversation
              console.log("Bot Connection Connecting");
              break;
            case ConnectionStatus.Online: // successfully connected to the converstaion. Connection is healthy so far as we know.
                  directLineIn
                    .postActivity({
                      from: props.userId,
                      name: "********",
                      type: "event",
                      value: event.detail,
                    })
                    .subscribe(
                      id => console.log("Posted ********* - id: ", id),
                      error => console.log("Error posting activity", error)
                    );
                });
              break;
            case ConnectionStatus.ExpiredToken: // last operation errored out with an expired token. Your app should supply a new one.
              console.log("Bot Token Expired");
              refreshBot();
              break;
            case ConnectionStatus.FailedToConnect: // the initial attempt to connect to the conversation failed. No recovery possible.
              console.log("Bot Failed to Connect");
              refreshBot();
              break;
            case ConnectionStatus.Ended: // the bot ended the conversation
              console.log("Bot Connection Ended");
              break;
          }
        });
      }

This has worked for us for a while but recently, each time we attempt this call we get an error.

hi @ivanELEC Do you see any more/additional information in the bot's Channels blade for Direct Line channel?