Skip to content

Getting started

Installation

bash
npm i @adaptical/mathew-chatbot

CDN

Using Vue from a CDN

We use import maps to load the chatbot and Vue from a CDN and be able to use import statements in our code.

javascript
<script type="importmap">
{
    "imports": {
        "@adaptical/mathew-chatbot": "https://unpkg.com/@adaptical/mathew-chatbot",
        "vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js",
    },
}
</script>

Starting the chatbot

html
<html>
    <body>
        <div id="app"></div>
    </body>
</html>
javascript
import { startChatbot } from '@adaptical/mathew-chatbot'
import '@adaptical/mathew-chatbot/style.css'

const chatbotRoot = document.querySelector('#app')

const apiKey = '<your-mathew-api-key>'
const userId = '<current-user-id>'
const method = 'HMAC-SHA256' // 'HMAC-SHA512' | 'HMAC-SHA384' | 'HMAC-SHA256'
const userIdHmac = await getUserIdHmac(userId) // Create this user id HMAC in your backend using your api secret

const apiAuth = { method, apiKey, userId, userIdHmac }
const chatbotOptions = { api: { auth: apiAuth } }

startChatbot(chatbotRoot, chatbotOptions)