Skip to main content

Chat API

JAICP provides a REST API for integration in third-party applications. For example, you can use it to implement a chat in a mobile app, on a web site, or in a game.

The API allows chatting with either bots or agents.

Connect the Chat API channel

Authorize in JAICP and switch to a project. On the control panel, click Channels → Inbound → Connect channel. Select the Chat API channel.

Fill out the fields:

  • Name — specify the channel name.
  • Access token — leave the field blank.
  • Disable text input when using buttons — select Yes if you want to prevent clients from entering text messages when using buttons in the script.
  • Branch — specify the project branch you want to deploy into the channel (master by default). You can also select a Git tag or enter a specific commit hash.
  • Agent — select an agent channel or leave blank.
  • Deployment — select Automatic (whenever any change made to the project is saved) or Manual (using the Deploy button in the channel description line).
caution
You have to deploy a script before starting the bot. At this stage, the system builds the bot, checks the script syntax, and performs tests.

Click Create. Wait for a pop-up window with the deploy result to appear. If successful, the bot is ready to use.

API access token

tip
You configure an access token when creating a channel. It is required for methods provided by the Chat API.

To obtain an access token, switch to the edit window of the newly created Chat API channel. The Access token field is already populated. Copy the value and use it to access the API.

You can also see examples of GET and POST requests here.

Webhook for asynchronous requests

When working with the Chat API channel, you can use asynchronous requests and receive bot messages or events to a webhook address.

Asynchrony allows you to process several requests simultaneously. You can send new requests without waiting for the server to finish processing the previous ones. For example, with asynchronous requests, you can send text campaigns without delays and receive asynchronous events without additional requests.

To specify a webhook:

  1. Select  in the Chat API channel bar, then Edit channel.
  2. Enter the URL in the Webhook address field.