AI Chatbot in ROBLOX using AI.API


  • I spent quite a few hours last night trying to get an AI chatbot working on ROBLOX using HTTP Service connecting to AI.API.

    I choose this site over others because it's free, and has a nice API.

    However I couldn't get it to work. It seemed really really useful, because you can set the AI to respond to commands, like asking for the weather, and responding to overall small-talk.

    It seemed like such an awesome idea, but the only problem is I'm not good at HTTP stuffs, and I couldn't get ROBLOX to connect with my bot.

    It might not even be possible for all I could know. But it seems unlikely that it wouldn't be possible, considering the whole API and connecting to webhooks and using HTTP to get and send information.

    If anyone could get this setup that would be awesome!


  • The main issue will be the authentication side as it requires you to put the token in the http header.

    The header is a pat of the http request that most users do not see, it contains the meta data about the request an example is the request type PUT, GET, POST ect and the mime type which defines what the content is and how it should be read by the receiving application.

    We might be able to set some of the header information for a PostAsync request as there is an argument for it at the end.

    On a side note it seems that this API supports JSON Post requests as seen here:-

    curl -H "Content-Type: application/json; charset=utf-8" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" --data "{'query':'and for tomorrow', 'timezone':'GMT-5', 'lang':'en', 'contexts':[{ 'name': 'weather', 'parameters':{'city': 'London'}, 'lifespan': 4}], 'sessionId':'1234567890'}" "https://api.api.ai/v1/query?v=20150910"
    

  • @kingdom5 Yeah...

    It seems that might have been my issue when trying to get this to work.

    I always thought it would be awesome to get a form of AI in ROBLOX though. If you can't do it with this site, maybe there's something else... :cat:


  • Try adding in the header with the token for the request, something like this

    local header = {}
    header.Authorization = 'Bearer ' .. token
    

  • @kingdom5 Yeah, then use:

    game:GetService("HttpService"):JSONEncode(header)
    

  • Kingdom helped me get this working.

    Here's a demo place. Say hi :3

    https://www.roblox.com/games/766175810/AI-testing#

    alt text


  • @OldPalHappy Very cool! I'll be sure to check it out when I have the time!


  • @mccrafter1212 The header is not send in a JSON format.

Log in to reply
 

Looks like your connection to Scripting Helpers was lost, please wait while we try to reconnect.