Skip to content

Instantly share code, notes, and snippets.

@RSamaium
Created February 20, 2020 06:45
Show Gist options
  • Save RSamaium/dafc4454eaca44fc85e7fd1086c5749c to your computer and use it in GitHub Desktop.
Save RSamaium/dafc4454eaca44fc85e7fd1086c5749c to your computer and use it in GitHub Desktop.
import axios from 'axios'
import code from './main.converse'
const SERVER_ACCESS_TOKEN = ''
export default {
code,
nlp: {
async witAi(text) {
try {
const ret = await axios({
url: 'https://api.wit.ai/message?v=20200214&q=' + text,
headers: {
'Authorization': 'Bearer ' + SERVER_ACCESS_TOKEN
}
}).then(res => res.data)
const intentName = ret.entities.intent[0].value
return {
[intentName]() {
return true
}
}
}
catch (err) {
console.error(err)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment