@agilebot/extension-runtime
v1.0.0-beta.13
Published
Agilebot Extension Runtime
Readme
@agilebot/extension-runtime
JavaScript Runtime for Agilebot Extension.
Features
- Get language from Cobots
- Make request to Easy Service
- Obtain extension state
- Invoke JSAPI methods
Installing
Package manager
Using npm:
npm install @agilebot/extension-runtimeUsing yarn:
yarn add @agilebot/extension-runtimeUsing pnpm:
pnpm i @agilebot/extension-runtimeOnce the package is installed, you can import the library using import or require approach:
import * as gbtExtension from '@agilebot/extension-runtime';CDN
Using jsDelivr CDN:
<script src="https://cdn.jsdelivr.net/npm/@agilebot/extension-runtime/dist/browser.js"></script>Using unpkg CDN:
<script src="https://unpkg.com/@agilebot/extension-runtime/dist/browser.js"></script>Example
import {
getLanguage,
getExtensionState,
callEasyService,
rtmNotification,
rtmMessageBox
} from '@agilebot/extension-runtime';
// Get language from Cobots
const currentLang = await getLanguage();
// Make request to Easy Service
const result = await callEasyService('myService', 'myCommand', {
a: 1,
b: 2
});
// Obtain extension state
const extension = await getExtensionState('myService');
// Show a notification
rtmNotification.info('My Info Message');
// Display a confirmation dialog box
rtmMessageBox
.confirm('Do you want to delete?')
.then(() => {
console.log('User confirmed');
})
.catch(() => {
console.log('User aborted');
});