heroku / dreamhouse-disco-old

A fun demo app to show off Heroku basics including Teams and Pipelines
0 stars 0 forks source link

Add ChatterBot Autoresponse to Salesforce Org #31

Closed thejonanshow closed 8 years ago

thejonanshow commented 8 years ago

https://appexchange.salesforce.com/listingDetail?listingId=a0N30000003HizvEAC

When a Salesforce user sends a message to the Dreamhouse Disco user with Chatter, the ChatterBot Autoresponse App should create a "track" in the Salesforce DB.

thejonanshow commented 8 years ago

Using an Apex trigger instead.

trigger ChatterFeedItem on FeedItem (before insert) {
    List<Track__c> tracks = new List<Track__c>();
    for(FeedItem item : Trigger.new){
        system.debug(item);
        Track__c newTrack = new Track__c();
        newTrack.Name = item.Body;
        tracks.add(newTrack);
    }

    try {
        insert tracks;
    } catch (system.DmlException e) {
        system.debug(e);
    }
}

Add the trigger under Setup, search for 'apex'. Technically triggers for any Chatter feed item, but could easily be restricted to a specific user. Should be fine for the demo.

image