Building telegram azure bot to deliver dynamic questionaaires, along with location sharing - c#

I am developing a location-based recommender system, which uses a chatbot which:
Situation
Gets the users current location via a channel such as telegram/facebook messenger or other
Uses the chatbot, which shares this location with a backend azure serverless function, and which sends a set of personalization multiple-choice questions with options to the chatbot.
The chatbot asks those questions( according to the questions sent from the backend), to the users, and sends the user's selected answers back to the backend. Note: the questions and their choices, are entirely dynamic, and a static questionnaire cannot be assumed.
The backend personalizes the recommendation for the landmarks around the user, according to the answers, and displays the recommendation to the user.
Questions:
I read lots of tutorials on doing this with microsoft botbuilder( which is a requirment) but dynamic form-dialogs dont seem to be possible ( I only saw statically coded form). The questions and their options should be retrieved via a back-end REST API call and the json will be parsed to make the Q and A dialog. With the option for each question being sent back to the server to store. how do I make this happen?
Since its a user-location-dependent service, how do I take the current location of the user, from the deployed channel(i.e. telegram),into the chatbot ( and then send it to server backend). is there any way to do this using the microsoft botbuilder framework?
Since I am very new to azure and botbuilder framework, thanks in advance for any help!
Now

1) The text for a message can be retrieved from anywhere. This example pulls messages from a mocked up service, and walks the user through the steps one at a time: https://github.com/EricDahlvang/MultiTurnHelpStepsBot
2) This library might help: https://github.com/Microsoft/BotBuilder-Location

Related

BOT does not calls choiceSelection method defined in PromptDialog.Choice using web-chat v4 framework

I am having a BOT application which is being developed using Microsoft BOT Framework V3 and WebChat Framework V4. In one of the scenario where user sends a particular utterance say "I want to place an order" which goes to LUIS and then BOT replies users to choose some choice using PromptDialog.Choice(context,choiceSelection,message). E.g. "Home Delivery", "Self Pickup"
Now when user clicks on one of the button (Say "Home Delivery"), then technically the choiceSelection method should be invoked but instead of that BOT takes that choice as a new utterances and calls the LUIS to which no intent is mapped and hence the scenario does not complete
with expected result.
Also I have checked with using BOT WebChat V3 version, the scenario works absolutely fine without failing. But due to client requirement, I would like to go with WebChat v4 instead of WebChat v3 framework.
Any suggestions, work around will be highly appreciated.
You have two options to choose from:
Limit how and when utterances and selections are captured by LUIS so every response isn't getting processed. Or,
Provide a "none" intent. If you supply your training model with sufficient examples for getting correct responses, then unrelated queries should map to "none". Really, the emphasis is on "sufficient examples". If you don't supply enough data to train your model with, then you will certainly get undesirable results. Once you get the "none" intent to properly produce, you can set the logic in your bot to recognize "none" was returned and to keep on going.
In truth, both options together would serve you well.
As for Web Chat, it has no bearing on LUIS responses. It is merely a client that receives and returns activities. Out-of-the-box, it does nothing to the activities unless you implement custom components and code.
For clarity, there is no relationship between Botbuilder v3/v4 and BotFramework Web Chat v3/v4. They can be used interchangeably. However, Web Chat v3 (a.k.a. "botchat") is deprecated and should not be used. Web Chat v4 is the platform you will want to use.
Hope of help!

How to get user's location while chatting with bots?

I am developing a Bot Framework application that integrates with Slack using Microsoft Bot technology. In the bot project, I was trying to get the user location when the user sends a message.
What I am trying to achieve is that, when a user types the message "Show me nearby hospitals", I want to get the users Geo coordinates and pass them to an API that will return a list of hospitals near that location. So any idea on how to get the user's current location in the Microsoft Bot project?
I tried using the Geo location class, however I am not able to add the class reference directly and when I add the external DLL for the Geo location class, Visual Studio throws some errors.
Is there any way to get the users current location in Bots?
The Bot Framework is getting updated every minute!!!
The Bing location control for Microsoft Bot Framework makes the process of collecting and validating the user’s desired location in a conversation easy and reliable.
The control is available for C# and Node.js and works consistently across all channels supported by Bot Framework.
Check the documentation here.
Click to view the code sample
This question is old but this is now a thing that exists to help with location hope it will help someone looking for this answer. https://github.com/Microsoft/BotBuilder-Location
Channels vary on whether they support location information. There is currently no way to get location information for users on Slack. Telegram, for instance, does. When location data is available it will returned in the Attachment data structure and in the channel's native format in the ChannelData field. Note that the user needs to opt into sending this data (to protect their privacy). The bot developer can send a message to the user requesting that they share their location data, but they cannot get it from the channel it w/o user action to share it.
This is currently not handled by the BotBuilder well. I've opened an issue to get this standardize across platforms. Regarding Slack, they don't have an option to send a location as an attachment as Telegram, Messenger and Kik do, so you might want to use Google Geocode API to derive coordinates from a string.

transfer chat conversation on Openfire and anonymous login

This will be the 3rd time attempting this question. I figure some stuff out as I go along, and then I get stuck at a different place, but I probably will need help with my final two problems.
I was given a task to create a IM solution for our company that will work with apps like IM+ etc.
A bit of background on what is required:
A person will use a IM app on his phone, or our website that will be setup to connect to our server.
I wrote a plugin that as soon as somebody connects to the server, a chat session will be initiated with a bot that will ask for some information.
After the bot identified the customer, I would like to "transfer" the chat session to a human that will be logged in on the server as well. This is Problem 1 Is it possible to "transfer" a chat session to somebody else?
My second problem is this.
Most of the times a customer will not be registered on Openfire as a user. I've allowed for anonymous login on the server, but I can't seem to get it to work. I've downloaded jabber-net client, and the bot is currently using asgXMPP to connect. And if I try to send a null username and password, it does not connect, does not give any errors, nothing.
If anybody can help me out a bit I would appreciate it. I am TOTALLY new to XMPP, and I'm happy with what I've accomplished so far.
Jaques
I can't really answer questions about how agsXMPP or jabber-net work, but: an anonymous session is not the same as a normal session with no password, it uses a different authentication mechanism (SASL ANONYMOUS), so you'll have to see whether those libraries support it, and how to request they use it.
For transferring chat sessions - there isn't really any sort of 'chat session' going on, it's just a series of messages. In principle you just need to send a stanza to the client asking it to talk to someone else instead of the bot once the bot's done with it. If you want to then forward the conversation history on to the new chat partner there's XEP-0297 that you could usefully apply for this.

Alert Selected users SignalR

I am looking into an alternative solution to my jQuery and Ajax alerting feature in my MVC4 app. I have stumbled across SignalR which looks like it can solve my solution but where I hear you can broadcast to a certain client and not all, I cannot seem to find an example.
Basically all I want to know is:
On set up can the clientID be the applications UserID on login?
Are you able to broadcast to specific roles and/or a list of userID's
Are there are any examples that can help demonstrate the above?
Thanks in advance
With SignalR you can manage your own user identities. SignalR represents each user with a ConnectionId but it is ultimately up to the dev to map that to an existing user profile.
Yes, you are able to broadcast to groups or specific clients. You can add clients to groups and then send single messages to multiple people simultaneously or you can send to a specific client.
As noted in the comment JabbR is an excelent example. Also for a quick start on getting introduced to SignalR check out the Quick Start Hubs page. Lastly SignalR is open source so check out the source and the wiki.

SagePay integration from Windows Forms

I’ve been asked to integrate a windows form application with SagePay to take payments directly from the application. The SagePay documentation talks about ASP.NET so I’m not sure whether this is possible. Has anyone integrated a WinForm application with SagePay before? Is it possible?
I know some payment processors have a connection option where the payment part is hosted on a form on their server. You could try embedding a web browser control into your app to display the payment page.
Usually there is another type of connection option where you can send your information via HttpWebRequest, but I'm not sure that this would work as it requires SSL. Since you are running your app as a desktop client, I'm not sure what you would have available.
I am not sure this is possible given that sagepay needs to redirect users to Mastercard securecode or Verified by Visa, I think they would need to redirect to the bank which then redirects back to a supplied URL. I would think this needs to be within a browser environment.
You can post to urls and get back a response via .net objects and parse the results to display on a form.
You can also ask SagePay to create a Vendor account with 3d secure switched off. This allows you to take payments in house in your winforms app without the customers password however most card vendors if you bypass 3d secure will not protect you if someone calls and uses a card fraudulently.
However it can definitely be done.
You can normally post to secure servers from non secure pages so again this isn't usually an issue.

Categories