Is it possible to pass data through a markdown link? So for example:
var html = "[link1](test1) [link2](test2)";
var reply = message.CreateReply();
reply.Text = $"Welcome {newMember.Name + html}!";
client.Conversations.ReplyToActivityAsync(reply);
Is there a way to pick up the click event that would let me know which link was clicked?
In bot framework, if you are trying to collect data off of link click (or button of the OpenUrl type). The recommended way is by using a 302 redirect. This is because you generally do not have access to anything from the front end as stuartd is pointing out. For example, if you have a facebook bot how would you capture what the user clicks since nothing is sent to the bot? This is the problem you are running into. You would essentially have to send an activity to the bot when the user clicks a link, but without access to the Facebook front end how do you send that on click?
If you would like to see an example of a 302 redirect in a bot, I have made this example which has both Node and C# versions. This project shows how to do this with a button using the OpenUrl action type but can be applied to a link as well.
Related
I have a scenario where I would like to automate programmatically the following process:
Currently, I have to manually
Navigate to a webpage
Enter some text (an email) in a certain field on the webpage
Press the 'Search' button, which generates a new page containing a Table with the results on it.
Manually scroll through the generated results table and extract 4 pieces of information.
Is there a way for me to do this from a Desktop WPF App using C# ?
I am aware there is a WebClient type that can download a string, presumably of the content of the webpage, but I don't see how that would help me.
My knowledge of web based stuff is pretty non-existent so I am quite lost how to go about this, or even if this is possible.
I think a web driver is what you're looking for, I would suggest using Selenium, you can navigate to sites and send input or clicks to specific elements in them.
Well, I'll write the algorithm for you but you also need to some homework.
UseWebClient get the htm page with the form you want to auto fill and submit
Us regex and extract the action attribute of the form you want to auto submit. That gets you the URL you want to submit your next request to.
Since you know the fields in that form, create a class corresponding to those fields, let's call the class AutoClass
Create a new instance of your auto class and assign values you want to auto fill
Using WebClient to send your new request with the url you extracted from the form previously, attach your object which you want to send to the server either through serialization or any method.
Send the request and wait for feedback, then further action
Either use a web driver like Puppeteer (Selenium is kinda dead) or use HTTPS protocol to make web requests (if you don't get stopped by bot checks). I feel like your looking for the latter method because there is no reason to use a web driver in this case when a lighter method like HTTP requests can be used.
You can use RestSharp or the built in libraries if you want. Here is a popular thread of the ways to send requests with the libraries built in to C#.
To figure out what you need to send you should use a tool like Fiddler or Chrome Dev Tools (specifically the Network tab) to see what you need to send to acheive your goal as you would in a browser.
I am trying to create a chatbot which is having multiple waterfall dialog classes using C# and BOT SDK V4. I have created a HTML page and placed the DirectLine channel Secret Key Iframe data into it and published it to Azure successfully and opened it in the browser. The browser opens with a in-built welcome message something like: Hi bot name type Hi to continue.
If i have Choice options done through prompt options to be displayed as buttons but these are not displayed through direct line channel but works very good in Web Chat Channel?
Attached image shows the issue:
a "WebChatbotHtml_optionbtndisplayed.jpg"
b. "DirectLinechannelHtml_optionbtnnotdisplayed.jpg"
Now, in the main dialog class i have implemented the Login mechanism using the Oauth Prompt in th html page that was created above i see the login link getting displayed using which i have successfully logged in this will navigate to another waterfall dialog having prompt options with some custom choice buttons, whee if i click on a choice button the next step will be executed and respective action will be triggered.
The issue i have is normally the options are displayed for me to access but in the html that i created the all other things like login link and navigation is happening but the choice buttons are not displayed its like they are getting hidden.
or Sometimes the Choice Option buttons are not displayed at all in the Direct Channel Web chat bot
The query is how to fix the issue?
To make my query to be understood in a better way please find below set of things:
1. WaterfalldiaglogClass1:
STEP 1: Has login option/link displayed through Oauth Prompt.
STEP 2: Gets token validates it and displays login successful message and then navigates to second waterfalldialogClass
2. WaterFallddialogClass2:
STEP 1: Custom choices are displayed through Prompt options lets say 1,2,3,4
STEP 2: Capture the choice getting clicked and perform respective action
I created a HTML page where the I frame code i copied with secret code of Direct Line Channel
Published it to azure successfully with no errors or warnings
Opened the html page in a browser the chat bot opens successfully with a welcome default message like: HI i am bot,enter Hi to continue
User sends hi and logins using the login link available displayed in dialog class 1 and login successful message is displayed
Navigated successfully to second dialog successfully as i can see the prompt message given as part of prompt option and custom choices in the code
Current Issue: The option buttons 1,2,3,4 are not getting displayed it is getting hidden somehow
Need help in resolving the issue Please provide detailed step by step guide in resolving it as i am new to BOT and coding .
language: C#
Bot Framework: V4
I have tried increasing height width and other % values in the HTML page and republished it but not successful. The same thing works in web chat channel i.e. if i keep secret code inside the HTML page of webchat channel without any issues.
Issue Image attached for reference.
Expected Result: Data or choices should be shown as it is working in Webchat channel
Actual Result: Not working the choice options are not visible to choose
There are two versions of Embedded Web Chat at the moment: Gemini and Scorpio. Embedded Web Chat is currently in the process of slowly transitioning all clients from Scorpio to Gemini. It appears your embedded Web Chat is still using Scorpio which unfortunately does not support the OAuth prompt. In the near future, you will be able to manually request your client to be switched to Gemini.
In the meantime, you can add either add Web Chat v4 to your site using a CDN or wait for your client to be migrated to Gemini.
For more details regarding Embedded Web Chat, take a look at the documentation.
Hope this is somewhat helpful.
Basically, I want to have my bot on different pages using iframes and Bot Framework Web Chat.
Depending on what page the user opens the bot, a different dialog is called.
Without Direct Line, this is as simple as adding a query parameter to api/messages and adjust the controller. But with Direct Line, I can only specify one endpoint in the portal.
I tried to change user.id in the JavaScript BotChat.App call to a different identifier and then select the correct dialog in my MessagesController based on that.
BUT: my custom id doesn't seem to be available as early as the activity "ConversationUpdate" occures where I send my welcome message. I need to send a dialog-specific welcome message though (so I need to navigate there as soon as possible and not only when the user types his first message).
Take a look at the backchannel. In your scenario you can pass a parameter from the Javascript via the back channel to set some value in UserData. Now your parameter will exist in state (in this case the IDataBag UserData) when your user first hits the bot.
Here is a C# sample of a 2-way backchannel
another C# sample using a 1 way backchannel
I am creating an Email Sending Software. So far i am able to open chrome and fill the details of the email (subject,body,attachments and all) but i wanted to know is there any way i can click Send button of G-Mail programmatically too?
Code for filling details in chrome
Process ps = Process.Start("chrome.exe", "https://mail.google.com/mail/u/0/?view=cm&fs=1&tf=1&to=a#gmail.com&bcc=b#gmail.com);
Note I haven't used SmtpClient to send email because it was not fulfilling my customized requirement (sorry cannot disclose the reason).
The way you want this, is not possible. Process.Start opens a new Process. In this case it opens Google Chrome, with the URL you sent with it. This URL contains a querystring containing the subject and the body of the email. This is possible, because Google reads this on the server-side, and puts it in the right fields. There is no way to enter the send button though. This is a POST action, which can not be triggered by a URL.
C# form, does have a WebBrowser class. From here you can access buttons and click them, but I don't think Google will allow this, and most likely send you a captcha. (That is, if you manage to login in the first place.)
I can't help with the simulated button press you're looking for, but I can suggest that you rather try to use the Gmail API to do what you're trying to do:
https://developers.google.com/gmail/api/?hl=en
This would be a more reliable and stable way to send gmail programmatically, and you still don't have to use the smtp object directly.
You should probably use Selenium (WebDriver). It allows you to control browser from c# code, navigates pages, traversing DOM etc..
On my website users can post comments on a document. Now I want to send an RSS feed to the webmasters when a comment is posted. I want the webmaster to be notified by a small pop-up in the right corner of the page. So this is what's happening:
User adds comment
system checks if webmaster is logged in
if webmaster is logged in; show pop-up in right corner with the title of the comment in it.
How to accomplish this?
Setup a javascript timer to call a webservice periodically (every 5 seconds?) if the user is a webmaster. This webservice can determine if a new comment has been added since the last time it was checked. The webservice returns nothing if no new comment or some information about the comment if there is a new one.
If the webservice returns a comment, put that information into a div tag that you have created on your page and make it visible. If you are sure the webmaster is using a modern browser, you can use position:fixed to put this div tag in the upper right corner. If not, you will have to use some javascript to accomplish this.
Unless you're using a comet style service to push notifictaions to the webmaster's browser, you're going to need to make a page that polls for new notifications at a pre-defined interval. You can then make an AJAX call to the service and parse the response on to a web page that only the webmaster has access to.
If you're interested in comet (services that can push data to the connected client), you can get a start at Wikipedia:
Comet (programming)