Comment on page
Actions
Actions enable conversations applications to interact with the outside world. The inputs they accept are attributes and they provide their response in terms of attributes as well.
The webhook action allows you to send and receive attributes to/from a webhook URL.
{
"input_data": {
"attributes": {
"[attribute name]": "[attribute value]"
}
}
}
{
"successful": true,
"output_data": {
"attributes": {
"full_name": "John Smith"
}
}
}
{
"successful": false,
"errors": [
{
"message": "[error message]"
}
]
}
This example models an action which takes first & last name attributes and uses them to populate a full name attribute. As the action response specified that it was successful, this will also automatically populate the
action_success
attribute with true
.Request
{
"input_data": {
"attributes": {
"first_name": "John",
"last_name": "Smith",
}
}
}
Response
{
"successful": true,
"output_data": {
"attributes": {
"full_name": "John Smith"
}
}
}
This example models a successful action which takes feedback attributes and then returns
null
values for some of them, causing OpenDialog to unset those attributes. It is possible for an action response to both unset and populate attributes, they are not mutually exclusive. As the action response specified that it was successful, this will also automatically populate the action_success
attribute with true
.Request
{
"input_data": {
"attributes": {
"location": "Bristol",
"rating": 5,
"comments": "Great service!"
}
}
}
Response
{
"successful": true,
"output_data": {
"attributes": {
"rating": null,
"comments": null,
"referral_code": "ABCXYZ123"
}
}
}
This example models an unsuccessful action which has returned an error. As the action response specified that it was unsuccessful, this will also automatically populate the
action_success
attribute with false
. The error message(s) will be automatically added to the logs.Request
{
"input_data": {
"attributes": {
"location": "Bristol"
}
}
}
Response
{
"successful": false,
"errors": [
{
"message": "Missing expected attributes: 'rating', 'comments'"
}
]
}