Contact info
Name, email and phone collected together in one step.
contact_infoName, email and phone collected together in one step.
How it gets answered — extracted from free text by the agent, then re-validated.
Configuration
Fields specific to contact_info. The fields every block has — id, ref, title, required, visibility, media, agentHints, prefillParam, identityField — are documented once.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"buttonLabel": {
"type": "string",
"maxLength": 60
},
"type": {
"type": "string",
"const": "contact_info"
},
"fields": {
"minItems": 1,
"type": "array",
"items": {
"type": "string",
"enum": [
"first_name",
"last_name",
"email",
"phone"
]
}
},
"fieldOptions": {
"type": "object",
"properties": {
"email": {
"type": "object",
"properties": {
"businessOnly": {
"default": false,
"type": "boolean"
},
"allowedDomains": {
"maxItems": 20,
"type": "array",
"items": {
"type": "string"
}
}
}
},
"phone": {
"type": "object",
"properties": {
"countryHint": {
"type": "string",
"minLength": 2,
"maxLength": 2
}
}
}
}
}
},
"required": [
"id",
"ref",
"title",
"type",
"fields"
],
"$defs": {
"__schema0": {
"type": "object",
"properties": {
"op": {
"type": "string",
"enum": [
"and",
"or"
]
},
"conditions": {
"default": [],
"type": "array",
"items": {
"type": "object",
"properties": {
"left": {
"oneOf": [
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "ref"
},
"ref": {
"type": "string",
"pattern": "^[a-z][a-z0-9_]{1,40}$"
}
},
"required": [
"kind",
"ref"
]
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "variable"
},
"name": {
"type": "string",
"pattern": "^[a-z][a-z0-9_]{0,40}$"
}
},
"required": [
"kind",
"name"
]
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "hidden"
},
"name": {
"type": "string",
"pattern": "^[a-zA-Z_][a-zA-Z0-9_.-]{0,60}$"
}
},
"required": [
"kind",
"name"
]
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "literal"
}
},
"required": [
"kind"
]
}
]
},
"op": {
"type": "string",
"enum": [
"eq",
"neq",
"gt",
"gte",
"lt",
"lte",
"contains",
"not_contains",
"starts_with",
"ends_with",
"matches_regex",
"is_empty",
"is_not_empty",
"is_checked",
"is_not_checked",
"includes",
"not_includes",
"ranked_above",
"ranked_below"
]
},
"value": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
},
"required": [
"left",
"op"
]
}
},
"groups": {
"default": [],
"type": "array",
"items": {
"$ref": "#/$defs/__schema0"
}
}
},
"required": [
"op"
]
}
}
}In a generated draft these arrive as config pairs: fields=<first_name|last_name|email|phone>; domains=<acme.com|acme.co.uk> and businessOnly=true hold the email field to the same rules the standalone email block takes; country=<2-letter code> does the same for the phone field.
What you receive
GET /v1/forms/{id} and every "next question" projects blocks through toPublicBlock. For the example above:
{
"id": "blk_contact1",
"ref": "q_contact",
"type": "contact_info",
"title": "Your details",
"required": true,
"imageKey": null,
"media": null,
"fields": [
"first_name",
"email"
]
}What you send
A map of the block's fields to their values.
type Answer = Record<'first_name' | 'last_name' | 'email' | 'phone', string>;curl -X POST https://api.chatform.in/v1/responses/{RESPONSE_ID}/answers \
-H "x-api-key: $CHATFORM_SECRET_KEY" \
-H "content-type: application/json" \
-d '{"ref": "q_contact", "value": {"first_name":" Maya ","email":"maya@northwind.co"}}'What gets stored
The value is normalised before it is saved, so what you read back is not always what you sent.
| You send | Stored | |
|---|---|---|
{"first_name":" Maya ","email":"maya@northwind.co"} | {"first_name":"Maya","email":"maya@northwind.co"} |
Errors
| Code | When | Message |
|---|---|---|
required | an empty answer on a required block | This question needs an answer. |
type | "Maya" | Please fill in the details. |
incomplete | {"first_name":"Maya"} | I still need your email address. |
invalid_email | {"first_name":"Maya","email":"nope"} | That doesn't look like a valid email address. |