Postman API To Swift
# 🤝help
d
Hello everyone! I have a question regarding my Botpress AI project. I plan to integrate it with my SwiftUI app. Is it possible to achieve functionality by linking Postman to BotPress, thus enabling the AI to work with Swift? Please let me know if my question is unclear, and I'll be happy to rephrase it. I've tried through the documentation docs, but I haven't been able to do it correctly.
b
I'm not sure I understand the full scope of your question, but in a recent livestream I demonstrate using Postman to test webhooks in Botpress
perhaps this helps?
you can find the recording of it on YouTube 🙂
d
Perfect, thank you. Yeah, basically I want to create a AI app, using BotPress. I've already built the UI on Swift, but am having some trouble linking the two so I can send and receive messages through the app
HI! I've been trying to do this, and I watchted the video tutorial too on the Botpress docs, but whenever I run it through postman I get this error "message": "Request failed with status code 502 (Error ID: err_20240510003342x1E92BAB3)"
f
Can you enlighten me on what exactly you tried to do through PostMan?
d
Yeah I've been trying to create a Swift app, linked with the Botpress AI. So, users can send and receive messages in app, I'm new to all this but I followed the Message API video in order to create a API endpoint (on Postman) so it would work in app. Does this make sense? I keep getting errors though...
Yeah I've been trying to create a Swift app, linked with the Botpress AI. So, users can send and receive messages in app, I'm new to all this but I followed the Message API video in order to create a API endpoint (on Postman) so it would work in app. Does this make sense? I keep getting errors though...
f
And what exactly is giving you the error on PostMan? What are you doing from there? Can you share the code?
d
Yes of course! {"id": "err_20240510201154x16D6F81C", "code": 500, "type": "Unknown", "message": "Request failed with status code 502 (Error ID: err_20240510201154x16D6F81C)" Is the error I get, I beleive this means there's an error on Botpresses end. I am trying to connect postman to my Swift app, does that make sense?! Maybe I'm not doing this correctly....
f
Can you share the http request that you made to get this error?
d
Yes, it was a POST request
Yes, it was a POST request
f
Can you copy the cUrl that you used and send it to me in a DM so I can understand the issue a bit better?
d
Yes, of course I'll DM you one moment
f
Thank you
d
Just DM you! Let me know if you don't see it
f
I see it
d
Good To Know!
f
You sent the JSON data which is fine and there doesn't seem to be any issues with that, but it does not help that much with debugging a 502 error. Can you send me the cURL that you are using. You can replace your PAT with x's.
d
Yeah, HTTP POST. Is that what it is?
f
Your cURL could look like this:
Copy code
bash
curl -X POST "http://your-botpress-url" \
-H "Content-Type: application/json" \
-d '{
    "userID": "remoteUserId",
    "messageID": "remoteMessageId",
    "conversationId": "remoteConversationId",
    "type": "text",
    "text": "Any text you want to send, otherwise a short description of what you are sending",
    "payload": {
        "foo": "bar",
        "user": {
            "userName": "Robert"
        }
    }
}'
http://your-botpress-url
would be the actual URL
d
Thank you! I tried it again but I still seem to be getting the error "id": "err_20240510221642x5F9C72E1", "code": 500, "type": "Unknown", "message": "Request failed with status code 502 (Error ID: err_20240510221642x5F9C72E1)" I don't know what's causing this...I've tried everything
f
Can you send me your cURL that looks like the one I sent to you?
d
Yeah I just Dm'd it to you
f
I don't believe you can make a post to the shared URL. Where did Botpress state that you can do this?
d
Messaging API under "instructions" perhaps I read it wrong?
f
You should use the "Webhook URL" as stated in the readme. You should read it all again, and see the videos provided by Patrick, they explain it well 🙂
d
Thank you!! I'll try again
f
Best of luck
2 Views