Passing information from the client to Composer bot
See original GitHub issueI am trying to post a custom event via Direct Line to my Composer-based bot.
I found a page for the Bot Framework SDK v3 showing how to send a custom activity, however this page is not present in the v4 docs.
This is my code, I’m utilising the Web Chat control:
var dl = window.WebChat.createDirectLine({
token: '[token]'
});
window.WebChat.renderWebChat(
{
directLine: dl,
userID: 'YOUR_USER_ID',
username: 'Web Chat User',
locale: 'en-US',
botAvatarInitials: 'WC',
userAvatarInitials: 'WW'
},
document.getElementById('webchat')
);
window.setTimeout(function () {
dl.postActivity({ type: "event", value: "hello", from: { id: "me" }, name: "PageLoaded" })
.subscribe(id => console.log("success"));
}, 5000);
I have a 5 second delay before posting the activity to make sure everything loads.
This works in as much as that when the activity is posted, I get my welcome text back from the bot, however the custom event is never fired on the Composer side.
I created the event in Composer by
- Adding a new Trigger
- Selected Custom events and provided the name PageLoaded
- Added “Send a response” to say “Got page loaded event”
I need to know how to be able to pull the value from the event, in this case the value “hello”.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How to pass information from client to bot framework ...
I'm able to get email id and name through direct line token generation api, I also need to capture some additional information from...
Read more >Make an HTTP request from Bot Framework Composer
Learn how to make an HTTP request to access an external service, on behalf of the user or as part of your business...
Read more >Using Bot Framework Composer to pass variables back to ...
Using Bot Framework Composer to pass variables back to Power Virtual Agents · 1 - Use Case · 2 - Install Microsoft Bot...
Read more >Communicate with External Systems - Anthology Inc.
You can use Bot Framework Composer to call the API of another system, retrieve data through an HTTP request, and then show the...
Read more >Events - Microsoft Open Source
Event Activities are used to pass metadata between a bot and user without being visible to the user. The data from these activities...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@knightmeister Maybe this can help you, we are sending an activity event from Webchat to Composer like this:
window.WebChat.renderWebChat( { directLine: window.WebChat.createDirectLine({ token }), store }, document.getElementById(‘webchat’) );
—> when loading this webchat html page, it directly sends the “loginevent” in store.
The webchat code is inspired by this sample: https://github.com/microsoft/BotFramework-WebChat/tree/master/samples/04.api/a.welcome-event
The composer then receives it with an “Activity Event” trigger
This way it works for us. Hope this can help you.
Many thanks @benjaminsommerfeld, this allowed me to determine where I was wrong. My JavaScript works, but the issue was I was using a dialog event, rather than an activity event.