Search code examples
watson-virtual-agent

Watson Virtual Agent - added javascript to page, now what?


I followed the instructions to get my bot id, my ibm key/secret and inserted the javascript into my website. I run the site and nothing happens. What do I need to do to see the virtual agent show up on the page?

I followed these instructions to get up and running: https://www.ibm.com/blogs/watson/2016/09/introducing-watson-virtual-agent/?__prclt=run4xzrj

Used this page to get my botid: https://developer.ibm.com/api/view/id-339

I don't see any errors in my site console.

Code included:

<script src='https://dp1-bot-chat.mybluemix.net/IBMChatClient-v1.1.0.js'></script>
<script>
  IBMChat.init({
    el: 'ibm_chat_root',
    baseURL: 'https://api.ibm.com/virtualagent/run/api/v1',
    botID: '___mybotid___',
    XIBMClientID: '__myclientid____',
    XIBMClientSecret: '___mysecret____'
  });
</script>


Solution

  • If your site doesn't show a box, it may be caused by a missing root element. Make sure that you have an HTML tag on your site that has an ID matching the value of el (in this case, ibm_chat_root).

    If you want to, you can also directly pass an element object:

    IBMChat.init({
        el: document.getElementById('my-element-id')
    });