Code Monkey home page Code Monkey logo

chat-widget's Introduction

IBM Watson Virtual Agent Chat Widget

codecov

Chat Widget demo

Lightweight chat widget for Watson Virtual Agent. The widget is built on top of the Client Bot SDK, which manages communications with a Watson Virtual Agent bot.

It contains a configurable user interface and can be used as-is or customized. Alternatively, to have ultimate control you can use the Client Bot SDK to build a chat widget of your own.

Getting Started

Get API keys

  1. (if you don't already have one) Get a set of Watson Virtual Agent API keys:

    1. Sign in for a Free Trial in https://www.ibm.com/marketplace/cloud/cognitive-customer-engagement/
    2. Log in to /api explorer with the same IBM ID that you used to sign up for the trial subscription
    3. Click the My APIs link, and look for the IBM Watson Virtual Agent tile. Click the key icon, and select the default key.

    4. Hover over the key fields, and then click SHOW to view the values. You must add these key values into the script later, so save them in a text file for now. The value from the first field is the client ID key. The value from the second field is the client secret token.

  2. Get your bot ID.

    Your bot ID is assigned when you create the Watson Virtual Agent instance, and is provided in the bot ID parameter of the code snippet that is displayed in the Publish page. You can use the value that is provided there as-is. If, for some reason, you want to retrieve the bot ID yourself, follow these steps. The order is important.

    1. When you get to the Watson Virtual Agent API details page, click KEYS.
    2. Click #1 - Key1.

    The key you selected is now displayed. 3. Now you should see a `TEST` button when you scroll down to the Retrieve Bot call.

Using the WVA Chat Widget on Your Site

You can copy this HTML code block into a file, give it an .html extension, and view it in a browser to see a quick and basic example. Replace the values of the botID, XIBMClientID, and XIBMClientSecret parameters.

<html>
<head>
<title>IBM Watson Virtual Agent Chat Widget Sample</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
<style>
  html, body, iframe { width: 100%; height:100%; padding:0; margin:0; }
  #ibm_chat_root { position:fixed; bottom:0; right: 20px; height: 80%; min-height:400px; width:300px; background:#000; }
</style>
</head>
<body>
<div id="ibm_chat_root"></div>
<iframe style="width:100%; height:100%" src="http://www.ibm.com/en-us"></iframe>
<!--
https://unpkg.com/@watson-virtual-agent/[email protected]/dist/chat.min.js for a specific version, where X.X.X is the semantic version of the chat widget.
In your production environment, we recommend locking down your widget version.
-->
<script src='https://unpkg.com/@watson-virtual-agent/chat-widget/dist/chat.min.js'></script>
<script>
  var config = {
    el: 'ibm_chat_root',
    baseURL: 'https://api.ibm.com/virtualagent/run/api/v1',
    botID: 'YOUR_BOT_ID',
    XIBMClientID: 'YOUR_IBM_CLIENT_ID',
    XIBMClientSecret: 'YOUR_IBM_CLIENT_SECRET'
  };
  window.IBMChat.init(config);
</script>
</body>
</html>

You can also install this package from npm with npm install @watson-virtual-agent/chat-widget and include it as part of your own scripts and build process.

var IBMChat = require('@watson-virtual-agent/chat-widget');
var config = {
  el: 'ibm_chat_root',
  baseURL: 'https://api.ibm.com/virtualagent/run/api/v1',
  botID: 'YOUR_BOT_ID',
  XIBMClientID: 'YOUR_IBM_CLIENT_ID',
  XIBMClientSecret: 'YOUR_IBM_CLIENT_SECRET'
};
IBMChat.init(config);

API

For more details about what you can do once the widget is up and running, see:

Watson Virtual Agent Documentation

Additional documentation related to Watson Virtual Agent can be found in www.ibm.com/watson/developercloud/doc/virtual-agent/wva_overview.shtml.

Questions and issues

Report bugs or feature requests to our github issue tracker. For questions please refer to StackOverflow under tag watson-virtual-agent or DeveloperWorks Answers.

Contributing

See CONTRIBUTING.md.

License

This code is licensed under Apache 2.0. Full license text is available in LICENSE.

chat-widget's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.