It is possible to send data through the Chat Control (iframe)?
I'm investigating the possible use of a certain Snrio: Suppose my client click on link that leads to my Bot site Contains the Chat Control. the link also contains user Id (POST). so it is possible to send the bot this user id as soon as the customer enters the site? so the Bot can perform a specific process Against this User?
Thanks
Sounds like really valid scenario, @danmarshall is it possible for someone to pass data to chat control iframe? I am not sure though how would the interoperability will work with this.
in addition, i know that i can use Direct Line API but It means I'll have to implement full client side (for example if the API (from bot side) send Cards with buttons to the client the user see only text and if i want it to show like in the Chat control or like in the emulator i should build this.. ) so if i can use the Built chat control and still Send through information It can be very effective.
Hi @Lipa9963 yes you can pass these additional URL parameters to your webchat iframe:
- userid
- username
This needs to be added to the documentation here and in the dev portal.
@danmarshall Works. Thanks!
On Wed, Jan 11, 2017 at 1:27 PM, Praveen R [email protected] wrote:
@Lipa9963 https://github.com/Lipa9963 how do you achieved this? Like this?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BotBuilder/issues/1987#issuecomment-271845153, or mute the thread https://github.com/notifications/unsubscribe-auth/AWFzXVKR9d1YciB4lerNvMwV4IZ6ZxXwks5rRLydgaJpZM4LdkCZ .
Sounds like this issue has been resolved. Closing now. If I'm in error, please reopen!
Hi guys, how can I read such parameters from the bot side? Thank you very much
@insanediv is your bot in Node or C# ?
Hi @danmarshall it is a node bot
@insanediv see https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/core-GetConversationMembers
@danmarshall is it possible to use this mechanism to pass arbitrary parameters to the bot via the web chat embed code?
@insanediv no. For arbitrary values, you will need to host your own custom webchat page. See the "backchannel" in the WebChat repo readme and example.
@danmarshall Thank you very much.
I managed to pass custom parameters to my bot, but have another question:
How is it possible to store such parameters to the session.userData object?
I show you my code:
Client side
botConnection.postActivity({type: "event",
value: "customarg",
from: {id: "me" },
name: "customEvent"})
.subscribe(id => console.log("success"));
Server side
bot.on("event", function (event) {
var msg = new builder.Message().address(event.address);
if (event.name === "customEvent") {
// HOW CAN I STORE event.value IN session.userData ?
console.log(event.value);
}
});
Thank you again
I finally managed to solve this. For anyone that needs please visit my github page
For those who would like to read the user ID and user name from a C# bot, they are available in the turn context, which in my bot is available in methods
OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken) in class DialogBot.cs, and in OnMembersAddedAsync(IList<ChannelAccount> membersAdded, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken) in class QnABot.cs.
In these methods, turnContext.Activity.From.Id contains the passed-in user ID, and turnContext.Activity.From.Name contains the passed-in user name.
@insanediv see https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/core-GetConversationMembers
I couldn't open this link, any idea how I could access the data passed in the iframe src in the bot? I am using nodejs thanks