nodejs client for interacting with the botmock api
Note: In order to get started with this client, you'll need to get your access token from https://app.botmock.com. After you sign in, go to the Account Settings page by clicking on your profile picture on the top right. Then click on "Developer API" from the dropdown menu. Give your token a name, check the box, and hit "Create". Remember to note down your token since it will not be shown after it is generated.
npm i @botmock/client
import Botmock from "@botmock/client";
const client = new Botmock({ token: process.env.BOTMOCK_TOKEN });
client.getProject(opt): Promise<any>
Gets project from a teamId
and projectId
within opt
const project = await client.getProject({ teamId, projectId });
client.getTeam(teamId): Promise<any>
Gets team from a teamId
const team = await client.getTeam(teamId);
client.getBoard(opt): Promise<any>
Gets board data from a teamId
, projectId
and boardId
const board = await client.getBoard({ teamId, projectId, boardId });
client.getIntents(opt): Promise<any>
Gets all intents from a teamId
and projectId
const intents = await client.getIntents({ teamId, projectId });
client.getVariables(opt): Promise<any>
Gets all variables from a teamId
and projectId
const variables = await client.getVariables({ teamId, projectId });
client.getEntities(opt): Promise<any>
Gets all entities from a teamId
and projectId
const entities = await client.getEntities({ teamId, projectId });
Events containing errors and also successes can be listened to in the following ways.
const client = new Botmock({ token: process.env.BOTMOCK_TOKEN });
client.on("error", ({ error, endpoint }: { error: FetchError, endpoint: string }) => {
console.error(error, endpoint);
});
client.on("success", ({ endpoint, timestamp }: { endpoint: string, timestamp: number }) => {
console.error(endpoint, timestamp);
});
To test the package, simply enter the command below into the command line:
npm test
Found bugs or have some ideas to improve this integration? We'd love to to hear from you! You can start by submitting an issue at the Issues tab. If you want, feel free to submit a pull request and propose a change as well!
- Start with creating an issue if possible, the more information, the better!
- Fork the Repository.
- Make a new change under a branch based on master. Ideally, the branch should be based on the issue you made such as "issue-530".
- Send the Pull Request, followed by a brief description of the changes you've made. Reference the issue.
NOTE: Make sure to leave any sensitive information out of an issue when reporting a bug with imagery or copying and pasting error data. We want to make sure all your info is safe!
The Botmock JS Client is copyright © 2019 Botmock. It is free software, and may be redistributed under the terms specified in the LICENSE file.