DirectLine do not preserve the ChannelData node while sending Activity

Christin Joseph 0 Reputation points
2025-10-23T07:55:44.35+00:00

I am sending a message Activity to the DirectLine channel. My aim is to integrate Custom Channel with Dynamics 365 Contact Center (Omnichannel).
I am using DirectChannel in my Azure Bot Service to do the communication.
I have attached the incoming call back Url of the omnichannel to the message end point of Azure Bot Service.

While sending message to the DirectLine channel I can see the message is reaching Omnichannel, but the ChannelData (I need to preserve the conversationcontext property in channeldata) is getting empty (initialised with empty data for the child nodes: channeltype, customercontext, conversationcontext).

This has been verified with the echo message Directline send to all channel when we send the first message.

While sending:

"ChannelData": 
{
   "channeltype":"MyCustomChannel", 
   "customercontext":{"name":"Firstname Lastname","phone":"123456789"},
   "conversationcontext":{"ContextVar1":"Data","ContextVar2":"Data"} 
}

The echo message from DirectLine forwarded to all participant (I guess thsi will be the one being forwarded to Omnichannel as well (via bot message endpoint url))

"ChannelData":
{
   "channeltype":[],
   "customercontext":[],
   "conversationcontext":[]
}

Since the data is not reaching the Dynamics (I guess the data is not being forwarded to dynamics too), the context variables set in Omnichannel Workstream is not getting filled (I checked the Context Item Value table in Dynamics).

My doubt is that if this is the actual behavior of DirectLine channel? Or should I make some changes in the data being send in Activity?

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Azar 31,135 Reputation points MVP Volunteer Moderator
    2025-10-23T19:20:50.5133333+00:00

    Hi there Christin Joseph

    Thanks for using QandA platform

    when you send a message with channelData, Direct Line will forward it to the bot, but when the bot (or the connector) echoes the message back, it rebuilds the activity and doesn’t retain the original custom payload. This is why you’re seeing empty objects in channeltype, customercontext, and conversationcontext.

    To work around this:

    You can manually include the required channelData in the bot’s reply activity (before calling turnContext.sendActivity() or equivalent).

    Alternatively, store the context data in conversation state or user state so your bot can rehydrate and pass it along when needed.

    For Omnichannel integration, make sure your adapter (or middleware) explicitly transfers channelData fields to Dynamics instead of relying on the echo activity.

    So yes — this is expected behavior from Direct Line, not an error on your side, but it does mean you’ll need to explicitly preserve and resend the channelData from within the bot logic.

    If this helps kindly accept the answer thanks much.


  2. Aryan Parashar 2,155 Reputation points Microsoft External Staff Moderator
    2025-10-24T07:02:22.2233333+00:00

    Hi Christin,

    Direct Line API 3.0, is part of .NET SDK, to integrate your channel using Direct Line, here is relevant documentation:
    https://free.blessedness.top/en-us/dynamics365/customer-service/develop/bring-your-own-channel

    Make sure you correctly process inbound activity in the directline, here is relevant documentation:
    https://free.blessedness.top/en-us/dynamics365/customer-service/develop/bring-your-own-channel#process-inbound-activities

    In Omnichannel, ensure that you don't update or delete the context variables after you create them. If you do need to update or delete the variables, make sure that they aren't used in any of the unified routing classification or assignment rules.
    Here is the relevant documentation:

    https://free.blessedness.top/en-us/dynamics365/customer-service/administer/manage-context-variables#considerations

    To send an activity in Direct Line API, here is relevant documentation:

    https://free.blessedness.top/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-send-activity?view=azure-bot-service-4.0

    Feel free to accept this as an answer.
    Thankyou for reaching out to The Microsoft QNA Portal.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.