New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@botmock/client

Package Overview
Dependencies
Maintainers
4
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@botmock/client

## Overview

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

@botmock/client

Overview

Botmock client package is used to unlock data from Botmock projects.

Let's take a deeper dive and see what are those public methods that are exposed by Botmock Client and also what to expect from the response from these public methods.

Install

The package is available to install on npm. It is written in TypeScript, and comes bundled with type definitions.

npm install @botmock/client

Resources

Resources are all the nuts and bolts of a given project. Resources includes project information, a board is part of a project, so its information which includes the information about blocks and its connections. A project belongs to a team so resources also give us team information. Our intents, entities and variables are essential part of a board, so resources also contains information about these three.

Single Resource Requests

Each of the following methods is publicly available on an instance of the named export Client:

const client = new Client({ token: process.env.TOKEN }); 
const project = await client.getProject(process.env.TEAM_ID, process.env.projectId);

getProject(teamId: string, projectId: string): FetchResult

This method takes two parameters: teamId as a string and projectId which is also a string and then returns JSON for the information about the project as shown in a sample JSON below:

{
    "id": "16f1c520-05c6-11e7-bc31-5554df9b496b",
    "name": "Kindly",
    "created_at": "2017-03-10 19:16:40",
    "updated_at": "2017-09-15 14:15:59",
    "type": "mock",
    "platform": "facebook"
}

getTeam(teamId: string): FetchResult

This method takes in one parameter of teamId as string and returns the team information as shown in the following JSON below:

{
    "id": 38881,
    "name": "First Team",
    "photo": "https://www.gravatar.com/avatar/00f062fb089de61b9a7e8033bc40109a.jpg?s=200&d=identicon",
    "created_at": {
        "date": "2017-01-10 20:45:21.000000",
        "timezone_type": 3,
        "timezone": "UTC"
    }
}

getBoard(teamId: string, projectId: string, boardId: string): FetchResult

GetBoard is a method that can be used to get all the board information if provided correct teamId, projectId, boardId all these parameters are expected to be strings. The sample JSON response is shown below:

{
    "board": {
        "root_messages": [
            "16f1c520-05c6-11e7-bc31-5554df9b496b"
        ],
        "messages": [
            {
                "message_id": "16f1c520-05c6-11e7-bc31-5554df9b496b",
                "message_type": "response",
                "next_message_ids": [
                    {
                        "message_id": "16f1c520-05c6-11e7-bc31-5554df9b496b",
                        "action": "*",
                        "intent": "",
                        "conditional": false
                    }
                ],
                "previous_message_ids": [],
                "is_root": true,
                "payload": {
                    "en": {
                        "facebook": {
                            "blocks": [
                                []
                            ]
                        }
                    }
                }
            },
            {
                "message_id": "16f1c520-05c6-11e7-bc31-5554df9b496b",
                "message_type": "response",
                "next_message_ids": [
                    {
                        "message_id": "16f1c520-05c6-11e7-bc31-5554df9b496b",
                        "action": "*",
                        "intent": "",
                        "conditional": false
                    }
                ],
                "previous_message_ids": [
                    {
                        "message_id": "16f1c520-05c6-11e7-bc31-5554df9b496b",
                        "action": "*"
                    }
                ],
                "is_root": false,
                "payload": {
                    "en": {
                        "facebook": {
                            "blocks": [
                                {
                                    "component_type": "text",
                                    "nodeName": "Bot Says",
                                    "text": "Your bot reply goes here...",
                                    "buttons": [],
                                    "delay": 2000,
                                    "workflow_index": 0
                                }
                            ]
                        }
                    }
                }
            },
        ]
    },
    "slots": {
        "34cb53e0-898e-11ea-a937-3f5c9b13d9b8": []
    },
    "variables": [],
    "created_at": {
        "date": "2020-04-28 20:24:05.000000",
        "timezone_type": 3,
        "timezone": "UTC"
    },
    "updated_at": {
        "date": "2020-04-30 17:02:40.000000",
        "timezone_type": 3,
        "timezone": "UTC"
    }
}

getIntents(teamId: string, projectId: string): FetchResult

This method takes in a teamId and projectId and returns all the intents of a specific project. It returns an array of intent object and each object consists of an intent id, name, list of utterances and some meta information like created_at and updated_at

[
    {
        "id": "16f1c520-05c6-11e7-bc31-5554df9b496b",
        "name": "Order Pizza",
        "utterances": {
            "en": [
                {
                    "text": "I want to order pizza",
                    "variables": []
                },
                {
                    "text": "Order pizza",
                    "variables": []
                }
            ]
        },
        "created_at": {
            "date": "2020-04-28 20:24:05.000000",
            "timezone_type": 3,
            "timezone": "UTC"
        },
        "updated_at": {
            "date": "2020-04-28 20:24:05.000000",
            "timezone_type": 3,
            "timezone": "UTC"
        },
        "is_global": false,
        "slots": []
    }
]

getEntities(teamId: string, projectId: string): FetchResult

This method takes in same as getIntents method a teamId and projectId and returns all the entities of a specific project. The sample JSON is shown below.

[
    {
        "id": "16f1c520-05c6-11e7-bc31-5554df9b496b",
        "name": "orderTime",
        "data": {
            "en": [
                {
                    "value": "lunch",
                    "synonyms": [
                        "brunch"
                    ]
                },
                {
                    "value": "breakfast",
                    "synonyms": []
                }
            ]
        },
        "created_at": {
            "date": "2020-04-30 17:36:10.000000",
            "timezone_type": 3,
            "timezone": "UTC"
        },
        "updated_at": {
            "date": "2020-04-30 17:36:10.000000",
            "timezone_type": 3,
            "timezone": "UTC"
        }
    }
]

Batch Requests

An Enum containing all resource names can be imported as follows:

import { Resource } from "@botmock/client";
export enum Resource {
  PROJECT = "project",
  TEAM = "team",
  BOARD = "board",
  INTENTS = "intents",
  VARIABLES = "variables",
  ENTITIES = "entities",
}

This import gives us access to names of all available resources. When we call getResources its on us which resources we need. so we need to pass then in the parameters of getResources method as shown below. It can all but it can also be a few on them.

getResources method

This public method can be used to fetch an array of resource names from a given project:

import { Client } from "@botmock/client";

const client = new Client({ token: process.env.TOKEN });

(async () => {
  const { intents, project } = await client.getResources({
    resources: [Resource.INTENTS, Resource.PROJECT], // Here we are going to only get two resources
    teamId: "1",
    projectId: "1",
    boardId: "1",
  });
})();

client.getResources promise resolves with an object containing keys for each of the elements of resources array.

Reporting Issues

If you would like to report an issue please feel free to send an email to help@botmock.com

Thanks for using Botmock! Happy Prototyping 😎 😎 👩🏻‍🎨 👨🏻‍🎨 😎 😎

FAQs

Package last updated on 01 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc