Overview
Your app can start and continue conversations in the inbox of workspace members, where they also talk with Twenty’s assistant. A message can end on a question, a form or a change to approve, which the member answers from the chat before the conversation continues with the assistant. The inbox helpers are exported from bothtwenty-sdk/logic-function and twenty-sdk/front-component, so a scheduled run and a button in your app post the same way.
Sending a message
sendInboxMessage() posts a message from your app in the chats of one or more workspace members and returns the conversation’s threadId.
src/logic-functions/notify-first-recording.ts
workspaceMemberIdslists the members who receive the conversation, at least one. The first member of a new conversation owns it, and the others follow it as participants. A later send under the same key that lists new members adds them; members it leaves out keep the conversation.threadKeypicks the conversation for this app, shared by every member it is sent to. A new key starts a conversation titledtitle; a key you used before adds the message to that conversation.idempotencyKeyidentifies the message within the conversation. Sending again with the same keys writes nothing new, so retries and concurrent runs never duplicate a message.textis markdown, and can carry mentions and record references. A member it mentions is notified, even when they are not inworkspaceMemberIds.toolCall(optional) ends the message on one of:- a call the member answers, which pauses the conversation:
ask_question(one multiple-choice question),request_form(fields to fill in) orpropose_tool_call(a call to approve). Itsinputtakes thetoolName, theargumentsyou would call the tool with and a one-sentencesummary. The tool must be one your app’s default role could run itself, such ascreate_one_personorupdate_one_opportunity(with the recordid); an email (send_emailordraft_email, withrecipients,subjectand abodyin HTML) needs no permission of your app. The member reviews the call in the same card as a call the assistant proposes, edits it if they want, and the approved call runs with their own access; - one of your app’s own tools, by
logicFunctionUniversalIdentifier, rendered by its front component with theinputandoutputyou pass. It does not pause the conversation.
- a call the member answers, which pauses the conversation:
- Only one call the member answers can wait in a conversation at a time: sending another before they answer fails with
THREAD_AWAITING_ANSWER. Plain messages and app tool calls are still accepted. - Only the member who owns a conversation can delete it, and a deleted conversation is gone for every member: it is not recreated, and nothing is added to it. The other members can unsubscribe to take it out of their own inbox.
- Every member must have the
AIpermission, and the call fails without writing the message when one of them cannot have the conversation. Your app’s default role must grantSystemPermissionFlag.AI.
Who sends the message
A message is always written by your app, whatever triggered the call. The call itself runs like the default API clients:- In a logic function, it acts as the person who triggered the run, or as your application when nobody did, such as on a cron schedule.
- In a front component, it acts as the member looking at the page. When the token has expired, the call refreshes it once through Twenty and retries.
AI permission as well, like every recipient.
To post from a front component, import the same helpers from twenty-sdk/front-component. Posting to the inbox shows how to open the conversation afterwards.
Mentions and record references
The inbox renders reference tokens intext as chips. Write them with these helpers rather than by hand:
src/logic-functions/flag-idle-deal.ts
inboxMention({ workspaceMemberId })writes a mention of a workspace member, andinboxReferenceRecord({ objectNameSingular, recordId })a chip that links to any record.- Both read the label the chip shows, as the composer does: the member’s full name, or their email when the name is empty, and the record’s label identifier, such as a company name. Brackets become parentheses and line breaks become spaces, so the chip always renders.
- They read with the same access as the rest of the call, so that access needs to reach the member or record. A record reference makes two requests, one for the object’s label field and one for the record.
- A mentioned member gets the conversation in their inbox, unread, with a mention to resolve, as when a teammate mentions them. They don’t need to be in
workspaceMemberIds, and the member who owns the conversation can be mentioned too. A mentioned member who cannot have the conversation, for example without theAIpermission, is skipped and the message is still sent. - Mentions notify once, when the message is first written: sending it again with the same keys notifies no one, even with a different
text, and a newidempotencyKeymentions again. - Only a complete mention notifies. One in inline code or a code block, one whose brackets are escaped (
\[\[), and a typed@namenotify no one. A record reference never notifies, and never shares the record. INBOX_ASSISTANT_MENTIONwrites the composer’s canonical assistant reference. The inbox displays it as@Ada; its stable identity is separate from its label. This reference alone does not request an assistant reply from an application message.
Attaching records to a conversation
attachRecordToInboxThread() links a conversation to a record, and detachRecordFromInboxThread() removes the link.
src/logic-functions/file-call-recap.ts
- Both take the conversation’s
threadIdand the record asobjectNameSingularandrecordId. A conversation can be linked to people, companies, opportunities and custom object records. - Both are idempotent: attaching a record twice keeps a single link, and detaching a record that is not attached changes nothing.
- The call runs with the same access as sending a message, which needs the
AIpermission. A member must be able to edit the conversation, and your application can act on a conversation it wrote in itself or one its default role was granted; otherwise the call fails withTHREAD_NOT_FOUND. - The record must be readable with that access, or the call fails with
RECORD_NOT_FOUND.
Archiving a conversation
archiveInboxThread() archives a conversation your application wrote, for the members you name, as if each of them had archived it from their inbox. Use it when the work behind a message got done somewhere else: the email you proposed was sent from Gmail, the meeting you asked about was approved in the calendar.
src/logic-functions/on-email-sent-archive-thread.ts
- Only your application can call it, on a conversation it wrote in itself or one its default role was granted; otherwise the call fails with
THREAD_NOT_FOUND. Members archive from their own inbox. - Every member you name must be able to read the conversation. If one cannot, the call fails with
THREAD_NOT_FOUNDand archives it for nobody. - A new message in the conversation brings it back to the inbox, as it does after a member archives it.
- A member who stopped following the conversation is skipped, so it stays out of their inbox.
workspaceMemberIds to mark a conversation done in its channel instead, as a member does from the channel view. Members’ own inboxes are left as they are, and a conversation that is in no channel fails with CHAT_THREAD_NOT_IN_CHANNEL.