Forms, Fields and Results
Forms are containers of fields that may be added to the conversation by agents or automations. Forms are defined per-organization, and assigned to the various conversation categories.
See the Categories and Forms chapter of the Provisioning Guide for more information.
Forms can be added to or removed from a conversation for the currently active category, and processed into the array of results for the conversation. All form-related actions are best performed by posting messages into the conversation.
Activate a Form
You can programmatically activate a form for a conversation by POSTing a form type message to the conversation. The text of the message can be anything but is probably the form name, provided it is prefixed by a plus-sign (+) Example:
Request: POST /v2/conversations/590bd49f458b716046347f47/messages
{
"type": "form",
"text": "+Proefrit",
"meta": {
"form": "590c76bdde1b762f2113e81c",
"categoryIndex": 1
}
}
This will add the form to the second category for the conversation. The meta properties must specify at least a form ID, and an optional categoryIndex (indices, the category slots for the organization, range from 0-9) or a category name. The category the form is added for defaults to the currently activate category for the conversation.
The form must be assigned to the category in the Organization's organization.categories settings.
Remove a form
Likewise, a currently active form can be removed from a category by prefixing the message text with a minus-sign (-). In the example below, the form will be removed from the currently active category (since categoryIndex or category are not specified as a meta property).
Request: POST /v2/conversations/590bd49f458b716046347f47/messages
{
"type": "form",
"text": "-Proefrit",
"meta": {
"form": "590c76bdde1b762f2113e81c"
}
}
Set a Field value
In its essence, a form instance inside a conversation is just a bag of field values (key/value pairs). To set a field using a message, optionally prefix the message text with a dot (.) and specify the value after the first whitespace:
Request: POST /v2/conversations/590bd49f458b716046347f47/messages
{
"type": "field",
"text": ".rating 8.3",
"meta": {
"field": "590c76bdde1b762f2113e81d",
"form": "590c76bdde1b762f2113e81c"
}
}
Meta properties should at least specify a field ID and a form ID. Like we've seen before, since no meta.categoryIndex or meta.category is specified, the currently active category is assumed.
To clear a field value that was set earlier, just omit the value:
Request: POST /v2/conversations/590bd49f458b716046347f47/messages
{
"type": "field",
"text": ".rating",
"meta": {
"field": "590c76bdde1b762f2113e81d",
"form": "590c76bdde1b762f2113e81c"
}
}
The form now no longer has a value for the rating field.
Contact Profile Fields
In addition to forms, any fields in the contact profile may be set using a field-type message.
Request: POST /v2/conversations/590bd49f458b716046347f47/messages
{
"type": "field",
"text": ".givenName John"
}
Here are the available fields:
Field | Description |
---|---|
givenName | First Name |
additionalName | Middle Name |
familyName | Last Name |
initials | Initials |
gender | Gender |
honorificPrefix | Prefix |
honorificSuffix | Suffix |
worksFor | Company |
telephone | Phone |
streetAddress | Street |
streetNumber | Number |
postalCode | Zip Code |
addressLocality | City |
addressRegion | Region |
addressCountry | Country |
When updating a profile field, no meta data is required.
Listing Forms
While processing webhooks or querying the API, your application has full access to all category form instances that were added to conversation.
Request: GET /v2/conversations/590bd49f458b716046347f47
Response: 200 OK
{
"id": "590bd49f458b716046347f47",
"category": "Used Car",
"categoryIndex": 1,
"forms": [
{
"name": "Test Drive",
"form": "590c76bdde1b762f2113e81c",
"type": "topic",
"state": "completed",
"labels": [
"isLead"
],
"category": "Used Car",
"categoryIndex": 1,
"values": {
"rating": "8.3"
}
}
],
... other conversation attributes ...
}
Form state
Each form instance can be in state active or completed when all required form fields have corresponding values specified. Whereas an active form instance is considered being worked on, a completed form is ready to be processed into a results message.
Form labels
A form definition can have form labels specified: custom tags that are recorded in conversation.forms conversation.results and type: results messages. These labels are recorded throughout the result lifecycle for reporting purposes.
Processing Completed Forms
Once a form is completed, the /process command message will process all completed form instances for all categories. To process one specific completed form in the conversation, specify the form ID as meta.form
Request: POST /v2/conversations/590bd49f458b716046347f47/messages
{
"type": "command",
"text": "/process",
"meta": {
"form": "590c76bdde1b762f2113e81c"
}
}
Aliases: /send /dispatch /results
This command accomplishes the following for each completed form:
- The form instance is removed from the conversation.forms list, and pointer to the results message is added to the conversation.results list;
- A results-type message for the form values is added to the conversation;
- If the form definition has form.notifyEmails specified, email notifications are sent.
Conversation Results
As a result of executing the /process command, all completed forms are removed from the conversation's active forms list. A results-type message is added to the conversation, and the message ID and form are added to the conversation's results list. If you retrieve the conversation you'll see the changes:
Request: GET /v2/conversations/590bd49f458b716046347f47 Response: 200 OK
{
"id": "590bd49f458b716046347f47",
"category": "Used Car",
"categoryIndex": 1,
"forms": [],
"results": [
{
"name": "Test Drive",
"form": "590c76bdde1b762f2113e81c",
"labels": [
"isLead"
],
"category": "Used Car",
"categoryIndex": 1,
"message": "59ac3cf257615f431a1a0ec9"
}
],
... other conversation attributes ...
}
Results Messages
Webhook processors and API users have easy access to all processed forms by listening on webhooks or retrieving messages through the API. A results-type message serves as a container for all completed forms and field values that were processed as a result of the /process command.
For example, to fetch all results messages for a particular conversation in reverse order by creation date:
Request: GET /v2/conversations/590bd49f458b716046347f47/messages?type=results&sort=-createdAt
Response: 200 OK
[
{
"organization": "590bcf50458b716046347f36",
"conversation": "590bd49f458b716046347f47",
"type": "results",
"contact": "59ac346e92da1c3b2a86ecce",
"text": "/send success - forms processed",
"actions": [],
"results": [
{
"name": "Test Drive",
"form": "590c76bdde1b762f2113e81c",
"state": "completed",
"type": "topic",
"labels": [
"isLead"
],
"category": "Used Car",
"categoryIndex": 1,
"values": {
"rating": "8.3"
}
}
],
"createdAt": "2017-09-03T17:33:38.078Z",
"updatedAt": "2017-09-03T17:33:38.078Z",
"id": "59ac3cf257615f431a1a0ec9"
}
]
Extend your queries with additional filters and population as outlined in the chapter Fetching Resources. For example, to fetch all results messages across all organizations for a specific day, with contact details expanded:
Request: GET /v2/messages?createdAt=>2017-09-03,<=2017-09-04&type=results&populate=contact
Response: 200 OK
[
{
"id": "59ac405787709d4566589dd9",
"organization": "590bcf50458b716046347f36",
"conversation": "590bd49f458b716046347f47",
"type": "results",
"contact": {
"id": "59ac346e92da1c3b2a86ecce",
"profile": {
"additionalName": null,
"email": "alice@example.com",
"familyName": "Johnson",
"givenName": "Alice",
"initials": null,
"name": "Alice Johnson",
"address": {}
},
... other contact fields ...
},
"text": "/send success - forms processed",
"actions": [],
"results": [
{
"name": "Test Drive",
"form": "590c76bdde1b762f2113e81c",
"state": "completed",
"type": "topic",
"labels": [
"isLead"
],
"category": "Used Car",
"categoryIndex": 1,
"values": {
"rating": "8"
}
}
],
"createdAt": "2017-09-03T17:48:07.332Z",
"updatedAt": "2017-09-03T17:48:07.332Z"
}
]
Please note that field values for contact profile changes are not included in results messages.
Report Messages
Like results-type messages, messages typed report should also contain a "results" array property to store key-value pairs. But while a results message generated by the system when triggered by a /send command, a report message is typically created by a bot or automation for displaying a summary of previous tasks accomplished.
For example, an automation might create the following report message and have it displayed as a card with key-value pairs in a chat application:
Request: POST /v2/conversations/590bd49f458b716046347f47/messages
Response: 201 Created
[
{
"organization": "590bcf50458b716046347f36",
"conversation": "590bd49f458b716046347f47",
"type": "report",
"contact": "59ac346e92da1c3b2a86ecce",
"text": "Performance Review",
"actions": [],
"results": [
{
"name": "Agent Performance",
"values": {
"score": "8.3"
}
}
],
"createdAt": "2017-09-03T17:33:38.078Z",
"updatedAt": "2017-09-03T17:33:38.078Z",
"id": "59ac3cf257615f431a1a0ec9"
}
]
Emails Sent
For each form result that is processed, one or more notification emails will be sent if the corresponding form definition has the notifyEmails property spefified. The resulting email sent to each notification email address will have variables filled into the following template:
From: Web1on1 no-reply@Web1on1.chat To: sales@acme.org
Hello,
A new Conversation Result for {form.name} is available. View the full conversation at:
https://app.web1on1.chat/conversations/590bd49f458b716046347f47#59ac405787709d4566589dd9
Thanks, {organization.displayName}
Standard Forms
The following standard set of forms and results are supported:
ID | Form name |
---|---|
64b317386170235fe4b6f240 | Appointment - Showroom visit |
64b317386170235fe4b6f24c | Appointment - Test drive |
64b317386170235fe4b6f26a | Request for Info - Find / buy car |
64b317386170235fe4b6f298 | Request for Info - Leasing / finance |
64b317386170235fe4b6f277 | Appointment - Workshop |
64400aae0760c8001d967720 | Appointment - Check-in |
65cb634847533a5b5820fcbc | Appointment - Emergency incident |
64b317386170235fe4b6f2a3 | Request for Info - Service |
64b317386170235fe4b6f2b5 | Request for Info - Parts |
64b317386170235fe4b6f2ac | Request for Info - Miscellaneous |
64b317386170235fe4b6f283 | Appointment - Rental |
64b317386170235fe4b6f2b1 | Share Info - Share info |
A full list of available fields can be seen below.
Contact Attributes
The contact attributes are fields sent with every result and not specific for the result itself. They can be set without specifying a meta.form
value.
name | label | type |
---|---|---|
AccountRep | Account Representative | resource-user |
HeaderTargetCar | Target Car | header |
TargetCarVIN | VIN | text |
TargetCarLicensePlate | License plate | text |
TargetCarType | Used or new car? | radio:Used car/New car |
TargetCarBrand | Car Brand | text |
TargetCarModel | Car Model | text |
TargetCarYear | Car Year | text |
MyCarHeader | My Car | header |
MyCarVIN | VIN | text |
MyCarLicensePlate | License plate | text |
MyCarBrand | Car Brand | text |
MyCarModel | Car Model | text |
MyCarYear | Car Year | text |
MyCarMileage | Mileage | number |
MyCarDamage | Damage | number |
MyCarLocation | Service Location | resource-location |
The following forms are dependent on the type of result being made:
SALES FORMS
Appointment - Showroom visit
Form ID: 64b317386170235fe4b6f240
name | label | type |
---|---|---|
QuotationRequest | QuotationRequest | radio:yes/no |
Location* | Location | resource-location |
AppointmentDate* | Date | date |
AppointmentTime* | Time | time |
Remark | Remark | textarea |
Appointment - Test drive
Form ID: 64b317386170235fe4b6f24c
name | label | type |
---|---|---|
Location* | Location | resource-location |
AppointmentDate* | Date | date |
AppointmentTime* | Time | time |
Remark | Remark | textarea |
Request for Info - Find / buy car
Form ID: 64b317386170235fe4b6f26a
name | label | type |
---|---|---|
TradeIn* | Trade In? | radio:yes/no |
QuotationRequest | QuotationRequest | radio:yes/no |
Location* | Location | resource-location |
Remark | Remark | textarea |
Request for Info - Leasing / finance
Form ID: 64b317386170235fe4b6f298
name | label | type |
---|---|---|
LeasingType* | Leasing Type | select:Finance/Private Lease/Financial Lease/Operational Lease |
LeasingDuration* | Duration in months | number |
LeasingMileage* | Kilometers a year | number |
TradeIn* | Trade In? | radio:yes/no |
QuotationRequest | QuotationRequest | radio:yes/no |
Location* | Location | resource-location |
Remark | Remark | textarea |
AFTERSALES FORMS
Appointment - Workshop
Form ID: 64b317386170235fe4b6f277
name | label | type | example |
---|---|---|---|
ServiceType* | Service Type | select:Damage repair/MOT/Tire/Interval/Pre-purchase inspection/Service status/Other | MOT |
Location* | Location | resource-location | 66b3462ac9d7fbc9bd533b0d |
AppointmentDate* | Date | date | 2024-10-15 |
AppointmentTime* | Time | time | 15:30 |
Remark | Remark | textarea | Change oil filter |
Appointment - Check-in
Form ID: 64400aae0760c8001d967720
name | label | type |
---|---|---|
ContactMethodPreference | Contact method preference | select:Call/SMS/WhatsApp |
ContactDetailsCorrect | Correct Contact Details | select:Yes/No |
UpsellScreenwash | Screenwash top-up | select:Yes/No |
UpsellWiperBlade | Wiper blade replacement | select:Yes/No |
RequirementsComments | Requirements comments | text |
GeneralComment | General Comment | text |
Appointment - Emergency incident
Form ID: 65cb634847533a5b5820fcbc
name | label | type |
---|---|---|
EmergencyIncidentType | Emergency incident type | radio:Breakdown/Accident |
ExternalIncidentNumber* | External incident number | text |
Location | Location | resource-location |
ServiceProvider | Service provider | text |
TowingTarget | Towing Target | text |
Caller | Caller | text |
CallbackNumber | Callback number | text |
Request for Info - Service
Form ID: 64b317386170235fe4b6f2a3
name | label | type |
---|---|---|
ServiceType* | Service Type | select:Damage repair/MOT/Tire/Interval/Pre-purchase inspection/Service status/Other |
QuotationRequest | QuotationRequest | radio:yes/no |
Location* | Location | resource-location |
Remark | Remark | textarea |
Request for Info - Parts
Form ID: 64b317386170235fe4b6f2b5
name | label | type |
---|---|---|
Part* | Part | text |
PartsOrder | Parts Order | radio:yes/no |
QuotationRequest | QuotationRequest | radio:yes/no |
Location* | Location | resource-location |
Remark | Remark | textarea |
OTHER FORMS
Request for Info - Miscellaneous
Form ID: 64b317386170235fe4b6f2ac
name | label | type |
---|---|---|
Subject* | Subject | select:Complaint/Job Application/Customer Care Request/Website Feedback/Other |
Location* | Location | resource-location |
Remark | Remark | textarea |
Appointment - Rental
Form ID: 64b317386170235fe4b6f283
name | label | type |
---|---|---|
RentalPickUpDate* | Pick up date | date |
RentalReturnDate* | Return date | date |
QuotationRequest | QuotationRequest | radio:yes/no |
Location* | Location | resource-location |
Remark | Remark | textarea |
Share Info - Share info
Form ID: 64b317386170235fe4b6f2b1
name | label | type |
---|---|---|
Remark* | Remark | textarea |