Using Rest API response trigger to fetch customer info
This is simple use case to demonstrate how you can use Rest API response type to fetch customer info directly from third party service as soon chat started. For optimal performance I would recommend to use Send Rest API Call in the background.
Purpose of our bot is
- Check was username provided
- If username is provided call Rest API trigger to fetch customer information using Rest API trigger.
- Always after fetching information set chat as pending.
For the customer it will be transparent process.
Rest API Server
Here we return JSON and prepend provided nick just to make sure all works as expected.
echo json_encode(
array(
'user_info' => array('name_surname' => 'Remigijus Kiminas' . $_GET['nick'])
)
);
Rest API Definition
Now we can define Rest API Call itself.
Main settings
Output parsing
Trigger
For all that we need only three triggers
Default
This trigger will be executed as soon chat starts. It also executes rest api call only if username is not Visitor. Means it was changed. If you are planning to make checking based on passed attribute, not visible by customer you can do that also.
Fetch information
Here we just call Rest API to fetch customer information.
Set user information
After we detected output we just set fetched information as chat attribute.
You can also set main chat attributes like nick
, email
by choosing command Update main chat attribute
Attribute would be nick
and value would be {content_1}
. More information how to use Update main chat attribute
Output
If you have done everything right you should see in chat additional data.