Live Helper Chat support forum.. Forum is locked. New place for questions - Github Discussions

You are not logged in.

Announcement

#1 2020-08-06 11:05:14

visvamba
New member
Registered: 2020-08-06
Posts: 4

Integrate AI with Bot - response JSON format and trigger type

I'm trying to integrate a 3rd party AI backend with the bot functionality. My backend returns JSON response that looks like this:

[== JavaScript ==]
{
    "msg": "Hi there! What can I help you with today?\n",
    "meta_msg": {
        "content": {
            "quick_replies": [        
                {
                    "type": "button",
                    "content": {
                        "name": "Raise a new ticket",
                        "payload": "/raise_ticket"
                    }
                },
                {
                    "type": "button",
                    "content": {
                        "name": "Login issues",
                        "payload": "/cant_login"
                    }
                },
                {
                    "type": "button",
                    "content": {
                        "name": "Hardware request",
                        "payload": "/hardware_request"
                    }
                },
            ] }}}

I have set up my REST API like so:
1596711778_screen1.jpg

And this is my trigger set up for the bot:
1596711802_screen2.jpg

But I get this kind of response in the chat:
1596711894_screen3.jpg'

What am I doing wrong?

Offline

#2 2020-08-06 11:11:16

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,661
Website

Re: Integrate AI with Bot - response JSON format and trigger type

You are using two incompatible methods. meta_msg is appended directly to the message received. In order to use this response type.

You just need that your response returned full trigger body like.

[== Undefined ==]
{"response":
[
    {
        "_id": "q4f24I899",
        "type": "text",
        "content": {
            "text": "some text...",
            "quick_replies": [
                {
                    "_id": "xJbl-TMRC",
                    "type": "button",
                    "content": {
                        "name": "Name of second button",
                        "payload": "first_payload"
                    }
                }
            ]
        }
    }
]
}

In rest API definition you put

response just as location response. and in this execute trigger bodu {content_1}

See this sampe.
https://doc.livehelperchat.com/docs/bot/trigger-body

Offline

#3 2020-08-10 08:54:48

visvamba
New member
Registered: 2020-08-06
Posts: 4

Re: Integrate AI with Bot - response JSON format and trigger type

Thank you for your response. I have configured the AI backend to return JSON in the format you have suggested. But there is still no response being shown, though I have checked and the response is being sent from the backend. Is it a problem with my trigger?

1597049604_screenshot_2020-08-10_at_4.51.47_pm.png

I have even tried to mock the API to return the JSON trigger body example you posted, and I still do not get any response message in the chat.

Offline

#4 2020-08-10 09:12:08

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,661
Website

Re: Integrate AI with Bot - response JSON format and trigger type

If you append simple response text message and if it's not executed means trigger is not executed. If prior that message nothing is shown. Problem with your Rest API integration.

Offline

#5 2020-08-10 09:15:29

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,661
Website

Re: Integrate AI with Bot - response JSON format and trigger type

Also if you followed article you have to return not direct json object in your Rest API but encoded json string.

Offline

Board footer