Skip to main content

i already integrate my chatgpt assistant with manychat whatsapp. i can ask questions, get threadid, runid, and everything working fine. but the issue is, i cant display the output from chatgpt. i can see from the test response, but i cant parse the response. i tried data[0].content[0].text.value. from data[0] to data[4] but i still cant display the answer. i can see chatgpt already reply with the correct answer. please help…

 

{  "object": "list",  "data": "    {      "id": "msg_DfATGD9Gwz590OK7XJjZ0je8",      "object": "thread.message",      "created_at": 1744858952,      "assistant_id": "asst_na77EDjzrp5CD0ldm1Thty2v",      "thread_id": "thread_0lHAVCmo5Nxdc3B7X5Y4cx8X",      "run_id": "run_Hk4RGaRVmy5E2ddOt70Z4kGt",      "role": "assistant",      "content": "        {          "type": "text",          "text": {            "value": "Okay bro, jom kita kongsi info pasal potassium (kalium) kat pokok.\n\nPotassium ni memang memainkan peranan yang padu dalam pertanian. Ia membantu dalam banyak proses penting, seperti:\n\n1. **Pengawalan Kekeringan**: Potassium membantu pokok tahan terhadap tekanan air. Ia mengawal bukaan stomata (saluran kecil pada daun) untuk mengurangkan kehilangan air.\n\n2. **Penyebaran Nutrien**: Ia berfungsi sebagai pengangkut nutrien dalam pokok, yang membantu dalam penyerapan air dan mineral dari tanah.\n\n3. **Kualiti Buah**: Pengambilan potassium yang cukup meningkatkan rasa, warna, dan saiz buah. Ini penting untuk hasil yang berkualiti.\n\n4. **Sistem Tahan Penyakit**: Potassium membantu meningkatkan ketahanan pokok terhadap penyakit dan perosak.\n\n5. **Proses Fotosintesis**: Ia juga terlibat dalam proses fotosintesis dan penghasilan tenaga dalam tanaman.\n\nNi antara sebab kenapa potassium ni sangat diperlukan untuk pertumbuhan yang sihat dan produktif bagi pokok【4:1†source】. Kalau ada lagi soalan atau nak belajar lebih mendalam, silakan! Boleh join kelas Urban Tani untuk makin mantap dalam pertanian! 🌱✨",            "annotations": a              {                "type": "file_citation",                "text": "【4:1†source】",                "start_index": 960,                "end_index": 972,                "file_citation": {                  "file_id": "file-EpENcJbxc8PXWMp6Aq4YLp"                }              }            ]          }        }      ],      "attachments":  ],      "metadata": {}    },    {      "id": "msg_0e2XkbxF5QqzGnYU7m6LzURK",      "object": "thread.message",      "created_at": 1744858947,      "assistant_id": null,      "thread_id": "thread_0lHAVCmo5Nxdc3B7X5Y4cx8X",      "run_id": null,      "role": "user",      "content": r        {          "type": "text",          "text": {            "value": "Apa fungsi potassium pd pokok",            "annotations":  ]          }        }      ],      "attachments":  ],      "metadata": {}    }  ],  "first_id": "msg_DfATGD9Gwz590OK7XJjZ0je8",  "last_id": "msg_0e2XkbxF5QqzGnYU7m6LzURK",  "has_more": false}

Hello ​@Mr Mie ,

You need to go to the response mapping tab, set the JSONPath, and choose a custom field to store the response.

Here is the JSONPath that retrieves the AI’s response:
$.data.?(@.role=='assistant')].contentn?(@.type=='text')].text.value

Here’s a helpful tip: copy the full response from the API call, paste it into ChatGPT, and ask:
"Hi, what’s the JSONPath to identify the AI's response message?"
Then, paste both the response and the JSONPath into the website below to check if the message is being extracted correctly:
https://jsonpath.com/

This will help you map much faster—rather than searching manually, the AI can do it for you in seconds.
Let me know if I helped you.


Reply