Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

To use the API, you’ll need to have an API key that needs to be included in all request headers. This key API keys can be generated through the django admin page. Please note that “normal“ users do not have access to this page, so a dimagi employee with the superuser role will have to generate this key for you.created on the user profile page. All requests needs to specify the the API key in the X-API-KEY header for authentication.

Request headers example

Code Block
Accept: "application/json"
X-Api-Key: <your-api-key>

Supported Endpoints

List a team’s experiments

Info

This endpoint is paginated. The response body will include links to the next and previous pages

URL: https://chatbots.dimagi.com/api/experiments

Method: GET

Response body:

Code Block
languagejson
{
  "results": ["name": "experiment 1", "experiment_id": "1cc121f1-e69f-4340-9fef-91daf735f6bc"],
  "next": "<url to the next page>",
  "previous": "<url to the previous page>"
}

Send a message to the bot

Info

Your client needs to wait for the bot response in this call. There is currently no way to ask for it in the future

URL: https://chatbots.dimagi.com/channels/api/<experiment-id>/incoming_message

Method: POST

Request body:

Code Block
languagejson
{
  "message": "Your message for the bot"
}

Response body:

Code Block
languagejson
{
  "response": "the bot's response"
}

Add or Update participant data

URL: https://chatbots.dimagi.com/channels/api/participants/<participant-id>

Method: POST

Request body:

Code Block
languagejson
{
  "participant-1-id": {"name": "John", "surname": "Doe"},
  "participant-2-id": {"name": "Jane", "surname": "Doe"},
}

Response body:

Info

If there are errors, the errors key will be present in the response body, otherwise it will be empty

...

languagejson

...

For the full list of API endpoints and the data schema’s go to the live API docs.