I am trying to intercept the request and response that are sent to a virtual agent bot using DirectLine (Bot Framework). I have subscribed to the directline's activity using:
`directLine.activity$.subscribe(message => console.log(message));`
From this I get the message object which I can manipulate before displaying it in the client. What I want is to find the topic (i.e. the virtual agent topic) that the bot has selected (using the trigger phrase) for the conversation. Based on the topic I want to do different things, how can I get it ?
Here is an example of the message I get:
{
type: 'message',
id: 'IvkoXGKm9ZKIHdjv6foMM6-in|0000001',
timestamp: '2023-03-20T05:26:13.7251392Z',
channelId: 'directline',
from: { id: '5903103d-ad35-496c-acb4-9f797198ab51', name: 'John' },
conversation: { id: 'IvkoXGKm9ZKIHdjv6foMM6-in' },
textFormat: 'markdown',
membersAdded: [],
membersRemoved: [],
reactionsAdded: [],
reactionsRemoved: [],
text: 'Can you tell me your name ?',
speak: '<speak version="1.0" xml:lang="en-US" xmlns:mstts="http://www.w3.org/2001/mstts" xmlns="http://www.w3.org/2001/10/synthesis">Can you tell me your name ?</speak>',
attachments: [],
entities: [],
replyToId: 'IvkoXGKm9ZKIHdjv6foMM6-in|0000000',
listenFor: [],
textHighlights: []
}
I expect that there should be a way to get the topic from the message. Any help would be appreciated. Thanks!
I too don't seem to receive the custom event as an activity from the Direct Line API in my tests.
I created a dialog emitting a custom event that contains the dialog schema name as a value:
I then call that dialog from my topic:
But the Direct Line only seems to retrieve activity of type 'message', and not my custom event:
@Jameslew_MSFT Yes I am emitting a Custom Event from composer (using emit a custom event) and redirecting to that dialogue(topic) from virtual agent. I am using Direct Line channel to subscribe to the activities of the virtual agent bot.
I have not tried this specifically; what sort of event are you emitting? Specifically type "Custom Event? I'd need to verify we support that one being emitted from PVA. There's also an Activity of type Event that I know we use for calling skills. LMK what you're using and I can check.
I'm not sure as I haven't tested this before.
@Jameslew_MSFT, do you think that approach would work?
Hi @HenryJammes
I emitted an event by extending virtual agent using bot framework composer , and emitted an custom event by creating a dialog in composer. In virtual agent I redirected to that topic (i.e. dialog). But I am not getting that event in "directLine.activity$.subscribe".
(I confirmed that the event is being emitted by using a trigger based on that)
Hi @anshul001,
I don't think that's possible. Direct Line has only what it needs to send/receive messages to the user. The internals of the bots operation, such as triggered topic, scores, etc., aren't relevant on the client side (and could be exposing data that the developer doesn't want to share).
I haven't explored it, but have you looked at emitting custom events, (that I'm assuming could be transparent to your end users) so that the client knows in what context/topic a message is sent? Events and triggers for adaptive dialogs - Bot Service | Microsoft Learn
Henry