PHP Question

irish_ignite's Avatar

irish_ignite

30 Oct, 2009 11:25 AM via web

i want to make my bot do something specifically. i know alittle bit about php but not fully. let me break it down as best i can on what i want it to do.

if someone says HI

i want to make it echo, hi how are you

if someone says good you

i want it to echo wounderful thanks for asking

and so on and so forth

after that it has everything taught the stuff people would ask that it isn't programed i want it to echo sorry, i don't understand, please try again.

what script to i use where i can keep adding peoples responses to the bots echos.

  1. 2 Posted by Ben Parzybok on 19 Nov, 2009 05:12 PM

    Ben Parzybok's Avatar

    Here's an example:

    Create a php script called bot.php
    Put it up on a domain, and make sure your bot URL reflects the location of that script.
    Paste this into bot.php:

    <?php

    //convert all messages to lower case

    $msg = strtolower($_REQUEST["msg"]);

    switch($msg)
    {

        case "hi":
                echo "Hi, how are you?";
        break;
        case "Good you?":
                echo "Wonderful. Thanks for asking.";
       break;
      default:
              echo "sorry, i don't understand, please try again.";
      break;
    

    } ?>

  2. Support Staff 3 Posted by Danté Vitulano on 20 Nov, 2009 03:03 PM

    Danté Vitulano's Avatar

    Ben is right on the money. If afterwards you wanted to add additional possible responses, all you would need to do is add more cases. It's as simple as that.

    ~Danté

  3. Danté Vitulano closed this discussion on 20 Nov, 2009 03:03 PM.

  4. irish_ignite re-opened this discussion on 28 Nov, 2009 05:44 AM

  5. 4 Posted by irish_ignite on 28 Nov, 2009 05:44 AM

    irish_ignite's Avatar

    yea sorry, i seen the response in an email. didn't get around to messaging back. this is exactly what i was looking for. I really really appreciate the help and thank ya a lot for everything.

  6. 5 Posted by mlucas on 15 Oct, 2010 03:39 PM

    mlucas's Avatar

    It looks like we've answered this for you, so we're going to mark this question as resolved. If you have any questions, you can re-open this issue or send a new one in and we'll be glad to help.

    -Matt Lucas
    IMified Support

  7. mlucas closed this discussion on 15 Oct, 2010 03:39 PM.

Comments are currently closed for this discussion. You can start a new one.