Submit an Interaction
Declare a Chat Interaction
5 min
// // overview the first step in processing any chat file is to declare the interaction when the post post request successfully executes, an http status is returned to indicate the request was successful, along with a json response containing the interactionidentifier sample api response { "interactionidentifier" "6091d697 9a98 4953 9850 d3e9b82cd5ab" } it is important you store the interactionidentifier as it will serve as a required parameter for all other elevateai endpoints – enabling you to post post , get get , and/or delete delete information associated with this interaction if an error occurs when requesting to declare the interaction, a standard http response code is retuned to indicate the request was unsuccessful, along with a json response containing additional details to assist with troubleshooting all interactions successfully declared will count towards your monthly request quota , regardless of the file upload status or processing outcome only interactions that have successfully processed are eligible for billing > once declared, you can check the processing status of your interaction, as well as tracking impacts to both usage and spend // // request parameters & code samples details on language support for cx ai features can be found on the cx ai features page { "tab" "examples", "url" "https //api elevateai com/v1/interactions", "name" "declare a chat interaction", "method" "post", "request" { "pathparameters" \[], "queryparameters" \[], "headerparameters" \[ { "kind" "required", "name" "x api token", "type" "string", "description" "valid api key associated with your account for authentication and usage tracking" }, { "kind" "required", "name" "content type", "type" "string", "description" "will be 'application/json'" } ], "bodydataparameters" \[ { "kind" "required", "name" "type", "type" "string", "description" "type of interaction to be processed, will be\n\\"chat\\"" }, { "kind" "required", "name" "languagetag", "type" "string", "description" "primary language of the chat, will be \n\\"en us\\" (for north american english), \n\\"en\\" (for international english), or \n\\"es 419\\" (for north american spanish)" }, { "kind" "required", "name" "vertical", "type" "string", "description" "vertical associated with interaction, will be \\"default\\"" }, { "kind" "required", "name" "chat", "type" "object", "description" "formatted chat text (see below)" } ], "formdataparameters" \[] }, "results" { "languages" \[ { "id" "ikvdsxifeiysauk1uae r", "code" "{\n \\"interactionidentifier\\" \\"string\\"\n} ", "language" "201", "customlabel" "" }, { "id" "ogn fhk6dtgaeyiv7jai", "code" "{\n \\"errormessage\\" \\"string\\"\n}", "language" "400", "customlabel" "" }, { "id" "x6cj5u7giqecvl 2yh9jn", "code" "{\r\n \\"errormessage\\" \\"string\\"\r\n}", "language" "401", "customlabel" "" }, { "id" "oa5jretm7 0dbef uj2ue", "code" "{\r\n \\"errormessage\\" \\"string\\"\r\n}", "language" "429", "customlabel" "" } ], "selectedlanguageid" "oa5jretm7 0dbef uj2ue" }, "examples" { "languages" \[ { "id" "b00i4wtyttxkbrpwpgfco", "language" "curl", "code" "curl location 'https //api elevateai com/v1/interactions' \\\\\n header 'x api token string' \\\\\n header 'content type string' \\\\\n data '{\\"type\\" \\"string\\",\\"languagetag\\" \\"string\\",\\"vertical\\" \\"string\\",\\"chat\\" \\"object\\"}'", "customlabel" "" }, { "id" "lzfpbg1mdd4p nw95i41c", "language" "nodejs", "code" "var request = require('request');\nvar options = {\n 'method' 'post',\n 'url' 'https //api elevateai com/v1/interactions',\n 'headers' {\n 'x api token' 'string',\n 'content type' 'string'\n },\n body '{\\"type\\" \\"string\\",\\"languagetag\\" \\"string\\",\\"vertical\\" \\"string\\",\\"chat\\" \\"object\\"}'\n\n};\nrequest(options, function (error, response) {\n if (error) throw new error(error);\n console log(response body);\n});\n", "customlabel" "" }, { "id" "wpvm m7 amub3gnblpp4", "language" "javascript", "code" "var myheaders = new headers();\nmyheaders append(\\"x api token\\", \\"string\\");\nmyheaders append(\\"content type\\", \\"string\\");\n\nvar raw = \\"{\\\\\\"type\\\\\\" \\\\\\"string\\\\\\",\\\\\\"languagetag\\\\\\" \\\\\\"string\\\\\\",\\\\\\"vertical\\\\\\" \\\\\\"string\\\\\\",\\\\\\"chat\\\\\\" \\\\\\"object\\\\\\"}\\";\n\nvar requestoptions = {\n method 'post',\n headers myheaders,\n body raw,\n redirect 'follow'\n};\n\nfetch(\\"https //api elevateai com/v1/interactions\\", requestoptions)\n then(response => response text())\n then(result => console log(result))\n catch(error => console log('error', error));", "customlabel" "" }, { "id" "s1945qbheqs4m9i0n5qrj", "language" "python", "code" "import requests\n\nurl = \\"https //api elevateai com/v1/interactions\\"\n\npayload = \\"{\\\\\\"type\\\\\\" \\\\\\"string\\\\\\",\\\\\\"languagetag\\\\\\" \\\\\\"string\\\\\\",\\\\\\"vertical\\\\\\" \\\\\\"string\\\\\\",\\\\\\"chat\\\\\\" \\\\\\"object\\\\\\"}\\"\nheaders = {\n 'x api token' 'string',\n 'content type' 'string'\n}\n\nresponse = requests request(\\"post\\", url, headers=headers, data=payload)\n\nprint(response text)\n", "customlabel" "" }, { "id" "ko yjci7z4qu2vizph8it", "language" "ruby", "code" "require \\"uri\\"\nrequire \\"net/http\"\n\nurl = uri(\\"https //api elevateai com/v1/interactions\\")\n\nhttps = net http new(url host, url port)\nhttps use ssl = true\n\nrequest = net http post new(url)\nrequest\[\\"x api token\\"] = \\"string\\"\nrequest\[\\"content type\\"] = \\"string\\"\nrequest body = \\"{\\\\\\"type\\\\\\" \\\\\\"string\\\\\\",\\\\\\"languagetag\\\\\\" \\\\\\"string\\\\\\",\\\\\\"vertical\\\\\\" \\\\\\"string\\\\\\",\\\\\\"chat\\\\\\" \\\\\\"object\\\\\\"}\\"\n\nresponse = https request(request)\nputs response read body\n", "customlabel" "" } ], "selectedlanguageid" "wpvm m7 amub3gnblpp4" }, "description" "", "currentnewparameter" { "label" "body parameter", "value" "bodydataparameters" } } // // formatting a chat for processing chat files will be formatted according to the schema below and included as a body parameter when declaring a chat interaction for processing sample chat file format sample chat format { "participants" \[ { "participant id" "elevateai team", "name" "madison", "role" "agent" }, { "participant id" "elevateai evangelist", "name" "developer", "role" "customer" } ], "messages" \[ { "participant id" "elevateai team", "timestamp" "2022 07 04t14 25 15z", "content" "we hope this documentation is useful!" }, { "participant id" "elevateai evangelist", "timestamp" "2022 07 04t14 26 45z", "content" "it is, thank you!" } ] } schema element type description participants array of objects ordered list of details associated with each participant, will include 1+ objects participant/ participant id string unique identifier associated with participant participants/ name string name of participant participants/ role string or null will be agent or customer messages array of objects ordered list of details associated with each chat message, will include 1+ objects messages/ participant id string maps to a unique participant id within participants object messages/ timestamp string date/time that the chat message was sent, formatted according to iso 8601 (utc) guidelines messages/ content string chat message need more help? contact the elevateai support team