Chatbots are responding often with references to other sources. This might be just the link to a webpage, an image or a button. You don’t want to display the user an 404 page or an error.
To cover if those links exist we build the HyperLinkAsserter. He will automatically detects all links (Buttons, Cards, Images or simple references) and will check if those are reachable and delivering the correct Http response code.
Prio to Botium 2.4, this asserter was enabled by default on Botium (depending on the flavour). If you want to disable this asserter, remove it from the Default Component Set by navigating to Settings / System Settings / Registered Components / Chatbot Hyperlink Response Asserter and disabling the Include in Default Component Set switch.
We develop a new Chatbot, who is giving us links.
Give me links #me Hi #bot Goodday, How can I help you? #me Can you give me some links #bot There you go: www.google.com, https://flippingbook.com/404 https://de.wikipedia.org
Easy right. Everything works great chatbot . Let’s go live with our amazing Chatbot! After 5 minutes we get the first incident. Some one tried to go to: https://flippingbook.com/404. Ups it is not there anymore .
How can we fix this?
We can refer the asserter as an separate step in the convo file
restaurant #me Hi #bot Goodday, How can I help you? #me Can you give me some links #bot There you go: www.google.com, https://flippingbook.com/404 https://de.wikipedia.org CHECKLINK 200
Now if we run this test again this will hopefully end up in an error that we can fix the link.
Error: Line 15: FAILURE: https://flippingbook.com/404 Not Found Actual: 404 Expected: 200 at Promise.all.then.results (/Users/stefan-sev/IdeaProjects/botium-box/packages/botium-asserter-hyperlink/src/HyperLinkAsserter.js:105:31) at process.internalTickCallback (internal/process/next_tick.js:77:7) at ScriptingProvider.fail (/Users/stefan-sev/IdeaProjects/botium-box/packages/botium-asserter-hyperlink/samples/sample1/node_modules/botium-core/src/scripting/ScriptingProvider.js:99:15) at scriptingEvents.assertConvoStep.then.then.catch (/Users/stefan-sev/IdeaProjects/botium-box/packages/botium-asserter-hyperlink/samples/sample1/node_modules/botium-core/src/scripting/Convo.js:218:42) at process.internalTickCallback (internal/process/next_tick.js:77:7)
Great! Now we clearly see that our chatbot references a non existing page https://flippingbook.com/404. Once this link is removed our tests are passing again and your customer will get all the information he needs.
This was a basic example for the usage of the hyperlink asserter. For more configuration options please read further.
Setup for Botium Enterprise
The asserter is already pre-configured in Botium, it can be referenced with the CHECKLINK tag in your convo file (for arguments, see below). You can change the configuration in the Settings / Registered Components / Chatbot Hyperlink Response Asserter section.
Switching on the Register as global scripting component option, all hyperlinks found in chatbot responses will be validated.
Switching on the Include in Default Component Set option, this asserter will be used for all test sessions.
If you combine those two switches, there are always all hyperlinks validated.
There is the possibility to reduce redundancy by defining global configurations.
In the registered component view, you have to add a JSON structure to the field Component Configuration (JSON-formatted) for the asserter.
Those are the possible configurations:
|baseUrl||If you test only links within your domain you can define a baseUrl. This will be concatenated with relative links in the response of the bot||
If we get a response with
|httpStatus||this will set a list of valid HttpStatuses for the links||
Http statuses 200 (OK), 204 (no content) and 301 (redirect) are in this example valid response codes
|maxRedirects||this is the depth of http redirects, which the hyperlink asserter is traversing. This might be handy if you are behind a corporate proxy.||
If we get the link https://de.wikipedia.org we want redirect to https://de.wikipedia.org/wiki/Wikipedia:Hauptseite. Instead we check the first response code, which is in this scenario 301 (redirect).
|timeout||HTTP request timeout in milliseconds (default: 10000 = 10 seconds)||
In case you expect slow network traffic, increase this timeout
|extractFromSourceData||Include “sourceData” structure for detecting hyperlinks (default: false). This is useful for custom chatbot implementations with custom information attached not part of the Botium structures (see Howto develop your own Botium Connector).||
If you need specific settings to the convo step you can override the global settings and defaults with the convo settings.
Here a the possible convo settings:
|httpStatus||Set the desired, valid http response codes for the links send by the bot||
There are to options to configure this in the convo file
Both configuration having the same result: Check if all links in the bot response are either responding with httpstatus 200, 204 or 301
|maxRedirects||Define the max depth of the redirects for links||
For the maxRedirects there is just the structured configuration available.
In this example the bot response with an redirect, but we are not interested if the redirect is valid. So we are just checking if the first url return status code 301 (redirect)
|timeout||HTTP request timeout in milliseconds||
Only structured configuration possible
Please sign in to leave a comment.