Passing messages to external API's / auto responder

I’m looking to build a service similar to Imified (www.imified.com) or Vicito (www.vicito.com).

User flow is:

  1. User adds bot (listener@mydomain.com)

  2. User can then send commands to the bot (ie “weather”)

  3. Bot takes command, does lookup for keywords etc, then passes to an external API

  4. API does lookup (say, uses weather.com API or whatever)

  5. Response returned to system

  6. Response returned to user

I can see several ways of possibly doing this: either at packet level, or by querying the underlying database(?). Does anyone have any views on the best way of approaching this, what (if any) plugins to use, etc?

Thanks in advance

Mike