botruntime
API ReferenceChat API

Get Or Create Message

Retrieves the [Message](#schema_message) object for given discriminating tags. If the message does not exist, it will be created. If the message already exists, its tags and payload will be updated with the provided values if they are defined.

POST
/v1/chat/messages/get-or-create

Header Parameters

x-bot-id*string

Bot id

x-integration-id?string

Integration id

x-integration-alias?string

Integration alias

Request Body

application/json

Message data

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

curl -X POST "https://example.com/v1/chat/messages/get-or-create" \  -H "x-bot-id: string" \  -H "Content-Type: application/json" \  -d '{    "userId": "stringstringstringstringstri",    "conversationId": "stringstringstringstringstri",    "type": "string",    "tags": {      "property1": "string",      "property2": "string"    }  }'
{  "message": {    "id": "stringstringstringstringstri",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "type": "string",    "payload": {},    "direction": "incoming",    "userId": "stringstringstringstringstri",    "conversationId": "stringstringstringstringstri",    "tags": {      "property1": "string",      "property2": "string"    },    "origin": "synthetic"  },  "meta": {    "created": true  }}
{  "message": {    "id": "stringstringstringstringstri",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "type": "string",    "payload": {},    "direction": "incoming",    "userId": "stringstringstringstringstri",    "conversationId": "stringstringstringstringstri",    "tags": {      "property1": "string",      "property2": "string"    },    "origin": "synthetic"  },  "meta": {    "created": true  }}