Check out example codes for "como crear un bot para whatsapp". It will help you in understanding the concepts better.

Code Example 1

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);
    }
  }
}

Learn ReactJs, React Native from akashmittal.com