microsoft / BotFramework-Composer

Dialog creation and management for Microsoft Bot Framework Applications
https://docs.microsoft.com/en-us/composer/
MIT License
870 stars 372 forks source link

ChannelData set in composer not coming in directline recieve activity #8903

Closed tushaar9027 closed 2 years ago

tushaar9027 commented 2 years ago

Describe the bug

I need to send channeldata from composer to directline receive activity so far if i try setting channeldata like this it is available in composer but no received in receive activity of channel data

Tried implementing like this but it didn't help turn.activity.channelData.eoc = false

Version

composer 2.1.1

Browser

OS

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

Channel Data should be available in bot responses in directline recieve activity as it is available in sdk first bot when queried using directline api

Screenshots

Additional context

dmvtech commented 2 years ago

Hi @tushaar9027

I need to send channeldata from composer to directline receive activity so far if i try setting channeldata like this it is available in composer but no received in receive activity of channel data

My apologies; can you please clarify on what you are attempting to accomplish and what the need is? Is this using Webchat as a client or a custom directline client? Can you clarify on what you mean by directline receive activity ?

tushaar9027 commented 2 years ago

Hi Dmvtech ,

there is a custom node web app i have created in azure in which i am trying to get the chatbot responses using the directline api ...this custom connector connects further to a third party vendor....

By Directline recieve activity i mean this http request to get bot responses using directline https://directline.botframework.com/v3/directline/conversations/${convid}/activities?watermark=${watermark}

where convid and watermark will dynamically inserted based on what is stored in azure storage.

The response i get from directline api is Recieve Activity Response Activities :

[
  {
    type: 'message',
    id: 'am1bVupNuGFcYF0Yw9RCy-eu|0000000',
    timestamp: '2022-01-23T04:28:12.6439381Z',
    serviceUrl: 'https://directline.botframework.com/',
    channelId: 'directline',
    from: { id: 'tushar.arora@example.com' },
    conversation: { id: 'am1bVupNuGFcYF0Yw9RCy-eu' },
    text: 'weather',
    sessionID: '4f58aced-8627-4daf-b523-6acfe0295468',
    messageId: '72d8898f-97fb-4e7f-87a7-59ad95f553c68'
  },
  {
    type: 'message',
    id: 'am1bVupNuGFcYF0Yw9RCy-eu|0000003',
    timestamp: '2022-01-23T04:28:24.1074588Z',
    channelId: 'directline',
    from: { id: 'ComposerDemo1', name: 'ComposerDemo1' },
    conversation: { id: 'am1bVupNuGFcYF0Yw9RCy-eu' },
    text: 'Please enter the city,country ?',
    speak: 'Please enter the city,country ?',
    inputHint: 'expectingInput',
    replyToId: 'am1bVupNuGFcYF0Yw9RCy-eu|0000000'
  }
]

you see in the second activity this is response from composer bot we can see the input hint but there is channeldata property in the response but in bot i have set the turn.activity.channelData.eoc = true (Note : I have been working with bot framework for last 2 years , i had a bot already created with v3 version and the channeldat was coming in bot responses recieved from directline endpoint but now i am shifting my whole bot to composer to make our lifes easier and to take advantage of Adaptive Dialogs) image

dmvtech commented 2 years ago

You won't be able to set the channelData properties from Composer. ChannelData is normally handled by the channel (Channel=>Bot. Not Bot=>Channel). So that the bot has information about the channel, and can handle certain logic per channel.

with v3 version and the channeldata was coming in bot responses recieved from directline endpoint

Your bot was sending channelData to a directline client?

tushaar9027 commented 2 years ago

Hi dmvtech,

Yes bots can send channeldata to directline otherwise there is no point of having channeldata .

Please refer the documentation attached https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-channeldata?view=azure-bot-service-4.0

You won't be able to set the channelData properties from Composer. ChannelData is normally handled by the channel (Channel=>Bot. Not Bot=>Channel). So that the bot has information about the channel, and can handle certain logic per channel.

with v3 version and the channeldata was coming in bot responses recieved from directline endpoint

Your bot was sending channelData to a directline client?

Hi dmvtech,

Yes bots can send channeldata to directline otherwise there is no point of having channeldata .

Please see lines (From Documentation) For example, your bot can use the channel data property to instruct Telegram to send a sticker or to instruct Office365 to send an email.

The outgoing and incoming messages between the user and the bot may have a channelData activity that contains a JSON object whose properties are specified in the previous table. The snippet below shows an example of the channelData property for an incoming custom email message, from the bot to the user.

Please refer the documentation attached https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-channeldata?view=azure-bot-service-4.0

EricDahlvang commented 2 years ago

It is possible to send channel data from composer with a structed lg template:

image

image

If the goal is to send channel data with every outgoing message from the bot, this could be accomplished with a middleware component hooking into all outgoing activities.

Demonstrating this shows up in channeldata on the client: image

dmvtech commented 2 years ago

Thanks @EricDahlvang I didn't even think of that. @tushaar9027 Let us know if that works for you.

tushaar9027 commented 2 years ago

Hi @EricDahlvang , Thanks for providing with the approach , i will try this out give me a couple of days will check and let you guys know if the approach also works with directline recieve activity end point.

By the way is there any good video for explaining how to implement middleware for composer in node js . Official documentation explains it with c#

dmvtech commented 2 years ago

@tushaar9027

By the way is there any good video for explaining how to implement middleware for composer in node js . Official documentation explains it with c#

I don't know of any off-hand, but I will take a look to see if I can find anything. As you know, Node JS runtime for Composer bots is in preview. At this point, there is no current ETA set for moving to GA.

dmvtech commented 2 years ago

I'm closing this as it seems you have an appropriate solution for setting the channelData from within Composer. I wasn't able to find any examples of implementing middleware within Composer node runtime.