visitorId
from the Web SDK or Flutter SDK.
1
Install
2
Create the client
3
Get context before the model call
Call Use the same
turnContext() after adding the latest user message to messages.visitorId for the same visitor. Use the same sessionId for
every turn in one conversation.4
Add the context to your system prompt
eraContext is a plain string. If it is empty, continue with the model call
as usual.Complete example
What to expect
The default mode isasync:
- The first turn normally returns
"". - Later turns return the previous turn’s prepared context.
- Network and API failures return
""instead of breaking your chat.
mode: "sync" if you need context for the current turn and can accept the
extra latency.
Add signed-in identity
If your backend knows the signed-in user, include your stable user ID:email or phone with partnerEndUserId. Never
copy those values directly from untrusted client input.
Next steps
Async and sync modes
Choose when Era prepares context.
Node SDK reference
See every client method and option.