Widget integration
Our widget is very easy to integrate on your own webpage. For some customers it's even easier than others since we offer our integration as one line of HTML which can be included by using tools like Google Tag Manager or by adding it to your code itself.
To find this one-line HTML integration, navigate to the Integrations > Widget page on the Oswald Dashboard. On the widget page you can find the Widget Script section with a single line integration like this:
Adding this line to your source code is all you need to do, and the widget will be running on your web page!
Customisation
There are a few customization options available for the widget integration. These can be selcted by adding the corresponding query parameter the url in the script above:
https://api.oswald.ai/api/v1/chats/YOUR_UNIQUE_WIDGET_TOKEN/widget
?key=value&key2=value2
key
type
value
open
boolean
true --> Widget opens automatically
false --> Widget stays closed until opened by user
startCommand
string
"your text command" --> send a custom start command to trigger a specific scenario in your chatbot onWidgetOpen.
locale
string
The language your bot needs to run in. E.g. "en-GB"
session
string
A custom sessionID for your conversation. When your page has multiple views/pages where the widget is active, you might want to assign a unique ID to each user so they can continue their conversation where they left off. If you don't provide a unique session ID yourself, the widget will generate a new one on each page reload/change, restarting the conversation from scratch and losing the previous context.
Open widget from your own button or link
You can create your own button to open the widget by using the following piece of code
If you would like to hide the default Oswald chat button, you can do so by adding CSS styling to render the button somewhere off-screen.
Send metadata from your webpage to the chatbot
Let's say your chatbot is running on a specific page of your website or you already know the name of your users since they are logged in, you might want to provide this information to the chatbot through the metadata JSON object. To pass data to your widget (and thus the chatbot it connects to) simply add another Javascript block to your source code or through Google Tag Manager (or equivalent technology):
Reading out the metadata object in Oswald is very easy. Toggle the code switch on your response node where you want to extract the metadata and write your response like this:
Last updated