Smart compose
The Smart Compose endpoints extend the Nylas Messages API. Currently, Smart Compose supports only two methods of getting AI responses: you can either receive them as a REST response in a single JSON blob, or use server-sent events (SSE) to stream the response tokens as Nylas receives them.
If you want to receive responses using the REST method, add the Accept: application/json header. Nylas will return a single JSON blob. If you use this method, you might want to add a "working" indicator to your UI, as response times may vary.
To enable SSE for a request, add the Accept: text/event-stream header.
For more information, see the Smart Compose documentation.
Smart Compose scopes
The table below lists the Smart Compose endpoints and which scopes they require. The table shortens the full scope URI for space reasons, so add the prefix for the provider when requesting scopes.
The ☑️ in each column indicates the most restrictive scope you can request for each provider and still use that API. More permissive scopes appear under the minimum option. If you're already using one of the permissive scopes, you don't need to add the more restrictive scope.
| Endpoint | Google Scopeshttps://www.googleapis.com/auth/... |
Microsoft Scopeshttps://graph.microsoft.com/... |
|---|---|---|
POST /messages/smart-composePOST /messages/<MESSAGE_ID>/smart-compose |
/gmail.readonly ☑️/gmail.modify |
Mail.Read ☑️Mail.ReadWriteMail.ReadWrite.SharedMail.Read.Shared |
For more information about scopes, see Using scopes to request user data.