Menu

Salesa - Basic Api Usage

To access the API, you need to make s simple post request with JSON data.

The input arguments are as follows:

 1. customer_key (string) - This is your auth token. You can find it here

 2. api_key (string) - This is your API key. You can find it here

 3. bot_id (integer) - You can fin your bot id on the id column to the left of the bot name in your bot management page

 4. user_input (string) - This is the sentence that the human user is saying to the bot. Keep in mind that to initiate any conversation, you must first send '' to the bot upon which it will begin by saying the opening sentence as given in the training. You can forward this response to the user and then send their reponse to the bot until the conversation ends.

 5. user_id (integer) - To allow the bot to differentiate between people and manage conversations, you need to provide a unique numeric id to each human user.

 6. training_profile_id (integer) - This is the training profile you want your bot to use for this conversation

The following is an example API call in Python

import requests

import json

your_response = input('User: ')

customer_key = 'Your auth token goes here'

bot_id = 0 # Your bot id goes here

api_key = "Your API key goes here"

training_profile = 0 # Your training profile id goes here

user_id = 0 # Your user id goes here

url = 'http://salesa.org/api/core/'

input_argument_dictionary = {'customer_key': customer_key,

              'api_key': api_key,

              'bot_id': bot_id,

              'user_input': your_response,

              'user_id': user_id,

              'training_profile_id': training_profile,

              }

resp = requests.post(url, data=json.dumps(input_argument_dictionary))

data = resp.json()

print(data)

print(data.get('response'))