Create message
Send a message within an existing conversation.
Purpose: Facilitates communication within a conversation by allowing authorized users or systems to send messages to the patient, subject to various validation checks based on the origin type, direction, and the current state of the conversation.
Use Case: This action is critical for maintaining real-time engagement with patients, allowing practices to respond dynamically as needed.
Field Descriptions:
-
message: The content of the message to be sent within the conversation. This field is required, cannot be empty, and must be between 1 and 1024 characters.
-
origin_type: Specifies the origin of the message. Available choices are:
SYSTEM_RESPONSIVE: Message sent by the system in response mode.AGENT: Message sent manually by an agent.
-
direction: Defines the direction of the message, indicating if it is inbound or outbound. Available choices are:
INBOUND: Incoming message to the system.OUTBOUND: Outgoing message from the system.
curl --request POST \
--url https://api.prod.peerlogic.com/api/conversations/{id}/message/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"message": "<string>",
"origin_type": "system_responsive",
"direction": "outbound"
}
'import requests
url = "https://api.prod.peerlogic.com/api/conversations/{id}/message/"
payload = {
"message": "<string>",
"origin_type": "system_responsive",
"direction": "outbound"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({message: '<string>', origin_type: 'system_responsive', direction: 'outbound'})
};
fetch('https://api.prod.peerlogic.com/api/conversations/{id}/message/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.prod.peerlogic.com/api/conversations/{id}/message/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'message' => '<string>',
'origin_type' => 'system_responsive',
'direction' => 'outbound'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.prod.peerlogic.com/api/conversations/{id}/message/"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"origin_type\": \"system_responsive\",\n \"direction\": \"outbound\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.prod.peerlogic.com/api/conversations/{id}/message/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"origin_type\": \"system_responsive\",\n \"direction\": \"outbound\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.prod.peerlogic.com/api/conversations/{id}/message/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": \"<string>\",\n \"origin_type\": \"system_responsive\",\n \"direction\": \"outbound\"\n}"
response = http.request(request)
puts response.read_body{
"error": "Aimee is not enabled for this Conversation's practice"
}{
"detail": "'Authorization' header is required"
}{
"message": "No permissions assigned to permit access to this endpoint."
}{
"detail": "No Conversation matches the given query."
}{
"error": "This conversation is not accepting new messages."
}Authorizations
Bearer access token issued by Peerlogic.
Path Parameters
A unique value identifying this conversation.
Body
Response
Message sent successfully.
Was this page helpful?
curl --request POST \
--url https://api.prod.peerlogic.com/api/conversations/{id}/message/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"message": "<string>",
"origin_type": "system_responsive",
"direction": "outbound"
}
'import requests
url = "https://api.prod.peerlogic.com/api/conversations/{id}/message/"
payload = {
"message": "<string>",
"origin_type": "system_responsive",
"direction": "outbound"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({message: '<string>', origin_type: 'system_responsive', direction: 'outbound'})
};
fetch('https://api.prod.peerlogic.com/api/conversations/{id}/message/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.prod.peerlogic.com/api/conversations/{id}/message/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'message' => '<string>',
'origin_type' => 'system_responsive',
'direction' => 'outbound'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.prod.peerlogic.com/api/conversations/{id}/message/"
payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"origin_type\": \"system_responsive\",\n \"direction\": \"outbound\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.prod.peerlogic.com/api/conversations/{id}/message/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"origin_type\": \"system_responsive\",\n \"direction\": \"outbound\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.prod.peerlogic.com/api/conversations/{id}/message/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": \"<string>\",\n \"origin_type\": \"system_responsive\",\n \"direction\": \"outbound\"\n}"
response = http.request(request)
puts response.read_body{
"error": "Aimee is not enabled for this Conversation's practice"
}{
"detail": "'Authorization' header is required"
}{
"message": "No permissions assigned to permit access to this endpoint."
}{
"detail": "No Conversation matches the given query."
}{
"error": "This conversation is not accepting new messages."
}