como crear un bot para whatsapp code example

Example: como crear un bot para whatsapp

const MessagingResponse = require('twilio').twiml.MessagingResponse;
// Dialogflow, IBM Watson, Alexa...
export interface NaturalProcessorLanguage {
  detectIntent(text: string, sessionId?: string): Promise<string>;
  getMedia(): string;
}

export class WhatsappCreator {
  private twiml = new MessagingResponse();
  private message = this.twiml.message();
  constructor(private naturalProcessorLanguage: NaturalProcessorLanguage) {
  }
  //XML response
  async create(text: string, sessionId: string): Promise<string> {
    const fulfillmentText = await this.naturalProcessorLanguage.detectIntent(text, sessionId);
    this.message.body(fulfillmentText);
    this.setMedia(this.naturalProcessorLanguage.getMedia());
    return this.twiml.toString();
  }
  private setMedia(media: string) {
    if (media) {
      this.message.media(media);
    }
  }
}