Skip to main content

createChat

Create a new chat conversation with one or more participants.
await sdk.chats.createChat(options): Promise<ChatResponse>

Parameters

options
object
required
Configuration for creating the chat
addresses
string[]
required
Array of participant addresses (phone numbers or email addresses)
message
string
Initial message to send when creating the chat
method
'apple-script' | 'private-api'
Method to use for creating the chat
service
'iMessage' | 'SMS'
Service to use for the chat (defaults to iMessage)
tempGuid
string
Temporary GUID for the chat
subject
string
Subject line for the chat (group chats only)
effectId
string
Message effect ID for the initial message
attributedBody
Record<string, unknown>
Attributed body data for rich text formatting

Returns

chat
ChatResponse
The newly created chat object
originalROWID
number
Database row ID
guid
string
Unique identifier for the chat
chatIdentifier
string
Chat identifier string
displayName
string
Display name of the chat
style
number
Chat style (0 = individual, 43 = group)
isArchived
boolean
Whether the chat is archived
isFiltered
boolean
Whether the chat is filtered
groupId
string
Group identifier for group chats
participants
HandleResponse[]
Array of participant handles
lastMessage
MessageResponse
Most recent message in the chat
lastAddressedHandle
string | null
Last addressed handle in the chat
properties
object[] | null
Additional chat properties

Example

import { SDK } from '@photon-ai/advanced-imessage-kit';

const sdk = SDK({ serverUrl: 'http://localhost:1234' });

// Create a 1-on-1 chat with initial message
const individualChat = await sdk.chats.createChat({
  addresses: ['+1234567890'],
  message: 'Hey! How are you?'
});

console.log(`Created chat: ${individualChat.guid}`);

// Create a group chat
const groupChat = await sdk.chats.createChat({
  addresses: ['+1234567890', '+0987654321', '[email protected]'],
  message: 'Welcome to the group!',
  subject: 'Weekend Plans'
});

console.log(`Created group: ${groupChat.displayName}`);

// Create chat with SMS service
const smsChat = await sdk.chats.createChat({
  addresses: ['+1234567890'],
  service: 'SMS',
  message: 'Sending via SMS'
});

// Create chat with message effect
const chatWithEffect = await sdk.chats.createChat({
  addresses: ['+1234567890'],
  message: 'Happy Birthday!',
  effectId: 'com.apple.messages.effect.CKConfettiEffect'
});

// Create chat using private API
const privateApiChat = await sdk.chats.createChat({
  addresses: ['+1234567890'],
  message: 'Hello!',
  method: 'private-api'
});

Build docs developers (and LLMs) love