Pre-call context
The pre-call context endpoint gives an external voice agent what it must know about a customer before a call. It returns the contact, the latest conversation, the recent messages, and a text summary. All values are strings in 1 flat map, so a voice runtime can use each key as a template variable.
The endpoint only reads data. It does not create a contact or a conversation. It takes the same API key as the other developer endpoints. See Quickstart.
Find the customer
Give 1 of these query parameters. If the request has more than 1, the API reads them in this order and ignores the others.
In a query string, a + becomes a space. The API reads a number with a space or with no + as a number with a +. To send the +, you can also encode it as %2B.
Response
The API answers 200 with a flat map of strings:
Contact keys
Conversation keys
Do not send the conversation_id of the response back to the other developer endpoints. It is the internal id. The other developer endpoints take the dashboard number, which is in conversation_display_id. The workflow trigger and the workflow webhook take the internal id. See Workflows.
If the contact has no conversation, the response has no conversation_* keys, and messages is an empty string.
Rules for all keys
- A value that is empty in Hams is an empty string.
- A nested object adds its keys to the name, with an underscore. For example,
social_profiles.facebookbecomescontact_additional_attributes_social_profiles_facebook. - A list becomes 1 string, with a comma and a space between the items.
- An empty object adds no keys. For example, a contact with no custom attributes has no
contact_custom_attributes_*keys.
Messages
messages has 1 line for each message, oldest first. A line starts with user: for a message from the customer and assistant: for a message to the customer. It includes the last 100 messages, up to 40,000 characters. Private notes, activity lines, and failed calls are not in it. A call shows its details and its transcript. A line assistant: <conversation_boundary status="resolved" /> marks the end of an earlier resolved conversation cycle.
Summary
summary is the same context as the other keys, as a Markdown text. It has a # Current Conversation Context part when there is a conversation, and a # Contact Information part. The AI agent of Hams gets the same context in its prompt. You can put it into the prompt of your voice agent as it is.