Skip to main content

Conversational

In questa sezione


Algho allows you to build your own custom client that communicates with the conversational API. You can create your own web client, mobile or integrated into existing applications.

Workflow

The workflow consists of six steps:

  1. Assign user Id
  2. Get bot info to retrieve settings like language, welcome message, etc..
  3. Get history messages for user (optional)
  4. Send text message and receive response
  5. Engagement (optional)
  6. Upvote or downvote the bot answer (optional)

Some fields are not documented because they are not necessary for the implementation of a client and may be changed in the future. Only documented fields should be used because others remained for backward compatibility and will be removed in future updates.

API Endpoints

Use the correct endpoint based on your Algho account.

ServerUrl
Qplushttps://virtualassistant.qplus.ai/api
AlghoOnCloudhttps://virtualassistant.alghoncloud.com/api

Common call response

All calls return the following JSON fields structure:

FieldDescriptionType
botIdbot id identifierstring
responseTyperesponse type 'OK': success, 'KO': errorstring
messageCodemessage codestring
messageerror or operationstring
serverTimeserver timedatetime
valuedata resultobject

The value field contains the response data of the call to the API.

Example

{
"botId" : "0b76f9173c941284f566a2460c7efeb5",
"message" : "",
"responseType" : "OK",
"messageCode" : "OK",
"value" : {...},
"serverTime" : "2019-11-18 17:40:13"
}

1 - Define user Id

All APIs must be supplied with the user_id field. User Id must be unique for users, and must be generated.

Do not use incremental numeric values for security reason.

It is suggested to use a prefix that indicates the name of the application or client developed.

You can save user_id in a cookie if you are developing a web application or with another system if the application is not web.

Example

e43e69e1bbaf23962e04998d26d6798a828d5359c832e0d699f5fce6b0dd019b26e0d04f560b62f3abd7e948336bc494

2 - Get bot info

You can retrieve bot info from API

Method: GET
Url: /api/bot/{bot_id}?user_id={user_id}&bot_group_id={bot_group_id}&lang={lang}

Request params

FieldDescriptionType
bot_idbot id (optional)string
user_iduser id (optional)string
bot_group_idbot group id (optional)int
langbot language desired (optional)string

Response structure

FieldDescriptionType
countrybot countrystring
standByMessagestandby messagestring
downvoteSelfLearningif true, downvote self learning is activeboolean
welcomeVideowelcome video urlstring
votingif true, answer voting is activeboolean
emotionalAnalysisif true, emotional analysis is enabledboolean
ownerIdbot owner identifierstring
hasConversationItemsuser has conversate with bot in previous timeboolean
callToActionarray of call to actions (eg. website url, phone number, email address)array
useContextEnabledif true, context analysis is enabledboolean
noHistoryhistory disabledboolean
optionsarray of questions used as welcome suggestions see tablearray
welcomeBackMessagewelcome back messagestring
standBybot is in stand by modeboolean
showAvatarImageif true, avatar image should be shownboolean
namebot namestring
poweredBymessage to show in the footer (if needed)string
useContextnumber of sentences considered as contextint
engagementTimeseconds to wait before call engagement from last requestint
genderf female, m malestring
descriptionbot descriptionstring
headerColorheader color (in rgb format)string
pageBackgroundbackground color (in rgba format)string
botIdbot id identifierstring
langbot language (see table)string
upvoteSelfLearningif true, upvote self learning is activeboolean
emotionalModuleDescriptionemotional module descriptionstring
welcomeMessagewelcome message to showstring
licenseEnabledlicense of the bot is in enabledboolean
createTimebot creation datetimedatetime
avatarImageavatar image urlstring
Details

Example Request:

GET https://virtualassistant.alghoncloud.com/api/bot/0b76f9173c941284f566a2460c7efeb5?user_id=e43e69e1bbaf23962e04998d26d6798a828d5359c832e0d699f5fce6b0dd019b26e0d04f560b62f3abd7e948336bc494

Response:

Content-Type: application/json
Body:
{
"responseType": "OK",
"messageCode": "OK",
"serverTime": "2022-02-23 11:30:57",
"botId": "0b76f9173c941284f566a2460c7efeb5",
"message": "Bot found",
"value": {
"country": "IT",
"standByMessage": "<p> Questo è il mio nuovo messaggio di standby. </p>",
"downvoteSelfLearning": false,
"customAudio": false,
"welcomeVideo": "",
"voting": true,
"emotionalAnalysis": true,
"narrationMessage": "<p>Vuoi che descriva il prodotto?</p>",
"ownerId": "8234gf380r12480r7823gt4r",
"showActivationDays": false,
"hasConversationItems": false,
"callToAction": {
"website": "",
"operator": false
},
"useContextEnabled": false,
"noHistory": false,
"features": {
"summarization": false,
"livechat": true,
"booking": false,
"vocalAssistant": true,
"bi": true,
"tourverse": false,
"nlg": false,
"telegram": true,
"textAssistant": true,
"learning": true,
"emotionalAnalysis": true,
"livechatZendesk": false,
"digitalHumanInterface": true,
"dynamics": true,
"rss": false,
"zendesk": true,
"messenger": true,
"smartDocumentAccess": true,
"voip": true,
"mailbot": false,
"kioskBanner": true,
"licenseId": "cbed1eb5c77f8f8bc18a1566fe20e489",
"magento": true,
"kiosk": true,
"n8n": false
},
"voiceId": "it-IT-Wavenet-C",
"limitsExceded": false,
"options": [
{
"optionType": "NextQuestion",
"optionId": "176356",
"optionText": "cosa sai fare?",
"nextQuestionType": "QA"
}
],
"welcomeBackMessage": "<p>Ciao! Bentornato!</p>",
"lookStyleId": "0",
"operatorUnavalaibleMessage": "<p>Al momento i nostri operatori sono occupati. Riprova più tardi.</p>",
"requestOperatorInMessage": "",
"standBy": false,
"operatorDisconnectMessage": "<p>Si è ora in contatto con il chatbot.</p>",
"showAvatarImage": false,
"operatorSelfLearning": false,
"rejectToCallWithOperatorMessage": "",
"narrationRules": [],
"paragraphDelayString": "MEDIUM",
"meta": {},
"name": "Gaia",
"poweredBy": "",
"useContext": 0,
"engagementTime": 60,
"gender": "m",
"disambiguationMessageWithSuggestions": "Potresti aiutarmi a capire meglio cosa ti interessa? Scegli tra queste possibilità",
"description": "",
"narrationNotAvailableMessage": "Mi dispiace, non sono ancora in grado di leggere questa pagina",
"headerColor": "rgb(56, 171, 222)",
"pageBackground": "rgba(55, 55, 55, 0.95)",
"stopWordsSize": 0,
"botId": "ab1b3fb73632eca762d9789b5d130484",
"lang": "it",
"paragraphDelay": "MEDIUM",
"upvoteSelfLearning": false,
"emotionalModuleDescription": "Da definire",
"disambiguationMessageWithoutSuggestions": "Verifica se ciò che mi chiedi è tra questi suggerimenti",
"disengageMessage": "",
"welcomeMessage": "",
"operatorConnectMessage": "<p>Si è ora in contatto con un operatore.</p>",
"licenseEnabled": false,
"banner": false,
"speech": false,
"createTime": "2021-10-06 17:18:49",
"avatarImage": "https://staging-builder.alghoncloud.com/img/avatar/1.png",
"narration": 0,
"bannerRandom": false
}
}

Not all fields are necessarily present

3 - History messages

if noHistory is false or hasConversationItems is true, you can retrieve user history messages.

method: GET
url: /api/conversate_item/list?bot_id={bot_id}&user_id={user_id}&conversation_id={conversation_id}&answer_id={answer_id}&offset={offset}&step={step}&sort={sort}

Request params

FieldDescriptionType
bot_idbot id (required)string
user_iduser id (required)string
conversation_idconversation id (optional)int
answer_idanswer id (optional)int
offsetstart position (optional)int
stepnumbers of items (optional)int
sortsort order (optional) see tablestring

Response field

FieldDescriptionType
datemessage datetimedatetime
currentUrlintegration site page urlstring
questionIdquestion idint
conversationIdconversation idint
responseTimeresponse time (in millis)int
ipIP address of the client from which the conversation originatedstring
sourcesource type see tablestring
conversationItemIdconversation item idint
userIduser idstring
userQuestionuser questionstring
questionTextquestion textstring
callTypecall type (standard or sandbox for sandbox mode)string
botMessageTypebot message type see tablestring
botMessageIdbot message idstring
sourceTypecustom app name (not to be confused with source)string
inputModeinput mode see tablestring
optionsArray of options (suggestions or admissible values) see tablearray
botMessageTextbot response textstring
botIdbot idstring
fieldTypefield type object see tableobject
questionTypequestion type see tablestring

Sort option

CodeDescription
conversation_item_idorder by conversationItemId (ascending)
conversation_item_id DESCorder by conversationItemId (descending)
Details

Example Request:

GET https://virtualassistant.alghoncloud.com/api/conversate_item/list?bot_id=0b76f9173c941284f566a2460c7efeb5&user_id=e43e69e1bbaf23962e04998d26d6798a828d5359c832e0d699f5fce6b0dd019b26e0d04f560b62f3abd7e948336bc494&sort=conversation_item_id+DESC&offset=0&step=2

Response:

Content-Type: application/json
Body:
{
"responseType": "OK",
"messageCode": "OK",
"serverTime": "2022-03-02 10:47:00",
"message": "0b76f9173c941284f566a2460c7efeb5",
"value": [
{
"date": "2022-02-23 12:29:37",
"currentUrl": "https://staging-fe.alghoncloud.com/text/?bot=0b76f9173c941284f566a2460c7efeb5",
"questionId": "123776",
"conversationId": 121990,
"responseTime": 381,
"ip": "10.0.0.1",
"source": "text_landscape",
"conversationItemId": 331675,
"userId": "e43e69e1bbaf23962e04998d26d6798a828d5359c832e0d699f5fce6b0dd019b26e0d04f560b62f3abd7e948336bc494",
"userQuestion": "ciao",
"questionText": "Ciao. Buongiorno. Salve. Buonasera",
"callType": "standard",
"botMessageType": "QA",
"botMessageId": "202612",
"sourceType": "web",
"inputMode": "keyboard",
"options": [],
"botMessageText": "Ciao",
"botId": "0b76f9173c941284f566a2460c7efeb5",
"fieldType": {
"suggestGlobalSearch": false,
"suggestPreviousValues": false,
"name": "Bool",
"type": "BoolFieldType",
"fieldTypeId": 5,
"sensible": false
},
"questionType": "STANDARD"
},
{
"date": "2022-02-23 12:29:37",
"currentUrl": "https://staging-fe.alghoncloud.com/text/?bot=0b76f9173c941284f566a2460c7efeb5",
"questionId": "123776",
"conversationId": 121990,
"ip": "10.0.0.1",
"source": "text_landscape",
"conversationItemId": 331676,
"userId": "e43e69e1bbaf23962e04998d26d6798a828d5359c832e0d699f5fce6b0dd019b26e0d04f560b62f3abd7e948336bc494",
"callType": "standard",
"botMessageType": "FORM",
"sourceType": "web",
"inputMode": "keyboard",
"options": [
{
"optionType": "AdmissibleValue",
"optionValue": "SI",
"id": "",
"optionText": "SI"
},
{
"optionType": "AdmissibleValue",
"optionValue": "NO",
"id": "",
"optionText": "NO"
},
{
"optionType": "SkipValue",
"optionValue": "Avanti",
"optionText": "Avanti"
},
{
"optionType": "EndValue",
"optionValue": "Interrompi la compilazione",
"optionText": "Interrompi la compilazione"
}
],
"botMessageText": "<p>form test</p>",
"botId": "0b76f9173c941284f566a2460c7efeb5",
"fieldType": {
"suggestGlobalSearch": false,
"suggestPreviousValues": false,
"name": "Bool",
"type": "BoolFieldType",
"fieldTypeId": 5,
"sensible": false
},
"questionType": "STANDARD"
}
]
}

Question type

TypeDescription
STANDARDstandard
SLIDESHOWslideshow (image carousel)

4 - Conversate

Allow to comunicate with bot.

Method: POST
Content-Type: application/json
alghoToken: MTIzNDU2Nzg5MA==
Url: /api/conversate_item/send_message?tts={tts}&lipSync={lipSync}

HTTP Request headers

FieldDescriptionType
alghoTokenany custom context data in base64string

Request params

FieldDescriptionType
ttstts response type (optional, default: NONE__) see tablestring
lipSyncif true, show lip sync data (optional, default: false__)boolean
info

The behavior of tts and lipSync parameters depends on the source field of JSON body.

JSON Request fields

FieldDescriptionType
userIduser idstring
botIdbot id identifierstring
sourceTypecustom app name (not to be confused with source)string
conversationIdconversation id (first call: null)int
currentUrlurl where bot is integratedstring
question_texttext to send (required) Max lenght: 1000string
questionIdquestion id of clicked option (-1 default)int
commandcommand code of clicked option (if present) see tablestring
inputModeinput mode see tablestring
sourcesource type see tablestring
callTypecall type (standard or sandbox for sandbox mode)string
optionTypeoption type of clicked option see tablestring
applicationContextapplication context (used for targeted answers)string
disableFieldHistoryfor form answers, if true, field suggestions from conversation history are disabledstring
wsBasePathurl base for Algho Forms (optional)If present, it will be used to compose the final url by combining it with the relative one saved on the forms/fields.string

After first call you can retrieve questionId value to pass to next call.

Details

Example Request:

Method: POST
Url: https://virtualassistant.alghoncloud.com/api/conversate_item/send_message
alghoToken: MTIzNDU2Nzg5MA==
Content-Type: application/json
Body:
{
"userId": "e43e69e1bbaf23962e04998d26d6798a828d5359c832e0d699f5fce6b0dd019b26e0d04f560b62f3abd7e948336bc494",
"botId": "0b76f9173c941284f566a2460c7efeb5",
"sourceType": "web",
"conversationId": null,
"currentUrl": "https://virtualassistant.alghoncloud.com/?bot=0b76f9173c941284f566a2460c7efeb5",
"question_text": "come stai?",
"questionId": -1,
"command": "",
"callType": "standard",
"inputMode": "keyboard",
"source": "text_landscape",
"disableFieldHistory": false,
"applicationContext": null,
"wsBasePath": null,
"optionType": "NextQuestion"
}

Response:

Content-Type: application/json
Body:
{
"botId" : "0b76f9173c941284f566a2460c7efeb5",
"message" : "",
"responseType" : "OK",
"messageCode" : "OK",
"value" : {
"conversationId" : 104276,
"question" : "Hi. Good morning.",
"userQuestionText" : "Hi",
"questionId" : "68659",
"solrScore" : 1.2242327,
"score" : 0.5519999999999999,
"baseQA" : true,
"botId" : "0b76f9173c941284f566a2460c7efeb5",
"answerList" : [ {
"answerId" : "106049",
"answerText" : "Hi",
"order" : 0,
"answerType" : "QA",
"options" : [ {
"optionText" : "What can you do?",
"optionId" : "68645",
"nextQuestionType" : "QA",
"optionType" : "NextQuestion"
}, {
"optionText" : "What can I ask you?",
"optionId" : "68663",
"nextQuestionType" : "QA",
"optionType" : "NextQuestion"
}, {
"optionText" : "What can you talk about?",
"optionId" : "68668",
"nextQuestionType" : "QA",
"optionType" : "NextQuestion"
} ],
"insertTime": "2021-10-06 17:19:01",
"updateTime": "2022-01-19 16:23:30",
"ttsAnswerList" : [ {
"htmlText" : "<p>Hi. Good morning.</p>",
"plainText" : "Hi. Good morning.",
"ssmlText" : "<speak> \n <p>Hi. Good morning.</p> \n</speak>"
} ],
"questionId" : "68659",
"enableSuggestions": "common"
} ],
"answerType" : "QA",
"questionType": "STANDARD"
},
"conversationId" : 104276,
"serverTime" : "2019-11-18 17:40:13"
}
info

The answer text of the bot is in HTML and must be converted to plain text using regular expressions if the developed client is not web.

Response field

FieldDescriptionType
conversationIdConversation Idint
questionbot question matchstring
userQuestionTextuser question textstring
questionIdbot question match idint
scoreaffinity score between user question and bot questionint
baseQAif true, this is base bot questionboolean
botIdbot idstring
answerListArray of response see tablearray
answerTypeanswer type see tablestring
commandcommand code (optional) see tablestring
frontEndMessagefront end message code (optional) see tablestring
questionTypequestion type (optional) see tablestring

Answer object

FieldDescriptionType
answerIdanswer idstring
answerTextanswer text in htmlstring
mediamedia url (optional)string
mediaTypemedia type (optional) see tablestring
ordersort order (zero based)int
answerTypeanswer type see tablestring
optionsarray of options (suggestions) see tablearray
fieldfield object if answerType equal FORM (optional) see tablearray
payloadCustom command (used for browser automation, voip commands)string
insertTimebot question insert time (optional)datetime
updateTimebot question update time (optional)datetime
ttsAnswerListarray of tts data for the answer (optional) see tablearray
questionIdquestion idint

Option object

FieldDescriptionType
optionTextoption textstring
optionIdoption idstring
nextQuestionTypenext question type see tablestring
optionTypeoption type see tablestring
suggestionTypesuggestion type see table (optional)string
commandcommand code see table (optional)string

Field object

FieldDescriptionType
fieldTemplateIdfield template idint
fieldTypefield type object see tableobject
formTemplateIdfield template idint
ownerIdowner identifierstring
namefield namestring
questionTextquestion text (used to introduce the field)string
ordersort order (zero based)int
requiredfield is requiredboolean
maxValuesToSelectmax values to selectint
requiredByEtlif true, field is required by ETL flowboolean
deletableif true, field is deletableboolean
avSemanticMatchif true, semantic match is activeboolean
forceValidationif true, validation is also forced for fields that usually do not require itboolean
validationRegexregex used for field validationstring
entitiesAutofillif true, autofill for entities is activeboolean
disableWritingif true, free writing must not be allowedboolean
skipSemanticValidationif true, semantic validation will be skipped for this field valueboolean

Field type object

FieldDescriptionType
fieldTypeIdfield type idint
namefield type namestring
typefield type enum see tablestring
suggestPreviousValuesif true, previous values could be used as suggested valuesboolean
sensibleif true, this field contains sensitive databoolean

TTS object

FieldDescriptionType
htmlTextanswer text with tagsstring
plainTextanswer text without tags (plain)string
ssmlTextanswer text with ssml tagsstring
audioUrlurl of generated audio filestring
lipSyncDatalip sync dataobject

Answer type

TypeNameDescription
QAAnsweranswer found in the knowledge base
QBQuibblecircumstance answers for questions to which the chatbot has no answer
QEEngagementmessage of engagement
FORMFormmessage asking to provide the value for a form field
RQResume QAmessage displayed when the user resume conversation after 15 minutes of inactivity
TRTrainingmessage displayed when the knowledge base is in a training state
SBStanbyanswer returned when the bot is in stanby mode
SMSorryanswer returned when a user downvote an answer

NextQuestion type

TypeDescription
QAAnswer
FORMForm

Option Type

TypeDescription
NextQuestionnext question to ask
AdmissibleValueform admissible value for field
SuggestedValueform suggested value for field
SkipValueskip form field if is not required
EndValueterminate form
Downvoteused if the voting function is active (voting feature)

Suggestion type

TypeDescription
SuggestedValueis suggested value to highlight (value previously used)

Command code

CodeDescription
WS_NEXT_PAGEallow to call form submit for next results (pagination)
SDA_SEARCHallow to call sda search for results
SDA_NEXT_PAGEallow to call sda for next results (pagination)
ETL_NEXT_PAGEallow to call etl for next results (pagination)
info

The command type must be retransmitted in the conversation calls if present in the option clicked.

The command types can be expanded in the future.

InputMode type

TypeDescription
clickedclick (selection of suggested or admissible value)
keyboardkeyboard
vocalvocal

Source type

TypeDescription
text_embeddedtext version of an embedded script
voice_embeddedvoice version of an embedded script
dhi_embeddeddhi version of an embedded script
text_landscapetext version of a fullscreen app
voice_landscapevoice version of a fullscreen app
dhi_landscapedhi version of a fullscreen app
kioskkiosk mode (reserved)
customuse this value for custom integrations
unknownunknown source
socialintegration with social networks (eg. Telegram, Messenger, etc.)
voipintegration with voip systems

Media type

TypeDescription
linklink url
iframeurl which should be shown in an iframe
imgimage url
videovideo (youtube, vimeo, embedded video)
fileurl or base64 file
qrcodeurl to qr code image file
smart_document_accessSDA Document
info

If Media Type is video, the media field contains embed url or direct link.

If Media Type is file, the media field may contain an url or base64 content in the following format:

data:application/pdf;base64,JVBERi0xLjQNJe......

Field type

FieldType can have the following values:

TypeDescription
TextFieldTypeis a plain text
EmailFieldTypeis an email address
TelFieldTypeis a phone number
LocationFieldTypeis an address
DateFieldTypeis a date (yyyy:MM:dd) or a date is extracted from text
HourFieldTyperepresents an hour (HH:mm)
NumFieldTypeis a number
BoolFieldTypeis true or false
UrlFieldTypeis an URL
FullNameFieldTypeis a name and surname or a name and surname are extracted from text
CFFieldTyperepresent a tax code
MultiSelectFieldTypemulti select
BirthDateFieldTypeit's a date (yyyy:MM:dd) before today
NameFieldTypeis a name or a name is extracted from text
SurnameFieldTypeis a surname or a surname is extracted from text
PrivacyFieldTypeis a privacy consent (true or false)
FileFieldTypeis an URI referred to a file
VatFieldTypeit's a VAT number
PasswordFieldTypeit's a password
DateRangeFieldTypeis a range in the form of yyyy:MM:dd - yyyy:MM:dd
DayFieldTypeis a day (Monday, Tuesday, ...), depends on form language
HourRangeFieldTypeis a range in the form of HH:mm - HH:mm
DayRangeFieldTypeis a range of days (e.g. Monday - Friday)
PostalCodeFieldTypeis a postal code
BookingDateFieldTypeis a date in the form of yyyy:MM:dd after today
BusinessFieldTypeis a business name
MeasureFieldTypeis a measure value (eg. 1 kg)
CurrencyFieldTypeis a currency value (eg. 1 $)
QuantityFieldTypeis a quantity value
CatalogFieldTypeis a catalog of items
OrderFieldTypeis an order number
QRCodeFieldTypevalue should be retrieved with a qr code reader
info

Algho uses internal validators for these types of fields.

TTS type

CodeDescription
NONEno tts data requested
SINGLErequest single tts data (single sentence) with audio file (in audioUrl of tts object)
MULTIPLErequest multiple tts data (for answers with multiple sentences) with audio file
TEXT_SINGLErequest single tts data (single sentence) without audio file
TEXT_MULTIPLErequest multiple tts data (for answers with multiple sentences) without audio file

Frontend message

CodeDescription
FORM_STARTindicates that the form begins
FORM_ENDindicates that the form is finished
info

Algho notifies these events to the client.

Language codes

CodeDescription
itItalian
enEnglish
esSpanish
ptPortuguese
frFrench
deGerman
roRomanian
zhChinese
ruRussian
Details

Example Response with form:

Content-Type: application/json
Body:
{
"responseType" : "OK",
"messageCode" : "OK",
"value" : {
"conversationId" : 126863,
"question" : "I'm looking for where to eat",
"userQuestionText" : "I'm looking for where to eat",
"questionId" : "206538",
"solrScore" : 1837.0525,
"score" : 100.0,
"baseQA" : false,
"botId" : "0b76f9173c941284f566a2460c7efeb5",
"answerList" : [ {
"answerId" : "314327",
"answerText" : "<p>Ok</p>",
"order" : 9999,
"answerType" : "QA",
"insertTime" : "2022-09-14 15:26:42",
"updateTime" : "2022-09-14 15:26:42",
"ttsAnswerList" : [ {
"htmlText" : "<p>Ok</p>",
"plainText" : "Ok",
"ssmlText" : "<speak> \n <p>Ok</p> \n</speak>"
} ],
"gloss" : {"values":[]},
"conversationItemId" : 382845,
"questionId" : "206538",
"enableSuggestions" : "common"
}, {
"answerText" : "<p>What do you want to look for?</p>",
"order" : 1,
"answerType" : "FORM",
"options" : [ {
"optionText" : "Kebab",
"optionValue" : "Kebab",
"optionType" : "AdmissibleValue"
}, {
"optionText" : "Restaurant",
"optionValue" : "Restaurant",
"optionType" : "AdmissibleValue"
}, {
"optionText" : "Tavern",
"optionValue" : "Tavern",
"optionType" : "AdmissibleValue"
}, {
"optionText" : "Avanti",
"optionValue" : "Avanti",
"optionType" : "SkipValue"
}, {
"optionText" : "Annulla",
"optionValue" : "Annulla",
"optionType" : "EndValue"
} ],
"ttsAnswerList" : [ {
"htmlText" : "<p>What do you want to look for?</p>",
"plainText" : "What do you want to look for?",
"ssmlText" : "<speak> \n <p>What do you want to look for?</p> \n</speak>"
} ],
"conversationItemId" : 382846,
"field" : {
"fieldTemplateId" : 23338,
"fieldType" : {
"fieldTypeId" : 2,
"name" : "Text",
"type" : "TextFieldType",
"suggestPreviousValues" : true,
"suggestGlobalSearch" : false,
"sensible" : false
},
"formTemplateId" : 4132,
"ownerId" : "7d7ea2fc47d182e311ebad6f740174e5",
"name" : "tipo",
"questionText" : "<p>What do you want to look for?</p>",
"order" : 0,
"required" : false,
"maxValuesToSelect" : 1,
"requiredByEtl" : false,
"deletable" : true,
"gdprCompliance" : true,
"hiddenAdmissibleValues" : false,
"customPicker" : false,
"avSemanticMatch" : false,
"selfLearning" : false,
"entitiesAutofill" : false,
"disableWriting" : true,
"showDuringAutofill" : false,
"showInFullscreen" : false,
"skipSemanticValidation" : false,
"admissibleValuesCount" : 0,
"fieldTypeString" : "TextFieldType"
},
"avNextUrl" : ""
} ],
"answerType" : "QA",
"frontEndMessage" : "FORM_START",
"questionType" : "STANDARD",
"scoreOrSolrScore" : 100.0
},
"serverTime" : "2022-09-14 15:26:53"
}

5 - Engagement

Get the bot engagement messages to show the user after a certain period of inactivity.

Method: POST
Url: /api/engagement/conversation/{conversation_id}?next_engagement={next_engagement}&current_url={current_url}&inputMode={inputMode}&source={source}&callType={callType}&tts={tts}&lipSync={lipSync}&applicationContext={applicationContext}

Request params

FieldDescriptionType
conversation_idconversation id (required)int
next_engagementengagement counter (zero based) (required)int
current_urlcurrent browser url (optional)string
inputModeinput mode see tablestring
sourcesource type see tablestring
callTypecall type (standard or sandbox for sandbox mode)string
ttstts response type (optional, default: NONE__) see tablestring
lipSyncif true, show lip sync data (optional, default: false__)boolean
applicationContextapplication context (used for targeted answers)string
info

The behavior of tts and lipSync parameters depends on the source field of JSON body.

Details

Example Request:

POST https://virtualassistant.alghoncloud.com/api/engagement/conversation/104239?next_engagement=0&current_url=https%3A%2F%2Fvirtualassistant.alghoncloud.com%2F%3Fbot%3D0b76f9173c941284f566a2460c7efeb5

Response:

Content-Type: application/json
Body:
{
"responseType": "OK",
"messageCode": "OK",
"serverTime": "2019-11-20 15:37:34",
"botId": "0b76f9173c941284f566a2460c7efeb5",
"message": "",
"value": {
"answerId": "2325",
"baseEngagement": true,
"viewOrder": 0,
"answerText": "<p>Hey, if you need help, I'm here!<\/p>",
"enableSuggestions": 1,
"ttsAnswerList": [
{
"ssmlText": "<speak> \n <p>Hey, if you need help, I'm here!<\/p> \n<\/speak>",
"plainText": "Hey, if you need help, I'm here!",
"htmlText": "<p>Hey, if you need help, I'm here!<\/p>"
}
],
"answerType": "QE",
"options": [
{
"optionType": "NextQuestion",
"optionId": "123762",
"optionText": "Cosa sai fare?",
"nextQuestionType": "QA"
},
{
"optionType": "NextQuestion",
"optionId": "123780",
"optionText": "Che domande posso farti?",
"nextQuestionType": "QA"
}
],
"nextEngagementTime": 20,
"botId": "0b76f9173c941284f566a2460c7efeb5",
"label": "15 secondi",
"oneShot": false
}
}

Response structure

FieldDescriptionType
answerIdanswer idstring
answerTextanswer text in htmlstring
answerTypeanswer type see tablestring
baseEngagementdefault bot engagementboolean
mediamedia url (optional)string
mediaTypemedia type (optional) see tablestring
nextEngamentTimeseconds to wait before call engagement from last request (if -1 stop)int
optionsarray of options (suggestions) see tablearray
ttsAnswerListarray of tts data for the answer (optional) see tablearray
labelname of engagement groupstring
oneShotif true, this engagement is shown only onceboolean
info

The field nextEngamentTime return seconds to wait for next engagement. If value is -1 you can stop.

info

After a call you must increment next_engagement counter.

info

After any user request you must reset next_engagement to 0 and timer.

6 - Upvote an answer

Allows you to upvote the answer given by the bot.

Method: POST
Content-Type: application/json
Url: /api/qa/upvote?question_text={question_text}&answer_id={answer_id}&conversation_id={conversation_id}

Request params

FieldDescriptionType
question_textquestion textstring
answer_idanswer idint
conversation_idconversation idint
Details

Example Request:

Method: POST
Url: https://virtualassistant.alghoncloud.com/api/qa/upvote?question_text=ciao&answer_id=211426&conversation_id=104239
Content-Type: application/json

Response:

Content-Type: application/json
Body:
{
"responseType": "OK",
"messageCode": "OK",
"serverTime": "2022-02-24 11:10:18"
}

7 - Downvote an answer

Allows you to downvote the answer given by the bot.

Method: POST
Content-Type: application/json
Url: /api/qa/downvote?question_text={question_text}&answer_id={answer_id}&conversation_id={conversation_id}&tts={tts}&lipSync={lipSync}

Request params

FieldDescriptionType
question_textquestion textstring
answer_idanswer idint
conversation_idconversation idint
ttstts response type (optional, default: NONE__) see tablestring
lipSyncif true, show lip sync data (optional, default: false__)boolean
Details

Example Request:

Method: POST
Url: https://virtualassistant.alghoncloud.com/api/qa/downvote?question_text=ciao&answer_id=211426&conversation_id=104239
Content-Type: application/json

Response:

Content-Type: application/json
Body:
{
"message": "0b76f9173c941284f566a2460c7efeb5",
"responseType": "OK",
"messageCode": "OK",
"value": {
"conversationId": 104239,
"solrScore": 0,
"score": 0,
"botId": "0b76f9173c941284f566a2460c7efeb5",
"answerList": [
{
"answerText": "Scusa se non sono riuscito a soddisfare la tua richiesta, prova a riformulare la tua domanda.",
"order": 0,
"answerType": "SM"
}
],
"answerType": "SM"
},
"conversationId": 104239,
"serverTime": "2022-02-24 12:02:30"
}