Need a little help with issue

Hey php help, I’m hoping you guys can help me sort of a slight nuisance that I’m having. I’m in the process of configuring a Twilio integration that responds to sms keywords, this one to be specific: https://www.twilio.com/help/faq/sms/how-do-i-build-a-sms-keyword-response-application

While that works perfectly with single keywords, in my application people will not be texting single words but rather a string.

I have found this documentation: http://stackoverflow.com/questions/33332423/twilio-sms-keyword-autoresponder-search-incoming-body/33352749

But it doesn’t seem to work, although I’m sure I’m not doing something right.

This application is for real estate, so obviously I will be changing out the keywords and responses, but what I’m looking for is this: Right now, someone could text the word ‘listing’ or ‘showing’ to my number and it would respond appropriately. However, the way this is set, that won’t happen. The responses the number will receive will be things like “I want to set up a showing” or “Tell me more about this listing at xxx address.”.

Needless to say, I need a parameter for the app to look through the body of the sms for keywords and respond based off those. I’m pretty sure this is possible, so can anyone help me out?

Doesn’t seem to work isn’t really helpful. Can you at least show us what you are trying to do in your code?

Having looked at the documentation:

[PHP]
$response = new Services_Twilio_Twiml;
$body = $_REQUEST[‘Body’];

if( $body == ‘hello’ ){
$response->message(‘Hi!’);
}else if( $body == ‘bye’ ){
$response->message(‘Goodbye’);
}
print $response;
[/PHP]
Source: https://twilio.radicalskills.com/projects/sms-respond/2.html

I don’t see why you can’t search within the $_REQUEST[‘Body’] variable. The problem is, how unique will the keywords be? E.g. “Your website is not showing me the listing” would contain both keywords.

Either way you could use something like:

[PHP]
if(stripos($body, “showing”) !== FALSE) {

// message contains the word “showing”

} else {

// message does not contain the word “showing”

if(stripos($body, “listing”) !== FALSE){

// message contains the word “listing”

}else {

//Does not contain any keywords - show generic response

}
}
[/PHP]

Sponsor our Newsletter | Privacy Policy | Terms of Service