### Get Agent Teams (Go) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Agents Example of how to fetch agent teams using Go, likely involving an HTTP GET request to the Dixa API. -------------------------------- ### Get Metric Data (Response Example) Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Analytics Provides an example of the response when requesting aggregated metric data from the Dixa API, showing the metric ID and its aggregated values. ```json { "data": { "id": "closed_conversations", "aggregates": [ { "value": 42, "measure": "Count", "_type": "LongAggregateValue" } ] } } ``` -------------------------------- ### Get Agent Teams (Ruby) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Agents Example of how to fetch agent teams using Ruby, likely involving an HTTP GET request to the Dixa API. -------------------------------- ### Get Agent Teams (Java) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Agents Example of how to fetch agent teams using Java, likely involving an HTTP GET request to the Dixa API. -------------------------------- ### Get Analytics Records (Go) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Analytics Example of how to fetch analytics records using Go. This snippet shows how to construct and send an authenticated GET request to the Dixa API. ```Go // Go example would go here, demonstrating net/http package ``` -------------------------------- ### Get Tag - Example Response Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Tags Example JSON response when retrieving a tag by its ID. It includes the tag's unique identifier, name, and current state (e.g., 'Active'). ```json { "data": { "id": "b794a74a-625b-4303-8237-9b11668a9605", "name": "example", "state": "Active" } } ``` -------------------------------- ### Get Dixa User Conversations (Go) Source: https://docs.dixa.io/openapi/integrations-api/tag/Users Example of fetching conversations for a specific user using Go. This snippet shows how to construct a GET request with the user ID and limit parameter, including authorization. ```go package main import ( "fmt" "net/http" ) func main() { userId := "YOUR_USER_ID_HERE" limit := 200 req, err := http.NewRequest("GET", fmt.Sprintf("https://docs.dixa.io/v1/users/%s/requested_conversations?limit=%d", userId, limit), nil) if err != nil { fmt.Println("Error creating request:", err) return } req.Header.Set("Authorization", "YOUR_API_KEY_HERE") client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } defer resp.Body.Close() // Process response... fmt.Println("Status Code:", resp.StatusCode) } ``` -------------------------------- ### Get Metric Data (Go) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Analytics Example Go code to get metric data. This demonstrates sending a POST request with a JSON payload to the Dixa API, including setting headers for content type and authorization. ```go package main import ( "bytes" "fmt" "io/ioutil" "net/http" "encoding/json" ) func main() { client := &http.Client{} payload := map[string]interface{}{ "id": "closed_conversations", "periodFilter": map[string]interface{}{ "value": map[string]string{ "_type": "PreviousWeek" }, "_type": "Preset" }, "filters": []map[string]interface{}{ { "attribute": "channel", "values": []string{ "email" } } }, "aggregations": []string{ "Count" }, "timezone": "Europe/Copenhagen" } jsonPayload, err := json.Marshal(payload) if err != nil { fmt.Println(err) return } req, err := http.NewRequest("POST", "https://dev.dixa.io/beta/analytics/metrics", bytes.NewBuffer(jsonPayload)) if err != nil { fmt.Println(err) return } req.Header.Set("Content-Type", "application/json") req.Header.Set("Authorization", "YOUR_API_KEY_HERE") resp, err := client.Do(req) if err != nil { fmt.Println(err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Create End User - Go Example Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Chatbots Go code snippet for creating an end user using the net/http package, showing how to send a POST request with a JSON body. ```go package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { url := "https://api.dixa.io/v1/endusers" payload := map[string]interface{}{ "displayName": "Alice Brown", "email": "alice@brown.com", "phoneNumber": "+551155256325", "additionalEmails": []string{"alice@secondary.email"}, "additionalPhoneNumbers": []string{ "+5566778899"}, "firstName": "Alice", "lastName": "Brown", "middleNames": []string{}, "avatarUrl": "http://avatar.url", "externalId": "#12345678" } jsonPayload, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonPayload)) req.Header.Set("Content-Type", "application/json") client := &http.Client{} res, _ := client.Do(req) defer res.Body.Close() fmt.Println("response Status:", res.Status) } ``` -------------------------------- ### Get Conversation Notes (Java) Source: https://docs.dixa.io/openapi/integrations-api/tag/Note This snippet provides an example of how to fetch conversation notes using Java. It typically involves using libraries like Apache HttpClient or OkHttp to perform the GET request. ```java // Java request example would go here, typically using HttpClient. // Example structure: // import java.net.http.HttpClient; // import java.net.http.HttpRequest; // import java.net.http.HttpResponse; // import java.io.IOException; // // HttpClient client = HttpClient.newHttpClient(); // HttpRequest request = HttpRequest.newBuilder() // .uri(URI.create("https://docs.dixa.io/v1/conversations/{csid}/notes")) // .header("Authorization", "YOUR_API_KEY_HERE") // .GET() // .build(); // // try { // HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); // System.out.println(response.body()); // } catch (IOException | InterruptedException e) { // e.printStackTrace(); // } ``` -------------------------------- ### Create End User - Curl Example Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Chatbots Example of how to create an end user using a curl command, demonstrating the HTTP method and endpoint. ```curl curl -X POST https://api.dixa.io/v1/endusers \ -H "Content-Type: application/json" \ -d '{ "displayName": "Alice Brown", "email": "alice@brown.com", "phoneNumber": "+551155256325", "additionalEmails": [ "alice@secondary.email" ], "additionalPhoneNumbers": [ "+5566778899" ], "firstName": "Alice", "lastName": "Brown", "middleNames": [ ], "avatarUrl": "http://avatar.url", "externalId": "#12345678" }' ``` -------------------------------- ### Get Conversation Messages (JavaScript) Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Messages Retrieves conversation messages using JavaScript. This example demonstrates making a GET request to the Dixa API endpoint. ```javascript // JavaScript example would go here, making a fetch or similar request to the API endpoint. ``` -------------------------------- ### Create Dixa User (Go) Source: https://docs.dixa.io/openapi/integrations-api/tag/Users Example of creating a Dixa user using Go. This snippet shows how to build the JSON request body and send a POST request to the Dixa API. ```go package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { userPayload := map[string]string{ "name": "string", "email": "string", "phone_number": "string" } payloadBytes, err := json.Marshal(userPayload) if err != nil { fmt.Println("Error marshaling JSON:", err) return } req, err := http.NewRequest("POST", "https://docs.dixa.io/v1/users", bytes.NewBuffer(payloadBytes)) if err != nil { fmt.Println("Error creating request:", err) return } req.Header.Set("Content-Type", "application/json") req.Header.Set("Authorization", "YOUR_API_KEY_HERE") client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } defer resp.Body.Close() // Process response... fmt.Println("Status Code:", resp.StatusCode) } ``` -------------------------------- ### Create End User - Ruby Example Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Chatbots Ruby code snippet for creating an end user using the Net::HTTP library, demonstrating how to send a POST request with a JSON body. ```ruby require 'net/http' require 'uri' require 'json' uri = URI.parse("https://api.dixa.io/v1/endusers") request = Net::HTTP::Post.new(uri.request_uri) request.content_type = 'application/json' payload = { "displayName" => "Alice Brown", "email" => "alice@brown.com", "phoneNumber" => "+551155256325", "additionalEmails" => ["alice@secondary.email"], "additionalPhoneNumbers" => ["+5566778899"], "firstName" => "Alice", "lastName" => "Brown", "middleNames" => [], "avatarUrl" => "http://avatar.url", "externalId" => "#12345678" } request.body = payload.to_json response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') do |http| http.request(request) end puts response.body ``` -------------------------------- ### Follow Up Conversation - Go Example Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Chatbots Go code snippet for following up on a conversation using the net/http package, demonstrating a PUT request with a JSON body. ```go package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { url := "https://api.dixa.io/v1/conversations/{conversationId}/followup" payload := map[string]interface{} { "timestamp": "2025-01-08T08:31:25Z", "userId": "5a556159-9c21-4f3e-a44f-d323deb80d16" } jsonPayload, _ := json.Marshal(payload) req, _ := http.NewRequest("PUT", url, bytes.NewBuffer(jsonPayload)) req.Header.Set("Content-Type", "application/json") client := &http.Client{} res, _ := client.Do(req) defer res.Body.Close() if res.StatusCode == http.StatusNoContent { fmt.Println("Conversation followed up successfully") } else { fmt.Printf("Failed to follow up conversation: %d\n", res.StatusCode) } } ``` -------------------------------- ### Create End User - JavaScript Example Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Chatbots JavaScript code snippet for creating an end user using the fetch API, showing how to send a POST request with a JSON body. ```javascript fetch('https://api.dixa.io/v1/endusers', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ "displayName": "Alice Brown", "email": "alice@brown.com", "phoneNumber": "+551155256325", "additionalEmails": [ "alice@secondary.email" ], "additionalPhoneNumbers": [ "+5566778899" ], "firstName": "Alice", "lastName": "Brown", "middleNames": [ ], "avatarUrl": "http://avatar.url", "externalId": "#12345678" }) }) .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### Get Agent Teams (PHP) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Agents Example of how to fetch agent teams using PHP, likely involving an HTTP GET request to the Dixa API. -------------------------------- ### Get Agent Teams (Python) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Agents Example of how to fetch agent teams using Python, likely involving an HTTP GET request to the Dixa API. -------------------------------- ### Create Agents in Bulk (Go) Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Agents Go language example for bulk agent creation. This code shows how to send a POST request to the Dixa API with the agent data payload. ```go package main import ( "bytes" "fmt" "io/ioutil" "net/http" ) func main() { url := "https://dev.dixa.io/v1/agents/bulk" payload := []byte(`{ "data": [ { "displayName": "Alice Brown", "email": "alice@brown.com", "phoneNumber": "+551155256325", "additionalEmails": [], "additionalPhoneNumbers": [], "firstName": "Alice", "lastName": "Brown", "middleNames": [], "avatarUrl": "http://avatar.url" } ] }`) ``` -------------------------------- ### Get Agent Teams (JavaScript) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Agents Example of how to fetch agent teams using JavaScript, likely involving an HTTP GET request to the Dixa API. -------------------------------- ### Create End User - Python Example Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Chatbots Python code snippet for creating an end user using the requests library, demonstrating how to make a POST request with JSON data. ```python import requests url = "https://api.dixa.io/v1/endusers" headers = { "Content-Type": "application/json" } payload = { "displayName": "Alice Brown", "email": "alice@brown.com", "phoneNumber": "+551155256325", "additionalEmails": [ "alice@secondary.email" ], "additionalPhoneNumbers": [ "+5566778899" ], "firstName": "Alice", "lastName": "Brown", "middleNames": [ ], "avatarUrl": "http://avatar.url", "externalId": "#12345678" } response = requests.post(url, headers=headers, json=payload) print(response.json()) ``` -------------------------------- ### Get Conversation Messages (Java) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Messages Fetches conversation messages using Java. This example demonstrates using the OkHttp client to perform the GET request. ```java import okhttp3.*; import java.io.IOException; public class DixaApiClient { public static void main(String[] args) { OkHttpClient client = new OkHttpClient(); String url = "https://dev.dixa.io/beta/conversations/{conversationId}/messages"; String apiKey = "YOUR_API_KEY_HERE"; Request request = new Request.Builder() .url(url) .header("Authorization", apiKey) .header("Content-Type", "application/json") .get() .build(); try (Response response = client.newCall(request).execute()) { if (response.isSuccessful()) { System.out.println(response.body().string()); } else { System.out.println("Error: " + response.code() + ", " + response.message()); } } catch (IOException e) { e.printStackTrace(); } } } ``` -------------------------------- ### Create Agents in Bulk (JavaScript) Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Agents Demonstrates creating agents in bulk using JavaScript. This example shows how to make a POST request to the Dixa API with the agent data. ```javascript const agentsData = { "data": [ { "displayName": "Alice Brown", "email": "alice@brown.com", "phoneNumber": "+551155256325", "additionalEmails": [], "additionalPhoneNumbers": [], "firstName": "Alice", "lastName": "Brown", "middleNames": [], "avatarUrl": "http://avatar.url" } ] }; fetch('https://dev.dixa.io/v1/agents/bulk', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'YOUR_API_KEY_HERE' }, body: JSON.stringify(agentsData) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Get Conversation Messages (JavaScript) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Messages Retrieves conversation messages using JavaScript. This example demonstrates making a GET request to the Dixa API endpoint. ```javascript fetch('https://dev.dixa.io/beta/conversations/{conversationId}/messages', { method: 'GET', headers: { 'Authorization': 'YOUR_API_KEY_HERE', 'Content-Type': 'application/json' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Create Dixa User (Java) Source: https://docs.dixa.io/openapi/integrations-api/tag/Users Example of creating a Dixa user using Java. This snippet demonstrates how to structure the request body and make a POST request to the Dixa API, typically using a library like Apache HttpClient or OkHttp. ```java import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; // ... inside a method ... CloseableHttpClient client = HttpClients.createDefault(); HttpPost httpPost = new HttpPost("https://docs.dixa.io/v1/users"); String jsonPayload = "{\"name\": \"string\", \"email\": \"string\", \"phone_number\": \"string\"}"; StringEntity entity = new StringEntity(jsonPayload); httpPost.setEntity(entity); httpPost.setHeader("Content-Type", "application/json"); httpPost.setHeader("Authorization", "YOUR_API_KEY_HERE"); // CloseableHttpResponse response = client.execute(httpPost); // System.out.println(EntityUtils.toString(response.getEntity())); // response.close(); // client.close(); ``` -------------------------------- ### Get Conversation Messages (Ruby) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Messages Fetches conversation messages using Ruby. This example demonstrates making an HTTP GET request with the required authorization header. ```ruby require 'net/http' require 'uri' uri = URI.parse('https://dev.dixa.io/beta/conversations/{conversationId}/messages') api_key = 'YOUR_API_KEY_HERE' http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Get.new(uri.request_uri) request['Authorization'] = api_key request['Content-Type'] = 'application/json' response = http.request(request) puts response.body ``` -------------------------------- ### Create Dixa User (PHP) Source: https://docs.dixa.io/openapi/integrations-api/tag/Users Example of creating a Dixa user using PHP. This snippet illustrates how to prepare the JSON payload and send a POST request to the Dixa API. ```php $userPayload = [ 'name' => 'string', 'email' => 'string', 'phone_number' => 'string' ]; $headers = [ 'Content-Type: application/json', 'Authorization: YOUR_API_KEY_HERE' ]; $ch = curl_init('https://docs.dixa.io/v1/users'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userPayload)); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Curl error: ' . curl_error($ch); } curl_close($ch); echo $response; ``` -------------------------------- ### Get Conversation Messages (PHP) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Messages Retrieves conversation messages via a PHP script. This example uses cURL to make the GET request to the Dixa API. ```php ``` -------------------------------- ### Create End User - Java Example Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Chatbots Java code snippet for creating an end user using HttpURLConnection, demonstrating how to send a POST request with a JSON body. ```java import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; // ... inside a method ... URL url = new URL("https://api.dixa.io/v1/endusers"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/json"); connection.setDoOutput(true); String jsonPayload = "{\"displayName\": \"Alice Brown\", \"email\": \"alice@brown.com\", \"phoneNumber\": \"+551155256325\", \"additionalEmails\": [ \"alice@secondary.email\" ], \"additionalPhoneNumbers\": [ \"+5566778899\" ], \"firstName\": \"Alice\", \"lastName\": \"Brown\", \"middleNames\": [ ], \"avatarUrl\": \"http://avatar.url\", \"externalId\": \"#12345678\" }"; try (OutputStream os = connection.getOutputStream()) { byte[] input = jsonPayload.getBytes("UTF-8"); os.write(input, 0, input.length); } int responseCode = connection.getResponseCode(); // Handle response... ``` -------------------------------- ### Create Conversation Rating Offer (Go) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Chatbots Go language example for creating a conversation rating offer. It shows how to construct a POST request with a JSON payload. ```go package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" ) func main() { payload := map[string]string{ "userId": "b0323b42-c428-4afa-970e-20bf5bdeeec4", "agentId": "eeb3bbe5-0355-4ac1-8af5-20d42a3db24b", "ratingType": "Csat", "offeredAt": "2024-03-11T16:39:30Z" } jsonPayload, _ := json.Marshal(payload) resp, err := http.Post("https://api.dixa.io/beta/conversations/{conversationId}/ratings/offer", "application/json", bytes.NewBuffer(jsonPayload)) if err != nil { fmt.Printf("Error: %s\n", err) return } defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) fmt.Println(string(body)) } ``` -------------------------------- ### Create Agents in Bulk (Java) Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Agents Java code example for creating agents in bulk. This illustrates making a POST request to the Dixa API with the necessary agent data. ```java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class CreateAgents { public static void main(String[] args) throws Exception { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://dev.dixa.io/v1/agents/bulk")) .header("Content-Type", "application/json") .header("Authorization", "YOUR_API_KEY_HERE") .POST(HttpRequest.BodyPublishers.ofString( "{\"data\": [{\"displayName\": \"Alice Brown\", \"email\": \"alice@brown.com\", \"phoneNumber\": \"+551155256325\", \"additionalEmails\": [], \"additionalPhoneNumbers\": [], \"firstName\": \"Alice\", \"lastName\": \"Brown\", \"middleNames\": [], \"avatarUrl\": \"http://avatar.url\"}]}" )) .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } ``` -------------------------------- ### Get Analytics Records (Ruby) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Analytics Example of how to fetch analytics records using Ruby. This code demonstrates making an HTTP GET request with authentication to the Dixa API. ```Ruby # Ruby example would go here, demonstrating Net::HTTP or Faraday ``` -------------------------------- ### Create Dixa User (Python) Source: https://docs.dixa.io/openapi/integrations-api/tag/Users Example of creating a Dixa user using Python. This snippet shows how to construct the request body and make a POST request to the Dixa API. ```python import requests user_payload = { "name": "string", "email": "string", "phone_number": "string" } headers = { 'Content-Type': 'application/json', 'Authorization': 'YOUR_API_KEY_HERE' } response = requests.post('https://docs.dixa.io/v1/users', json=user_payload, headers=headers) print(response.json()) ``` -------------------------------- ### Follow Up Conversation - Ruby Example Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Chatbots Ruby code snippet for following up on a conversation using the Net::HTTP library, demonstrating a PUT request with a JSON body. ```ruby require 'net/http' require 'uri' require 'json' uri = URI.parse("https://api.dixa.io/v1/conversations/{conversationId}/followup") request = Net::HTTP::Put.new(uri.request_uri) request.content_type = 'application/json' payload = { "timestamp" => "2025-01-08T08:31:25Z", "userId" => "5a556159-9c21-4f3e-a44f-d323deb80d16" } request.body = payload.to_json response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') do |http| http.request(request) end if response.code == '204' puts "Conversation followed up successfully" else puts "Failed to follow up conversation. Status code: #{response.code}" end ``` -------------------------------- ### Get Analytics Records (Java) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Analytics Example of how to fetch analytics records using Java. This code demonstrates making an authenticated HTTP GET request to the Dixa API. ```Java // Java example would go here, demonstrating HttpURLConnection or HttpClient ``` -------------------------------- ### Get Analytics Records (PHP) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Analytics Example of how to fetch analytics records using PHP. This snippet illustrates making an HTTP GET request with necessary headers and parameters. ```PHP // PHP example would go here, demonstrating cURL or file_get_contents ``` -------------------------------- ### Create Agent - Python Request Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Agents Illustrates creating a single agent via a Python script using the `requests` library. It demonstrates setting up the API endpoint, headers, and sending the agent data as JSON. ```python import requests url = "https://api.dixa.io/v1/agents" headers = { "Authorization": "ApiKey YOUR_API_KEY", "Content-Type": "application/json" } data = { "displayName": "Alice Brown", "email": "alice@brown.com", "phoneNumber": "+551155256325", "firstName": "Alice", "lastName": "Brown" } response = requests.post(url, headers=headers, json=data) print(response.json()) ``` -------------------------------- ### Get Analytics Records (Python) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Analytics Example of how to fetch analytics records using Python. This code snippet shows how to make an authenticated GET request to the Dixa API. ```Python # Python example would go here, demonstrating requests library or similar ``` -------------------------------- ### Get Message Export (JavaScript) Source: https://docs.dixa.io/openapi/exports-api/paths/~1v1~1message_export/get This JavaScript example shows how to make a GET request to the Dixa Exports API to retrieve message data. It includes setting the Authorization header with a Bearer token and specifying date filters. ```javascript fetch('https://exports.dixa.io/v1/message_export?created_after=2019-08-24&created_before=2019-08-24', { method: 'GET', headers: { 'Authorization': 'Bearer ', 'Content-Type': 'application/json' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Create Dixa User (JavaScript) Source: https://docs.dixa.io/openapi/integrations-api/tag/Users Example of creating a Dixa user using JavaScript. This snippet demonstrates how to structure the request payload and send it to the Dixa API. ```javascript const userPayload = { "name": "string", "email": "string", "phone_number": "string" }; // Example using fetch API (replace with your actual API endpoint and auth) fetch('https://docs.dixa.io/v1/users', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'YOUR_API_KEY_HERE' }, body: JSON.stringify(userPayload) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Get Filter Values (Go) Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Analytics Example of how to fetch filter values using Go, demonstrating an API call to the Dixa analytics endpoint. ```go // Go example for fetching filter values would go here. ``` -------------------------------- ### Get Conversation Notes using Go Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Internal-Notes A Go language example for accessing conversation notes through the Dixa API. This snippet demonstrates making an HTTP GET request. ```go // Go example would go here, likely using the 'net/http' package. // Example structure: /* package main import ( "fmt" "io/ioutil" "net/http" ) func main() { client := &http.Client{} req, err := http.NewRequest("GET", "https://dev.dixa.io/v1/conversations/{conversationId}/notes", nil) if err != nil { fmt.Println("Error creating request:", err) return } req.Header.Add("Authorization", "YOUR_API_KEY_HERE") req.Header.Add("Content-Type", "application/json") resp, err := client.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } fmt.Println(string(body)) } */ ``` -------------------------------- ### Get Metric Data (curl) Source: https://docs.dixa.io/openapi/dixa-api/beta/tag/Analytics Example curl command to get metric data. This demonstrates how to send a POST request with a JSON payload to the Dixa API for analytics data. ```curl curl -i -X POST \ 'https://dev.dixa.io/beta/analytics/metrics' \ -H 'Content-Type: application/json' \ -H 'Authorization: YOUR_API_KEY_HERE' \ -d '{ "id": "closed_conversations", "periodFilter": { "value": { "_type": "PreviousWeek" }, "_type": "Preset" }, "filters": [ { "attribute": "channel", "values": [ "email" ] } ], "aggregations": [ "Count" ], "timezone": "Europe/Copenhagen" }' ``` -------------------------------- ### Create End User - PHP Example Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Chatbots PHP code snippet for creating an end user using cURL, showing how to send a POST request with a JSON payload. ```php 'Alice Brown', 'email' => 'alice@brown.com', 'phoneNumber' => '+551155256325', 'additionalEmails' => array('alice@secondary.email'), 'additionalPhoneNumbers' => array('+5566778899'), 'firstName' => 'Alice', 'lastName' => 'Brown', 'middleNames' => array(), 'avatarUrl' => 'http://avatar.url', 'externalId' => '#12345678' ); $options = array( 'http' => array( 'header' => "Content-type: application/json\r\n", 'method' => 'POST', 'content' => json_encode($data) ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); var_dump($result); ?> ``` -------------------------------- ### Get Message Export (PHP) Source: https://docs.dixa.io/openapi/exports-api/paths/~1v1~1message_export/get This PHP code provides an example of fetching message exports from the Dixa API. It utilizes cURL to send a GET request, including the necessary Authorization header and query parameters for date filtering. ```php '; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $token, 'Content-Type: application/json' )); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } else { echo $response; } c_close($ch); ?> ``` -------------------------------- ### Create Conversation Response (Go) Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Chatbots Example response for creating a conversation, returning the ID of the newly created conversation. ```Go { "data": { "id": 100 } } ``` -------------------------------- ### Follow Up Conversation - JavaScript Example Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Chatbots JavaScript code snippet for following up on a conversation using the fetch API, demonstrating a PUT request with a JSON body. ```javascript fetch('https://api.dixa.io/v1/conversations/{conversationId}/followup', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ "timestamp": "2025-01-08T08:31:25Z", "userId": "5a556159-9c21-4f3e-a44f-d323deb80d16" }) }) .then(response => { if (response.ok) { console.log('Conversation followed up successfully'); } else { console.error('Failed to follow up conversation'); } }); ``` -------------------------------- ### Get Conversation Messages (JSON Response Example) Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Conversations Example JSON response structure for conversation messages, illustrating different message attributes like email content, attachments, and direction. ```json { "data": [ { "id": "11b95893-0514-4606-a5d8-1880172b3a55", "authorId": "41646d42-edc0-493e-ac7b-814d9ff40a2e", "externalId": "13244", "createdAt": "2021-12-01T12:46:36.581Z[GMT]", "attributes": { "emailContent": { "content": { "value": "Hello, this is a regular email content", "_type": "Text" }, "_type": "Regular" }, "from": { "email": "some-help@email.dixa.io", "name": "Help" }, "to": [ { "email": "someone@somecompany.com", "name": "Some One" } ], "cc": [], "bcc": [], "isAutoReply": false, "inlineImages": [], "attachments": [ { "url": "https://files.dixa.io/private/something/attachment/attachment-1", "prettyName": "Picture" } ], "direction": "Outbound", "originalContentUrl": { "url": "https://files.dixa.io/private/something/email_original_data/a1b2c3d4" }, "_type": "EmailAttributes" } }, { "id": "12c95893-0514-4606-a5d8-1880172b3a56", "authorId": "41646d42-edc0-493e-ac7b-814d9ff40a2e", "externalId": "13245", "createdAt": "2021-12-01T12:47:36.581Z[GMT]", "attributes": { "emailContent": { "file": { "url": "https://files.dixa.io/private/something/email_stripped_content/large-email-content", "prettyName": "Large Email Content" }, "_type": "TooLarge" }, "from": { "email": "some-help@email.dixa.io", "name": "Help" }, "to": [ { "email": "someone@somecompany.com", "name": "Some One" } ], "cc": [ { "email": "manager@somecompany.com", "name": "Manager" } ], "bcc": [ { "email": "archive@somecompany.com" } ], "isAutoReply": false, "inlineImages": [], "attachments": [ { "url": "https://files.dixa.io/private/something/attachment/attachment-2", "prettyName": "Large Document" }, { "url": "https://files.dixa.io/private/something/attachment/attachment-3", "prettyName": "Spreadsheet" } ], "direction": "Inbound", "originalContentUrl": { "url": "https://files.dixa.io/private/something/email_original_data/b2c3d4e5" }, "_type": "EmailAttributes" } } ] } ``` -------------------------------- ### Get Linked Conversations (Python) Source: https://docs.dixa.io/openapi/dixa-api/v1/tag/Conversations This snippet provides a Python example for retrieving linked conversations from the Dixa API. It uses the 'requests' library to make a GET request with the necessary authentication. ```python import requests url = 'https://dev.dixa.io/v1/conversations/{conversationId}/linked' headers = { 'Authorization': 'YOUR_API_KEY_HERE' } response = requests.get(url, headers=headers) if response.status_code == 200: print(response.json()) else: print(f'Error: {response.status_code}') ```