web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / DirectLine invoke post...
Copilot Studio
Suggested Answer

DirectLine invoke postActivity returns 502 in Network though bot processes successfully

(1) ShareShare
ReportReport
Posted on by 63

I am using Direct Line to send feedback data from the frontend to a bot using postActivity with an invoke activity.

Here is the code I’m using:

directLine.postActivity({
    type: 'invoke',
    name: 'message/submitAction',
    value: {
        actionName: 'feedback',
        actionValue: {
            feedback: { feedbackText: feedbackText || defaultFeedbackText },
            reaction: reaction
        },
        activityId: activityId
    },
    from: { id: user.employeeId, name: user.userName }
}).subscribe(
    id => console.log('Feedback sent, activityId:', id),
    error => console.error('Error sending feedback:', error)
);

Observed Behavior

  • The bot successfully receives and processes the feedback

  • Data (feedback text, reaction, etc.) is correctly stored

  • The subscribe callback does not always trigger an error

  • However, in the browser Network tab, the request consistently returns:

502 Bad Gateway

Expected Behavior

  • Since the bot processes the request successfully, I would expect an HTTP 200 OK instead of 502

  • Ideally, no error should appear in the Network tab


Constraints

  • I do NOT have access to the bot backend code (it is managed / wrapped by another team or service)

  • I can only make changes on the frontend


Questions

  1. Is this a known behavior of Direct Line when using invoke activities without an explicit response from the bot?

  2. Is there any way from the frontend to prevent or suppress the 502 response?

  3. Would switching from invoke to message be a recommended workaround in such cases?

  4. Is there any configuration in Direct Line that can avoid this behavior?


Additional Notes

  • The issue seems related to missing or improper invokeResponse from the bot

  • Functionality is not affected, but the 502 response is confusing and undesirable in production


Any insights or recommended best practices would be greatly appreciated.

I have the same question (0)
  • Suggested answer
    Nivedipa-MSFT Profile Picture
    Microsoft Employee on at
    Hello ,

    The 502 error occurs as expected because an 'invoke' action requires an invokeResponse from the bot; if it's missing, Direct Line returns a 502 error.

    Solution: Update the type from 'invoke' to 'event'. Since events are fire-and-forget, the bot doesn't need to respond, and you won't encounter a 502 error. The bot will still receive the data, and no backend changes are necessary.

  • BestYuan Profile Picture
    63 on at
    @Nivedipa-MSFT Thank you very much for your reply.
    I have already used event, but only increased the number of reactions. For reactions>comments, there is no response.
    How can I customize the implementation of submitting feedback?
  • Nivedipa-MSFT Profile Picture
    Microsoft Employee on at
    Hello ,

    Thank you for the update.

    Just to clarify, reactions and comments are processed differently. Reactions (messageReaction activity) are managed through onReactionsAdded, while comments are not a standard Direct Line activity type.

    To collect custom feedback (both reactions and comments): You can use an Adaptive Card with Action.Submit (instead of invoke), including thumbs-up/down options and a text field for comments. Then, handle the submitted data in your bot's onMessage handler. This approach avoids the 502 error and allows you to manage the feedback process directly.

  • BestYuan Profile Picture
    63 on at
    @Nivedipa-MSFT Thank you very much.
    Could you tell me how to actually operate it? Or how to make changes based on my code?
    Actually, I have a customized page. If I use Adaptive Card, how should I write the code for my bot?
  • Nivedipa-MSFT Profile Picture
    Microsoft Employee on at
    Hello ,
    Could you please refer below document:
    Designing Adaptive Cards for your app - Teams | Microsoft Learn

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Copilot Studio

#1
Valantis Profile Picture

Valantis 633

#2
Vish WR Profile Picture

Vish WR 301

#3
Haque Profile Picture

Haque 219

Last 30 days Overall leaderboard